statsmodels.tsa.statespace.kalman_smoother.KalmanSmoother.set_conserve_memory

method

KalmanSmoother.set_conserve_memory(conserve_memory=None, **kwargs)

Set the memory conservation method

By default, the Kalman filter computes a number of intermediate matrices at each iteration. The memory conservation options control which of those matrices are stored.

Parameters
conserve_memoryinteger, optional

Bitmask value to set the memory conservation method to. See notes for details.

**kwargs

Keyword arguments may be used to influence the memory conservation method by setting individual boolean flags. See notes for details.

Notes

The memory conservation method is defined by a collection of boolean flags, and is internally stored as a bitmask. The methods available are:

MEMORY_STORE_ALL = 0

Store all intermediate matrices. This is the default value.

MEMORY_NO_FORECAST = 0x01

Do not store the forecast, forecast error, or forecast error covariance matrices. If this option is used, the predict method from the results class is unavailable.

MEMORY_NO_PREDICTED = 0x02

Do not store the predicted state or predicted state covariance matrices.

MEMORY_NO_FILTERED = 0x04

Do not store the filtered state or filtered state covariance matrices.

MEMORY_NO_LIKELIHOOD = 0x08

Do not store the vector of loglikelihood values for each observation. Only the sum of the loglikelihood values is stored.

MEMORY_NO_GAIN = 0x10

Do not store the Kalman gain matrices.

MEMORY_NO_SMOOTHING = 0x20

Do not store temporary variables related to Klaman smoothing. If this option is used, smoothing is unavailable.

MEMORY_NO_SMOOTHING = 0x20

Do not store standardized forecast errors.

MEMORY_CONSERVE

Do not store any intermediate matrices.

Note that if using a Scipy version less than 0.16, the options MEMORY_NO_GAIN, MEMORY_NO_SMOOTHING, and MEMORY_NO_STD_FORECAST have no effect.

If the bitmask is set directly via the conserve_memory argument, then the full method must be provided.

If keyword arguments are used to set individual boolean flags, then the lowercase of the method must be used as an argument name, and the value is the desired value of the boolean flag (True or False).

Note that the memory conservation method may also be specified by directly modifying the class attributes which are defined similarly to the keyword arguments.

The default memory conservation method is MEMORY_STORE_ALL, so that all intermediate matrices are stored.

Examples

>>> mod = sm.tsa.statespace.SARIMAX(range(10))
>>> mod.ssm..conserve_memory
0
>>> mod.ssm.memory_no_predicted
False
>>> mod.ssm.memory_no_predicted = True
>>> mod.ssm.conserve_memory
2
>>> mod.ssm.set_conserve_memory(memory_no_filtered=True,
...                             memory_no_forecast=True)
>>> mod.ssm.conserve_memory
7