| qpm_filter | R Documentation |
Runs the Kalman filter and RTS smoother over the solved model, jointly inferring every latent variable — output gap, neutral rate, equilibrium exchange rate, trend processes — and the historical structural shocks from whatever subset of variables you actually observe. Missing values (ragged edges, gappy series) are handled naturally.
qpm_filter(x, data, observables = NULL, measurement_error = 0, kappa = 1e+06)
x |
A |
data |
A data frame in levels (model units). Columns whose names
match declared variables are used as observables; an optional
|
observables |
Optional character vector restricting which columns are treated as observed. |
measurement_error |
Measurement-error standard deviation(s): scalar or named vector over observables. Defaults to 0. |
kappa |
Diffuse-prior variance scale used when the model has
unit-root (random-walk) trends; see |
The filter is initialized at the model's stationary distribution (Lyapunov covariance), which is exact for the stationary models qpmR currently supports.
An object of class qpm_filtration: smoothed states in levels
($states), their standard errors ($se), smoothed structural
shocks ($shocks), the log-likelihood ($loglik), innovation
diagnostics ($diag), and the full expanded-state matrix
($states_dev). Feed it to qpm_decompose() for historical shock
decompositions or to qpm_forecast() to forecast from the smoothed
current state.
sol <- qpm_solve(qpm_template("bkl"))
obs <- simulate(sol, nsim = 60, seed = 3, burn = 20)
fit <- qpm_filter(sol, obs[, c("period", "pi", "i", "q")])
fit
plot(fit, vars = c("y_gap", "r_bar"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.