Kalman Filter Configuration Guide
TL;DR
You can see an example config here.
Read Model Configuration Guide
This guide refers to fields used in model configuration and some parameters relevant to Kalman Filters are part of the model parameter family. Please make sure you've read the model configuration guide before reading this one.
SymbolicDSGE uses a single configuration file and appends the Kalman Filter (KF) configuration to the same YAML that carries model information. Although Kalman Filtering can be done in a completely model-detached fashion, there's integration infrastructure provided in the model objects and configurations.
All KF related configuration entries live under the parent field kalman: and are parsed into a KalmanConfig object at parse time.
Config Overrides
All configuration fields (except R:) can be overridden through function parameters when calling the filter.
Observables
The config uses a tag y to define the list of model measurement equations to include in the Kalman Filter.
- The listed names are observable names defined in the model configuration
To ensure matrix alignment, names given here will be reordered to match their ordering in the model configuration. You can check the order via ModelConfig.observables or CompiledModel.observable_names to confirm the positions to expect the output arrays in.
Alignment Demonstration
Assume we have three observables and use two of them. In the model config, we defined observables: [obs1, obs2, obs3] and for the KF configuration, we used y: [obs3, obs1].
The alignment occurs on the positional index of observables as given in the model config. So we re-order to y: [obs1, obs3] internally.
This will reflect in all ndarrays outputted from a KF run and it is generally advisable to check alignment or confirm the updated positions of observable arrays to avoid future confusion.
Measurement Covariance
Measurement Covariance (\(R\)) is constructed through parameters defined in the model configuration. We use the parent R: and populate it as such:
Then we populate each sub-field with respective parameter names:
- Defined as a parameter and given calibration value in model config.
- Defined as a parameter and given calibration value in model config.
- Defined as a parameter and given calibration value in model config.
No Defaults
SymbolicDSGE does not fall back to defaults when constructing \(R\). As of now, heuristics to infer \(R\) are not implemented and any "default" is practically guaranteed to be inaccurate. There are future plans to implement robust \(R\) inference pipelines; but the no-default behavior will not change until said implementations are in place.
Runtime Diagonal R Estimation
SolvedModel.kalman(...) also exposes estimate_R_diag=True (with optional R_scale) to estimate a diagonal R by likelihood before filtering. This is a runtime option and does not mutate the configuration.
State Covariance
State Covariance (\(P\)) defines the inter-state variation through a covariance matrix. \(P\) is an inferred parameter in Kalman Filters; but an initial guess \(P_0\) is provided through the configuration. As of now, the configuration only allows the creation of diagonally-defined matrices (assumes no correlation) but a full \(P_0\) construction will be implemented. Initial guesses are not relevant beyond an (often short) burn-in period; but a well-specified \(P_0\) guess can help convergence speeds. In the config we define a parent P0: and populate the following fields:
P0construction mode."eye"uses \(I_n \times \operatorname{scale}\) while"diag"constructs the matrix from below defined diagonal values before scaling byscale.- Scaling factor of P0.
- Diagonal entries of the covariance matrix.
Diagonal Values
The diag field is directly used as the pre-scaling matrix values. Therefore, entries in the diag field correspond to variances instead of standard deviations.
Filter Options
SymbolicDSGE defines two KF options that can be adjusted through the configuration file. These options do not belong to a parent tag and are defined as follows:
- The number specified is added to covariance matrices if their Cholesky decomposition fails.
- Covariance matrices are symmetrized if this field is
true. Symmetrization is applied as \((M + M^\top)/2\).
Conclusion
The configuration fields above provide all KF necessary information that can't (or shouldn't) be inferred from the model state. This config field is only relevant to SolvedModel.kalman. If you've read to this point and want to check a complete configuration file including kalman and model configurations, you can visit this link.