State space model
ssm_lm.Rd
Computes state space model with one equation. Starting with a simple lm
model, build the all state space model and run it.
Use rjd3sts
packages.
Usage
ssm_lm(
x,
trend = FALSE,
var_intercept = 0,
var_slope = 0,
var_variables = 0,
fixed_var_intercept = TRUE,
fixed_var_trend = TRUE,
fixed_var_variables = TRUE,
...,
remove_last_dummies = FALSE,
intercept = TRUE
)
Arguments
- x
a
lm
ordynlm
model- trend
boolean indicating if the model should have a trend.
- var_intercept, var_slope
variance of the intercept (used if
ìntercept = TRUE
) and the slope (used iftrend = TRUE
).- var_variables
variance of the other variables: can be either a single value (same variance for all the variables) or a vector specifying each variance.
- fixed_var_intercept, fixed_var_trend, fixed_var_variables
logical indicating if the variance are fixed or estimated.
- ...
other arguments used in
rjd3sts::estimate()
.- remove_last_dummies
boolean indicating if current dummies (i.e.: only 0 and 1 at the last date) should be removed.
- intercept
boolean indicating if the model should have an intercept.
Value
Returns a list
containing:
- smoothed_states
\(E[a_t|y_0,\dots,y_n]\)
- smoothed_stdev
\(\sqrt{V[a_t|y_0,\dots,y_n]}\)
- filtering_states
\(E[a_t|y_0,\dots,y_{t-1}]\)
- filtering_stdev
\(\sqrt{V[a_t|y_0,\dots,y_{t-1}]}\)
- parameters
some estimation parameters
- data
data used in the original model
Examples
data_gdp <- window(gdp, start = 1980, end = c(2019, 4))
reg_lin <- lm(
formula = growth_gdp ~ bc_fr_m1 + diff_bc_fr_m1,
data = data_gdp
)
ssm <- ssm_lm(reg_lin, fixed_var_intercept = FALSE, fixed_var_variables = FALSE)
ssm
#> Mean of time-varying estimated coefficients (smoothing):
#> (Intercept) bc_fr_m1 diff_bc_fr_m1 noise
#> -1.5964 0.0205 0.0425 0.0000
summary(ssm)
#> Summary of time-varying estimated coefficients (smoothing):
#> (Intercept) bc_fr_m1 diff_bc_fr_m1 noise
#> Min. -1.596 0.01877 0.01990 -1.426e+00
#> 1st Qu. -1.596 0.01920 0.02492 -1.953e-01
#> Median -1.596 0.02094 0.04371 1.087e-02
#> Mean -1.596 0.02046 0.04252 -1.605e-17
#> 3rd Qu. -1.596 0.02147 0.05741 2.240e-01
#> Max. -1.596 0.02174 0.07843 7.934e-01