Simulation Smoother

Note that this class inherits from Kalman smoother; its documentation should be consulted for additional methods available in SimulationSmoother objects.

class dismalpy.ssm.simulation_smoother.SimulationSmoother(k_endog, k_states, k_posdef=None, simulation_smooth_results_class=None, **kwargs)[source]

State space representation of a time series process, with Kalman filter and smoother, and with simulation smoother.

Parameters:

k_endog : array_like or integer

The observed time-series process \(y\) if array like or the number of variables in the process if an integer.

k_states : int

The dimension of the unobserved state process.

k_posdef : int, optional

The dimension of a guaranteed positive definite covariance matrix describing the shocks in the measurement equation. Must be less than or equal to k_states. Default is k_states.

simulation_smooth_results_class : class, optional

Default results class to use to save output of simulation smoothing. Default is SimulationSmoothResults. If specified, class must extend from SimulationSmoothResults.

**kwargs

Keyword arguments may be used to provide default values for state space matrices, for Kalman filtering options, for Kalman smoothing options, or for Simulation smoothing options. See Representation, KalmanFilter, and KalmanSmoother for more details.

get_simulation_output(simulation_output=None, simulate_state=None, simulate_disturbance=None, simulate_all=None, **kwargs)[source]

Get simulation output bitmask

Helper method to get final simulation output bitmask from a set of optional arguments including the bitmask itself and possibly boolean flags.

Parameters:

simulation_output : integer, optional

Simulation output bitmask. If this is specified, it is simply returned and the other arguments are ignored.

simulate_state : boolean, optional

Whether or not to include the state in the simulation output.

simulate_disturbance : boolean, optional

Whether or not to include the state and observation disturbances in the simulation output.

simulate_all : boolean, optional

Whether or not to include all simulation output.

**kwargs

Additional keyword arguments. Present so that calls to this method can use **kwargs without clearing out additional arguments.

simulation_smoother(simulation_output=None, results_class=None, prefix=None, **kwargs)[source]

Retrieve a simulation smoother for the statespace model.

Parameters:

simulation_output : int, optional

Determines which simulation smoother output is calculated. Default is all (including state and disturbances).

simulation_smooth_results_class : class, optional

Default results class to use to save output of simulation smoothing. Default is SimulationSmoothResults. If specified, class must extend from SimulationSmoothResults.

prefix : string

The prefix of the datatype. Usually only used internally.

**kwargs

Additional keyword arguments, used to set the simulation output. See set_simulation_output for more details.

Returns:

SimulationSmoothResults

class dismalpy.ssm.simulation_smoother.SimulationSmoothResults(model, simulation_smoother)[source]

Results from applying the Kalman smoother and/or filter to a state space model.

Parameters:

model : Representation

A Statespace representation

simulation_smoother : {{prefix}}SimulationSmoother object

The Cython simulation smoother object with which to simulation smooth.

Attributes

model (Representation) A Statespace representation
dtype (dtype) Datatype of representation matrices
prefix (str) BLAS prefix of representation matrices
simulation_output (integer) Bitmask controlling simulation output.
simulate_state (boolean) Flag for if the state is included in simulation output.
simulate_disturbance (boolean) Flag for if the state and observation disturbances are included in simulation output.
simulate_all (boolean) Flag for if simulation output should include everything.
generated_obs (array) Generated observation vector produced as a byproduct of simulation smoothing.
generated_state (array) Generated state vector produced as a byproduct of simulation smoothing.
simulated_state (array) Simulated state.
simulated_measurement_disturbance (array) Simulated measurement disturbance.
simulated_state_disturbance (array) Simulated state disturbance.
simulate(simulation_output=-1, disturbance_variates=None, initial_state_variates=None)[source]

Perform simulation smoothing

Does not return anything, but populates the object’s simulated_* attributes, as specified by simulation output.

Parameters:

simulation_output : integer, optional

Bitmask controlling simulation output. Default is to use the simulation output defined in object initialization.

disturbance_variates : array_likes, optional

Random values to use as disturbance variates. Usually only specified if results are to be replicated (e.g. to enforce a seed) or for testing. If not specified, random variates are drawn.

initial_state_variates : array_likes, optional

Random values to use as initial state variates. Usually only specified if results are to be replicated (e.g. to enforce a seed) or for testing. If not specified, random variates are drawn.