Construct an object of class ssm_mlg by directly defining the corresponding terms of
the model.
ssm_mlg(
y,
Z,
H,
T,
R,
a1,
P1,
init_theta = numeric(0),
D,
C,
state_names,
update_fn = default_update_fn,
prior_fn = default_prior_fn
)Observations as multivariate time series or matrix with dimensions n x p.
System matrix Z of the observation equation as p x m matrix or p x m x n array.
Lower triangular matrix H of the observation. Either a scalar or a vector of length n.
System matrix T of the state equation. Either a m x m matrix or a m x m x n array.
Lower triangular matrix R the state equation. Either a m x k matrix or a m x k x n array.
Prior mean for the initial state as a vector of length m.
Prior covariance matrix for the initial state as m x m matrix.
Initial values for the unknown hyperparameters theta.
Intercept terms for observation equation, given as a p x n matrix.
Intercept terms for state equation, given as m x n matrix.
Names for the states.
Function which returns list of updated model
components given input vector theta. This function should take only one
vector argument which is used to create list with elements named as
Z, H T, R, a1, P1, D, and C,
where each element matches the dimensions of the original model.
If any of these components is missing, it is assumed to be constant wrt. theta.
Function which returns log of prior density given input vector theta.
Object of class ssm_mlg.
The general multivariate linear-Gaussian model is defined using the following observational and state equations:
$$y_t = D_t + Z_t \alpha_t + H_t \epsilon_t, (\textrm{observation equation})$$ $$\alpha_{t+1} = C_t + T_t \alpha_t + R_t \eta_t, (\textrm{transition equation})$$
where \(\epsilon_t \sim N(0, I_p)\), \(\eta_t \sim N(0, I_k)\) and \(\alpha_1 \sim N(a_1, P_1)\) independently of each other. Here p is the number of time series and k is the number of disturbance terms (which can be less than m, the number of states).
The update_fn function should take only one
vector argument which is used to create list with elements named as
Z, H T, R, a1, P1, D, and C,
where each element matches the dimensions of the original model.
If any of these components is missing, it is assumed to be constant wrt. theta.
Note that while you can input say R as m x k matrix for ssm_mlg,
update_fn should return R as m x k x 1 in this case.
It might be useful to first construct the model without updating function
# NOT RUN {
data("GlobalTemp", package = "KFAS")
model_temp <- ssm_mlg(GlobalTemp, H = matrix(c(0.15,0.05,0, 0.05), 2, 2),
R = 0.05, Z = matrix(1, 2, 1), T = 1, P1 = 10)
ts.plot(cbind(model_temp$y, smoother(model_temp)$alphahat),col=1:3)
# }
Run the code above in your browser using DataLab