SS                   package:sspir                   R Documentation

_R_e_p_r_e_s_e_n_t_a_t_i_o_n _o_f _G_a_u_s_s_i_a_n _S_t_a_t_e _S_p_a_c_e _M_o_d_e_l

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

     Creates an SS-object describing a Gaussian state space model.

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

     SS(y = NA, x = NA,
        Fmat = function(tt, x, phi) { NA },
        Gmat = function(tt, x, phi) { NA },
        Vmat = function(tt, x, phi) { NA },
        Wmat = function(tt, x, phi) { NA },
        m0 = 0, C0 = NA,
        phi = NA)

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

       y: a matrix giving a multivariate time series of observations.
          The observation at time 'tt' is 'y[,tt]'. The dimension of
          'y' is d times n.

       x: a list of entities (eg. covariates) passed as argument to the
          functions 'Fmat', 'Gmat', 'Vmat', and 'Wmat'.

    Fmat: a function depending on the parameter-vector 'phi',
          covariates 'x' and returns the p times d design matrix at
          time 'tt'.

    Gmat: a function depending on the parameter-vector 'phi',
          covariates 'x' and returns the p times p evolution matrix at
          time 'tt'.

    Vmat: a function depending on the parameter-vector 'phi',
          covariates 'x' and returns the d times d (positive definit)
          variance matrix at time 'tt'. 

    Wmat: a function depending on the parameter-vector 'phi',
          covariates 'x' and returns the p times p (positive
          semidefinite) evolution variance matrix at time 'tt'.

      m0: a p times 1 matrix giving the initial state.

      C0: a p times p variance matrix giving the variance matrix of the
          initial state.

     phi: a parameter vector passed as argument to the functions
          'Fmat', 'Gmat', 'Vmat', and 'Wmat'.

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

     The state space model is given by

         Y_t     = F_t^T * theta_t     + v_t, v_t ~ N(0,V_t)


          theta_t = G_t  * theta_{t-1} + w_t, w_t ~ N(0,W_t)

     for t=1,...,n. The matrices F_t, G_t, V_t, and W_t may depend on a
     parameter vector phi. The initialization is given as

                        theta_0 ~ N(m_0,C_0).

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

     An object of class 'SS', which is a list with the following
     components 

       y: as input.

       x: as input.

    Fmat: as input.

    Gmat: as input.

    Vmat: as input.

    Wmat: as input.

      m0: as input.

      C0: as input.

     phi: as input.

       n: the number of time points

       d: the dimension of each observation.

       p: the dimension of the state vector at each timepoint.

  ytilde: for use in the extended Kalman filter.

iteration: for use in the extended Kalman filter.

       m: after Kalman filtering (or smoothing), holds the conditional
          mean of the state vectors given the observations up til time
          t (filtering) or all observations (smoothing). This is
          organised in a p times n dimensional matrix holding m_t
          (m_t^*) in columns.

       C: after Kalman filtering (or smoothing), holds the conditional
          variance of the state vectors given the observations up til
          time t (filtering) or all observations (smoothing). This is
          organised in a list holding the p times p dimensional
          matrices C_t (C_t^*).

      mu: after Kalman smoothing, holds the conditional mean of the
          signal (mu_t=F_t^top theta_t) given all observations. This is
          organised in a d times n dimensional matrix holding mu_t in
          columns.

likelihood: the log-likelihood value after Kalman filtering.

_A_u_t_h_o_r(_s):

     Claus Dethlefsen and Sren Lundbye-Christensen

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

     'ssm' for a glm-like interface of specifying models, 'kfilter' for
     Kalman filter and 'smoother' for Kalman smoother.

_E_x_a_m_p_l_e_s:

     time <- 1:length(UKgas)
     gasmodel <- ssm( log10(UKgas) ~ -1+
                      tvar(polytime(time,1))+
                      tvar(sumseason(time,12)),time=time)

     gasmodel$ss$phi <- StructTS(log10(UKgas),type="BSM")$coef[c(4,1,2,3)]

     fit <- kfs(gasmodel)

     plot( ts( t(fit$m[1:3,]) ) )

