ssm                  package:sspir                  R Documentation

_D_e_f_i_n_e _s_t_a_t_e-_s_p_a_c_e _m_o_d_e_l _i_n _a _g_l_m-_s_t_y_l_e _c_a_l_l.

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

     Use a glm-style formula and family arguments to setup a state
     space model.

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

     ssm(formula, family = gaussian, data = list(), subset =
         NULL, time = NULL)

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

 formula: a formula with univariate response on the lefthand side. The
          righthand side is a sum of terms and the special functions
          'sumseason', 'polytime', 'polytrig', and 'season' can be
          used. Terms can be marked by the 'tvar'-function to create a
          term with time-varying coefficients. A special case is
          'tvar(1)' meaning a random walk.

  family: a description of the error distribution and link function to
          be used in the model. This can be a character string naming a
          family function, a family function or the result of a call to
          a family function.  (See 'family' and 'getFamily' for details
          of family functions.)

    data: an optional data frame containing the variables in the model.
          If not found in 'data', the variables are taken from
          'environment(formula)', typically the environment from which
          'ssm' is called.

  subset: an optional vector specifying a subset of observations to be
          used in the fitting process.

    time: a vector giving the observation times, eg. '1:n'.

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

     An object of class 'ssm' with the following components 

      ss: an object of class 'SS' describing the state space model. In
          addition, the 'ss' object contains the components 'family'
          and 'ntotal' (for binomial case).

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

     Claus Dethlefsen and Sren Lundbye-Christensen.

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

     'SS', 'extended'

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

     data(vandrivers)
     vd <- ssm( y ~ tvar(1) + seatbelt + sumseason(time,12),
               time=time, family=poisson(link="log"),
               data=vandrivers)
     vd$ss$phi["(Intercept)"] <- exp(- 2*3.703307 )
     vd$ss$C0 <- diag(13)*1000
     vd.res <- kfs(vd)

     plot( ts( t(vd.res$m[1:3,]) ))

     attach(vandrivers)
     plot(y,ylim=c(0,20))
     lines(exp(vd.res$m[1,]+vd.res$m[2,]*seatbelt),lwd=2 )

