mskfModel: Specify a Markov regime switching state-space model

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/mskfModel.R

Description

Specify a Markov regime switching state-space model for uni- or multivariate time series.

Usage

1
    mskfModel(object, ...)

Arguments

object

A mskfSkeleton object returned by mskfModelSkeleton.

...

Specifications of the model vectors and matrices. See Details below.

Details

The object is a basic skeleton for a Markov regime switching state-space model for uni- or multivariate time series, the details of which are specified through this function. The time serie(s) is (are) assumed to be (an) indicator(s) for an underlying, (latent) stochastic state process that is described by a state space (vector autoregressive; VAR) model. Both uni- and multi-dimensional latent state spaces are supported. The dynamics of the latent series is assumed to switch between a discrete set of unobserved regimes, each associated with their own set of parameters. Switching between regimes is modeled with a Hidden Markov Model.

Let ny be the number of (endogenous) observed time series, ne the dimension of the (latent) state process, nm the number of regimes, and nx be the number of exogonous time series. The regime switching state-space model consists of the measurement equation and the state transition equation, and a discrete Markov Chain.

The measurement equation is given by

y[t] = W(S[t]) a[t] + B(S[t]) x[t] + e[t]

where y[t] is an ny-vector measurement made at occasion t; a[t] is an ne-vector (latent) state vector for occasion t; x[t] is an nx-vector with exogenous measurements; W(S[t]) is the ny by ne matrix with regression coefficients for predicting the observations from the states; B(S[t]) is an ny by nx matrix with regression coefficients for y[t] from the exogenous measurements; and e[t] ~ N(0, R(S[t])), t = …, -1, 0, 1, …, are ny-dimensional i.i.d. vectors.

The transition equation for the states is given by

a[t] = c(S[t]) + H(S[t]) a[t-1] + G(S[t]) u[t]

where c(S[t]) is a vector with ne intercepts; H(S[t]) is a ne by ne matrix of vector-autoregression coefficients; G(S[t]) is an ne by ne design matrix; and u[t] ~ N(0, K(S_t)), t = …, -1, 0, 1, …, are i.i.d. innovations.

The model parameters W(S[t]), B(S[t]), H(S[t]), R(S[t]), G(S[t]), K(S[t]), and c(S[t]), all depend on the current regime S[t]. The regimes swith from one to the other according to

P(S[t] = s) = ∑ π(s,s') P(S[t-1] = s').

The regimes are labeled with integers from 1 to nm.

The parameters B, c, and G are optional. For the model to be identifiable, the parameter matrices/vectors need to be structured/constraint. All parameters can be constraint to a fixed value, or can be set to be estimated freely. Individual parameters can be fixed or freed through the “patterns” and “matrix” specifications of the model matrices/vectors. To fix model matrix elements to a specific value, the maW, mac, maH, maG, maK, map, arguments are passed with that value. To free model matrix elements to be freely estimated, the paW, pac, paH, paG, paK, pap, arguments are passed specifying (unique) names for the elements. For example, in a two regime model, if W is to be the identity matrix (e.g., to equate the states with the measurements; see the example below), this is specified by mdl = mskf.model(x, maW = diag(ny)) # set H to fixed value diag(ny) for each regime If in addition, c and H are to be estimated, this is specified by mdl = mskf.model(x, maW = diag(ny), pac = 1:4, paH = array(5:12,c(2,2,2))) # elements of c and H freely estimated Names in paW, pac, paH, paG, paK, pap argument values must be integers. Entries in these arguments that are equal to 0 are fixed and not estimated (their values are obtained from maW, mac, maH, maG, maK, map, respectively). Non-unique names in these arguments are treated as equality constraints. For instance, if in the above example the c's should be equal for the two regimes, this is specified by mdl = mskf.model(x, maW = diag(ny), pac = 1:2, paH = array(5:12,c(2,2,2))) # intercept c same across regimes where the names provided through pac (1 and 2) are automatically recycled untill al the c elements have a name. If there shouldn't be any cross-laged influences between the state variables in the example above, this can be specified with mdl = mskf.model(x, maW = diag(ny), pac = 1:2, paH = c(diag(5:6),diag(7:8))) # no cross-lagged influences

Non-zero entries in pattern specifications always supersede matrix value specifications of the corresponding entries.

Parameters can be further constraint with box constraints by passing the lower and/or upper arguments a named vector of lower and upperbounds, where the names are the names is in the pattern specifications.

Patterns left unspecified are automatically given all unique names.

Starting values can be set by passing the start argument a vector in the same way as lower and upper.

Value

Object of class mskf.model.

Author(s)

Ellen Hamaker & Raoul Grasman

References

Hamaker, E.L., & Grasman, R.P.P.P. (2011) ..., Psychometrika, ?, ??–??.

See Also

mskf, paW, pac, paH, paG, paK, pap, maW, mac, maH, maG, maK, map, startValues, plot

Examples

 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
33
34
35
36
37
38
39
40
41
42
43
44
    # simulate a time series
    y = ts(matrix(rnorm(200), ncol = 2));

    ##
    ## build the model
    ##

    ## first a skeleton
    skel = mskfModelSkeleton(y, ne = 2, nm = 2) # 2 latent state variables, 3 regimes

    ## specify the details
    mdl = mskfModel(skel)  # default: y[t] = a[t], same intercept across regimes,
    print(mdl)             #          no cross-lagged influences, unit variance innovations,
                           #          equal switching probabilities

    # freely estimate c across regimes
    mdl = mskfModel(skel, pac = c(1, 2, 3, 4))
    print(mdl)

    # c free across regimes, a cross-lagged influence in one direction
    mdl = mskfModel(skel, pac = c(1, 2, 3, 4), paH = c(5,6,0,7,8,9,0,10))
    print(mdl)
    plot(mdl)

    # set (some) starting values
    mdl = mskfModel(skel, pac = c(1, 2, 3, 4), paH = c(5,6,0,7,8,9,0,10),
            start = c('1'=1, '2'=1, '3'=2, '4'=2, '5'=0.7, '8'=0.7))

    ##
    ## changing the model
    ##

    # restrict auto-regressions to be same across regimes
    paH(mdl) = c(5,6,0,7)
    print(mdl)

    # no cross-lagged influence in the 2nd regime
    paH(mdl)[1,2, "regime 2"] = 0
    plot(mdl)

    # change (some) upper and lower bounds
    upper(mdl) = c('1' = 1, '3'= 1)
    upper(mdl, "paH") = array(1, dim(paH(mdl)))
    lower(mdl, "paH") = array(-1, dim(paH(mdl)))

mskf documentation built on May 2, 2019, 6:47 p.m.