ssm: Define state-space model in a glm-style call.

Description Usage Arguments Value Author(s) See Also Examples

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
ssm(formula, family = gaussian, data = list(), subset =
    NULL, fit = TRUE, phi = NULL, m0 = NULL, C0 = NULL,
                 Fmat = NULL, Gmat = NULL, Vmat = NULL, Wmat = NULL)
## S3 method for class 'ssm'
C0(ssm) 
## S3 method for class 'ssm'
m0(ssm) 
## S3 method for class 'ssm'
Fmat(ssm)
## S3 method for class 'ssm'
Gmat(ssm)
## S3 method for class 'ssm'
Vmat(ssm)
## S3 method for class 'ssm'
Wmat(ssm)
## S3 method for class 'ssm'
phi(ssm) 
## S3 replacement method for class 'ssm'
C0(ssm) <- value
## S3 replacement method for class 'ssm'
m0(ssm) <- value
## S3 replacement method for class 'ssm'
Fmat(ssm) <- value
## S3 replacement method for class 'ssm'
Gmat(ssm) <- value
## S3 replacement method for class 'ssm'
Vmat(ssm) <- value
## S3 replacement method for class 'ssm'
Wmat(ssm) <- value
## S3 replacement method for class 'ssm'
phi(ssm) <- value
getFit(ssm)

Arguments

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 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.

ssm

an object of class ssm.

fit

a logical. If TRUE, the model is fit using the kfs method. Otherwise, the model is returned as is.

phi

a vector of initial values of hyperparamters. Note that these have to be in the right order. Best advice is to leave this option to be NULL and then inspect the returned result using phi(ssm).

m0

a vector with the initial state vector.

C0

a matrix with the variance matrix of the initial state.

Fmat

a function giving the regression matrix at a given timepoint.

Gmat

a function giving the evolution matrix at a given timepoint.

Wmat

a function giving the evolution variance matrix at a given timepoint.

Vmat

a function giving the observation variance matrix at a given timepoint.

value

an object to be assigned to the element of the state space model.

Value

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).

Author(s)

Claus Dethlefsen and Søren Lundbye-Christensen.

See Also

SS, extended

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
data(vandrivers)
vandrivers$y <- ts(vandrivers$y,start=1969,frequency=12)
vd.time <- time(vandrivers$y)
vd <- ssm( y ~ tvar(1) + seatbelt + sumseason(vd.time,12),
          family=poisson(link="log"),
          data=vandrivers,
          phi = c(1,0.0004),
          C0=diag(13)*100,
          fit=FALSE
          )
phi(vd)["(Intercept)"] <- exp(- 2*3.703307 )
C0(vd) <- diag(13)*1000
vd.res <- kfs(vd)

plot( 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 )
detach(vandrivers)

ClausDethlefsen/sspir documentation built on May 6, 2019, 7 p.m.