Skip to contents

R arm of morie.fn.stsmod: \(y_t = Z a_t + e_t\), \(e_t \sim N(0, H)\); \(a_{t+1} = T a_t + R n_t\), \(n_t \sim N(0, Q)\), \(a_1 \sim N(a1, P1)\) (default 0 and \(10^6 I\)). Kalman filter with the prediction-error decomposition of the log-likelihood, filtered states and the Durbin-Koopman backward smoother.

Usage

Stsmod(y, Z, T, H, Q, R, a1 = NULL, P1 = NULL)

Arguments

y

Observations (vector, or n x p matrix).

Z, T, H, Q, R

System matrices (scalars allowed).

a1, P1

Initial state mean and covariance.

Value

List with loglik, filtered, smoothed, predicted, innovations, F.

References

Durbin, J. and Koopman, S. J. (2012). Time Series Analysis by State Space Methods, 2nd ed. Oxford University Press.

Examples

Stsmod(c(1.1, 0.9, 1.4, 1.2, 1.6), 1, 1, 0.5, 0.2, 1, a1 = 0, P1 = 10)$loglik
#> [1] -6.039096