Skip to contents

Formula: E-step Kalman filter + RTS smoother (including the lag-one smoothed covariance); M-step in closed form. For the scalar model


  x_t = phi x_{t-1} + w_t,  w_t ~ N(0, Q)
  y_t = x_t + v_t,          v_t ~ N(0, R)

with the smoothed sums S11 = sum(xs_t^2 + Ps_t), S10 = sum(xs_t xs_{t-1} + Pcs_t), S00 = sum(xs_{t-1}^2 + Ps_{t-1}), the M-step is exactly phi = S10 / S00, Q = (S11 - phi S10) / n and R = mean((y_t - xs_t)^2 + Ps_t).

Usage

Emkfst(y, init = NULL, max_iter = 50)

Arguments

y

Observation sequence.

init

Starting values (phi, Q, R); default (0.9, var/2, var/2).

max_iter

Number of EM iterations; 0 returns the log-likelihood at the starting values without moving them.

Value

List with estimate, phi, Q, R, loglik, loglik_path, iters, n, method.

References

Shumway & Stoffer (1982), J. Time Series Analysis 3(4):253-264, doi:10.1111/j.1467-9892.1982.tb00349.x.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
Emkfst(V)
#> $estimate
#> [1] 1.199973
#> 
#> $phi
#> [1] 1.199973
#> 
#> $Q
#> [1] 0.2010824
#> 
#> $R
#> [1] 0.003397836
#> 
#> $loglik
#> [1] -5.86786
#> 
#> $loglik_path
#>  [1] -17.493063 -14.692095 -12.728719 -11.032501  -9.633378  -8.562621
#>  [7]  -7.809995  -7.315184  -6.994299  -6.777184  -6.621100  -6.503448
#> [13]  -6.411904  -6.338998  -6.279820  -6.230997  -6.190142  -6.155526
#> [19]  -6.125875  -6.100229  -6.077854  -6.058182  -6.040765  -6.025247
#> [25]  -6.011343  -5.998820  -5.987486  -5.977184  -5.967783  -5.959171
#> [31]  -5.951257  -5.943959  -5.937210  -5.930952  -5.925133  -5.919711
#> [37]  -5.914646  -5.909905  -5.905458  -5.901280  -5.897346  -5.893637
#> [43]  -5.890134  -5.886821  -5.883682  -5.880705  -5.877877  -5.875188
#> [49]  -5.872628  -5.870188  -5.867860
#> 
#> $iters
#> [1] 50
#> 
#> $n
#> [1] 8
#> 
#> $method
#> [1] "EM for state-space parameters"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"