UnivariateFilter#

class pymc_experimental.statespace.filters.UnivariateFilter(mode=None)[source]#

The univariate kalman filter, described in [1], section 6.4.2, avoids inversion of the F matrix, as well as two matrix multiplications, at the cost of an additional loop. Note that the name doesn’t mean there’s only one observed time series, that’s the SingleTimeSeries filter. This is called univariate because it updates the state mean and covariance matrices one variable at a time, using an inner-inner loop.

This is useful when states are perfectly observed, because the F matrix can easily become degenerate in these cases.

References

__init__(mode=None)#

Kalman Filter.

Parameters:

mode (str, optional) – The mode used for Pytensor compilation. Defaults to None.

Notes

The BaseFilter class is an abstract base class (ABC) for implementing kalman filters. It defines common attributes and methods used by kalman filter implementations.

mode#

The mode used for Pytensor compilation.

Type:

str or None

seq_names#

A list of name representing time-varying statespace matrices. That is, inputs that will need to be provided to the sequences argument of pytensor.scan

Type:

list[str]

non_seq_names#

A list of names representing static statespace matrices. That is, inputs that will need to be provided to the non_sequences argument of pytensor.scan

Type:

list[str]

eye_states#

An identity matrix of shape (k_states, k_states), stored for computational efficiency

Type:

TensorVariable

eye_posdef#

An identity matrix of shape (k_posdef, k_posdef), stored for computational efficiency

Type:

TensorVariable

eye_endog#

An identity matrix of shape (k_endog, k_endog), stored for computational efficiency

Type:

TensorVariable

Methods

__init__([mode])

Kalman Filter.

add_check_on_time_varying_shapes(data, ...)

Insert a check that time-varying matrices match the data shape to the computational graph.

build_graph(data, a0, P0, c, d, T, Z, R, H, Q)

Construct the computation graph for the Kalman filter.

check_params(data, a0, P0, c, d, T, Z, R, H, Q)

Apply any checks on validity of inputs.

handle_missing_values(y, Z, H)

This function handles missing values in the observation data y and adjusts the design matrix Z and the observation noise covariance matrix H accordingly.

initialize_eyes(R, Z)

Initialize identity matrices for of shapes repeated used in the kalman filtering equations and store them.

kalman_step(y, a, P, c, d, T, Z, R, H, Q)

Performs a single iteration of the Kalman filter, which is composed of two steps : an update step and a prediction step.

predict(a, P, c, T, R, Q)

Perform the prediction step of the Kalman filter.

unpack_args(args)

The order of inputs to the inner scan function is not known, since some, all, or none of the input matrices can be time varying.

update(a, P, y, c, d, Z, H, all_nan_flag)

Perform the update step of the Kalman filter.