KalmanLike               package:stats               R Documentation

_K_a_l_m_a_n _F_i_l_t_e_r_i_n_g

_D_e_s_c_r_i_p_t_i_o_n:

     Use Kalman Filtering to find the (Gaussian) log-likelihood, or for
     forecasting or smoothing.

_U_s_a_g_e:

     KalmanLike(y, mod, nit = 0)
     KalmanRun(y, mod, nit = 0)
     KalmanSmooth(y, mod, nit = 0)
     KalmanForecast(n.ahead = 10, mod)
     makeARIMA(phi, theta, Delta, kappa = 1e6)

_A_r_g_u_m_e_n_t_s:

       y: a univariate time series.

     mod: A list describing the state-space model: see Details.

     nit: The time at which the initialization is computed. 'nit = 0'
          implies that the initialization is for a one-step prediction,
          so 'Pn' should not be computed at the first step.

 n.ahead: The number of steps ahead for which prediction is required.

phi, theta: numeric vectors of length >=0 giving AR and MA parameters.

   Delta: vector of differencing coefficients, so an ARMA model is
          fitted to 'y[t] - Delta[1]*y[t-1] - ...'.

   kappa: the prior variance (as a multiple of the innovations
          variance) for the past observations in a differenced model.

_D_e_t_a_i_l_s:

     These functions work with a general univariate state-space model
     with state vector 'a', transitions 'a <- T a + R e', e ~ N(0,
     kappa Q) and observation equation 'y = Z'a + eta', eta ~ N(0,
     kappa h). The likelihood is a profile likelihood after estimation
     of kappa.

     The model is specified as a list with at least components

     '_T' the transition matrix

     '_Z' the observation coeficients

     '_h' the observation variance

     '_V' 'RQR''

     '_a' the current state estimate

     '_P' the current estimate of the state uncertainty matrix

     '_P_n' the estimate at time t-1 of the state uncertainty matrix

     'KalmanSmooth' is the workhorse function for 'tsSmooth'.

     'makeARIMA' constructs the state-space model for an ARIMA model.

_V_a_l_u_e:

     For 'KalmanLike', a list with components 'Lik' (the log-likelihood
     less some constants) and 's2', the estimate of of kappa.

     For 'KalmanRun', a list with components 'values', a vector of
     length 2 giving the output of 'KalmanLike', 'resid' (the
     residuals) and 'states', the contemporaneous state estimates, a
     matrix with one row for each time.

     For 'KalmanSmooth', a list with two components. Component 'smooth'
     is a 'n' by 'p' matrix of state estimates based on all the
     observations, with one row for each time. Component 'var' is a 'n'
     by 'p' by 'p' array of variance matrices.

     For 'KalmanForecast', a list with components 'pred', the
     predictions, and 'var', the unscaled variances of the prediction
     errors (to be muliplied by 's2').

     For 'makeARIMA', a model list including components for its
     arguments.

_W_a_r_n_i_n_g:

     These functions are designed to be called from other functions
     which check the validity of the arguments passed, so very little
     checking is done.

     In particular, 'KalmanLike' alters the objects passed as the
     elements 'a', 'P' and 'Pn' of 'mod', so these should not be
     shared.

_R_e_f_e_r_e_n_c_e_s:

     Durbin, J. and Koopman, S. J. (2001) _Time Series Analysis by
     State Space Methods._  Oxford University Press.

_S_e_e _A_l_s_o:

     'arima', 'StructTS'. 'tsSmooth'.

