Set the inversion method
The Kalman filter may contain one matrix inversion: that of the forecast error covariance matrix. The inversion method controls how and if that inverse is performed.
Bitmask value to set the inversion method to. See notes for details.
Keyword arguments may be used to influence the inversion method by setting individual boolean flags. See notes for details.
The inversion method is defined by a collection of boolean flags, and is internally stored as a bitmask. The methods available are:
If the endogenous time series is univariate, then inversion can be performed by simple division. If this flag is set and the time series is univariate, then division will always be used even if other flags are also set.
Use an LU decomposition along with a linear solver (rather than ever actually inverting the matrix).
Use an LU decomposition along with typical matrix inversion.
Use a Cholesky decomposition along with a linear solver.
Use an Cholesky decomposition along with typical matrix inversion.
If the bitmask is set directly via the inversion_method 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 inversion method may also be specified by directly modifying the class attributes which are defined similarly to the keyword arguments.
The default inversion method is INVERT_UNIVARIATE | SOLVE_CHOLESKY
Several things to keep in mind are:
If the filtering method is specified to be univariate, then simple division is always used regardless of the dimension of the endogenous time series.
Cholesky decomposition is about twice as fast as LU decomposition, but it requires that the matrix be positive definite. While this should generally be true, it may not be in every case.
Using a linear solver rather than true matrix inversion is generally faster and is numerically more stable.
>>> mod = sm.tsa.statespace.SARIMAX(range(10)) >>> mod.ssm.inversion_method 1 >>> mod.ssm.solve_cholesky True >>> mod.ssm.invert_univariate True >>> mod.ssm.invert_lu False >>> mod.ssm.invert_univariate = False >>> mod.ssm.inversion_method 8 >>> mod.ssm.set_inversion_method(solve_cholesky=False, ... invert_cholesky=True) >>> mod.ssm.inversion_method 16