## What Are State-Space Models?

### Definitions

#### State-Space Model

A state-space model is a discrete-time, stochastic model that contains two sets of equations:

• One describing how a latent process transitions in time (the state equation)

• Another describing how an observer measures the latent process at each period (the observation equation)

Symbolically, you can write a linear, multivariate, time-varying, Gaussian state-space model using the following system of equations

`$\begin{array}{l}{x}_{t}={A}_{t}{x}_{t-1}+{B}_{t}{u}_{t}\\ {y}_{t}-{\left({Z}_{t}\beta \right)}^{\prime }={C}_{t}{x}_{t}+{D}_{t}{\epsilon }_{t},\end{array}$`

for t = 1,...,T.

• ${x}_{t}=\left[{x}_{t1},...,{x}_{t{m}_{t}}\right]\prime$ is an mt-dimensional state vector describing the dynamics of some, possibly unobservable, phenomenon at period t. The initial state distribution (x0) is Gaussian with mean μ0 and covariance matrix Σ0.

• ${y}_{t}=\left[{y}_{t1},...,{y}_{t{n}_{t}}\right]\prime$ is an nt-dimensional observation vector describing how the states are measured by observers at period t.

• At is the mt-by-mt – 1 state-transition matrix describing how the states at time t transition to the states at period t – 1.

• Bt is the mt-by-kt state-disturbance-loading matrix describing how the states at period t combine with the innovations at period t.

• Ct is the nt-by-mt measurement-sensitivity matrix describing how the observations at period t relate to the states at period t.

• Dt is the nt-by-ht observation-innovation matrix describing how the observations at period t combine with the observation errors at period t.

• The matrices At, Bt, Ct, and Dt are referred to as coefficient matrices, and might contain unknown parameters.

• ${u}_{t}=\left[{u}_{t1},...,{u}_{t{k}_{t}}\right]\prime$ is a kt-dimensional, Gaussian, white-noise, unit-variance vector of state disturbances at period t.

• ${\epsilon }_{t}=\left[{\epsilon }_{t1},...,{\epsilon }_{t{h}_{t}}\right]\prime$ is an ht-dimensional, Gaussian, white-noise, unit-variance vector of observation innovations at period t.

• εt and ut are uncorrelated.

• ${Z}_{t}=\left[\begin{array}{cccc}{z}_{t1}& {z}_{t2}& \cdots & {z}_{td}\end{array}\right]$ is row t of a T-by-d matrix of predictors Z. Each column of Z corresponds to a predictor, and each successive row to a successive period. If the observations are multivariate, then all predictors deflate each observation.

• β is a d-by-n matrix of regression coefficients for Zt.

To write a time-invariant state-space model, drop the t subscripts of all coefficient matrices and dimensions.

#### Diffuse State-Space Model

A diffuse state-space model is a state-space model that can contain at least one state with an infinite initial variance, called a diffuse state. In addition to having an infinite initial variance, all diffuse states are uncorrelated with all other states in the model. There are several motivations for using diffuse state-space models:

• The study of very early starting points of some nonstationary systems, such as random walk process, leads to initial distribution variances that approach infinity.

• An infinite variance specification for an initial state distribution indicates complete ignorance, or no prior knowledge, of the diffuse states. The advantage of this specification is that the analysis of these states is more objective. That is, the observations, rather than additional distribution assumptions, aid in understanding the diffuse states. The disadvantage is that posterior distributions of the states might be improper, and the likelihood function is unbounded. However, with enough data and an identifiable, Gaussian state-space model, the filtered and smoothed states, and a likelihood based on them, can be computed using the diffuse Kalman filter.

• Represent a static, initial state as unknown parameter by attributing to it an infinite variance.

#### Time-Invariant State-Space Models

In a time-invariant state-space model:

• The coefficient matrices are equivalent for all periods.

• The number of states, state disturbances, observations, and observation innovations are the same for all periods.

For example, for all t, the following system of equations

`$\begin{array}{c}\left[\begin{array}{c}{x}_{1,t}\\ {x}_{2,t}\end{array}\right]=\left[\begin{array}{cc}{\varphi }_{1}& 0\\ 0& {\varphi }_{2}\end{array}\right]\left[\begin{array}{c}{x}_{1,t-1}\\ {x}_{2,t-1}\end{array}\right]+\left[\begin{array}{cc}0.5& 0\\ 0& 2\end{array}\right]\left[\begin{array}{c}{u}_{1,t}\\ {u}_{2,t}\end{array}\right]\\ {y}_{t}=\left[\begin{array}{cc}{\varphi }_{3}& 1\end{array}\right]\left[\begin{array}{c}{x}_{1,t}\\ {x}_{2,t}\end{array}\right]+0.2{\epsilon }_{t}\end{array}$`

represents a time-invariant state-space model.

#### Time-Varying State-Space Model

In a time-varying state-space model:

• The coefficient matrices might change from period to period.

• The number of states, state disturbances, observations, and observation innovations might change from period to period. For example, this might happen if there is a regime shift or one of the states or observations cannot be measured during the sampling time frame. Also, you can model seasonality using time-varying models.

To illustrate a regime shift, suppose, for t = 1,..,10

`$\begin{array}{c}\left[\begin{array}{c}{x}_{1,t}\\ {x}_{2,t}\end{array}\right]=\left[\begin{array}{cc}{\varphi }_{1}& 0\\ 0& {\varphi }_{2}\end{array}\right]\left[\begin{array}{c}{x}_{1,t-1}\\ {x}_{2,t-1}\end{array}\right]+\left[\begin{array}{cc}0.5& 0\\ 0& 2\end{array}\right]\left[\begin{array}{c}{u}_{1,t}\\ {u}_{2,t}\end{array}\right]\\ {y}_{t}=\left[\begin{array}{cc}{\varphi }_{3}& 1\end{array}\right]\left[\begin{array}{c}{x}_{1,t}\\ {x}_{2,t}\end{array}\right]+0.2{\epsilon }_{t}\end{array},$`

for t = 11

`$\begin{array}{c}{x}_{1,t}=\left[\begin{array}{cc}{\varphi }_{4}& 0\end{array}\right]\left[\begin{array}{c}{x}_{1,t-1}\\ {x}_{2,t-1}\end{array}\right]+0.5{u}_{1,t}\\ {y}_{t}={\varphi }_{5}{x}_{1,t}+0.2{\epsilon }_{t}\end{array},$`

and for t = 12,..,T

`$\begin{array}{c}{x}_{1,t}={\varphi }_{4}+0.5{u}_{1,t}\\ {y}_{t}={\varphi }_{5}{x}_{1,t}+0.2{\epsilon }_{t}\end{array}.$`

There are three sets of state transition matrices, whereas there are only two sets of the other coefficient matrices.

### State-Space Model Creation

To create a standard or diffuse state-space model, use `ssm` or `dssm`, respectively. For time-invariant models, explicitly specify the parametric form of your state-space model by supplying the coefficient matrices. For time-variant, complex models, or models that require constraints, supply a parameter-to-matrix mapping function. The software can infer the type of state (stationary, the constant one, or nonstationary), but it is best practice to supply the state type using, for example, the `StateType` name-value pair argument.

To filter and smooth the states of a specified `ssm` or `dssm` model, the software uses the standard Kalman filter or the diffuse Kalman filter. To implement either, the software requires the parameters of the initial state distribution (x0).

• For stationary states (`StateType` is `0`), the initial means, variances, and covariances are finite, and the software infers them. However, you can specify other values using the properties `Mean0` and `Cov0`, and dot notation.

• For states that are the constant one for all periods (`StateType` is `1`), the initial state means are 1 and covariances are 0.

• For nonstationary or diffuse states (`StateType` is `2`):

• For standard state-space model, the initial state means are 0 and initial state variance is `1e7` by default. To specify an initial state covariance of `Inf`, create a `dssm` model object instead.

• For diffuse state-space models, the initial state means are 0 and initial state variance is `Inf`.

 Durbin J., and S. J. Koopman. Time Series Analysis by State Space Methods. 2nd ed. Oxford: Oxford University Press, 2012.