View source: R/ts_fil_kalman.R
| ts_fil_kalman | R Documentation |
Estimate a latent trend via a state-space model using the
Kalman Filter (KF), wrapping the KFAS package.
ts_fil_kalman(H = 0.1, Q = 1)
H |
variance or covariance matrix of the measurement noise. This noise pertains to the relationship between the true system state and actual observations. Measurement noise is added to the measurement equation to account for uncertainties or errors associated with real observations. The higher this value, the higher the level of uncertainty in the observations. |
Q |
variance or covariance matrix of the process noise. This noise follows a zero-mean Gaussian distribution. It is added to the equation to account for uncertainties or unmodeled disturbances in the state evolution. The higher this value, the greater the uncertainty in the state transition process. |
A ts_fil_kalman object.
R. E. Kalman (1960). A new approach to linear filtering and prediction problems. Journal of Basic Engineering, 82(1), 35–45.
# State-space smoothing with Kalman Filter (KF)
# Load package and example data
library(daltoolbox)
data(tsd)
tsd$y[9] <- 2 * tsd$y[9] # inject an outlier
# Fit KF (H = obs noise, Q = process noise) and transform
filter <- ts_fil_kalman()
filter <- fit(filter, tsd$y)
y <- transform(filter, tsd$y)
# Plot original vs KF-smoothed series
plot_ts_pred(y = tsd$y, yadj = y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.