SingleTimeseriesFilter#

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

Kalman filter optimized for univariate timeseries

If there is only a single observed timeseries, regardless of the number of hidden states, there is no need to perform a matrix inversion anywhere in the filter.

__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)

"

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(*args)

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.