SKF {dfms} | R Documentation |
(Fast) Stationary Kalman Filter
Description
A simple and fast C++ implementation of the Kalman Filter for stationary data with time-invariant system matrices and missing data.
Usage
SKF(X, A, C, Q, R, F_0, P_0, loglik = FALSE)
Arguments
X |
numeric data matrix ( |
A |
transition matrix ( |
C |
observation matrix ( |
Q |
state covariance ( |
R |
observation covariance ( |
F_0 |
initial state vector ( |
P_0 |
initial state covariance ( |
loglik |
logical. Compute log-likelihood? |
Details
The underlying state space model is:
where is
X[t, ]
. The filter then first performs a time update (prediction)
where . This is followed by the measurement update (filtering)
If a row of the data is all missing the measurement update is skipped i.e. the prediction becomes the filtered value. The log-likelihood is computed as
where and
is the prediction error.
For further details see any textbook on time series such as Shumway & Stoffer (2017), which provide an analogous R implementation in astsa::Kfilter0
.
For another fast (C-based) implementation that also allows time-varying system matrices and non-stationary data see FKF::fkf
.
Value
Predicted and filtered state vectors and covariances.
F |
|
P |
|
F_pred |
|
P_pred |
|
loglik |
value of the log likelihood. |
References
Shumway, R. H., & Stoffer, D. S. (2017). Time Series Analysis and Its Applications: With R Examples. Springer.
Harvey, A. C. (1990). Forecasting, structural time series models and the Kalman filter.
Hamilton, J. D. (1994). Time Series Analysis. Princeton university press.
See Also
Examples
# See ?SKFS