ssm {sspir} | R Documentation |
Use a glm-style formula and family arguments to setup a state space model.
ssm(formula, family = gaussian, data = list(), subset = NULL, time = NULL)
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 . |
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). |
Claus Dethlefsen and Søren Lundbye-Christensen.
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 )