This example shows how to create a stationary ARMA model subject to measurement error using `ssm`

.

To explicitly create a state-space model, it is helpful to write the state and observation equations in matrix form. In this example, the state of interest is the ARMA(2,1) process

$${x}_{t}=c+{\varphi}_{1}{x}_{t-1}+{\varphi}_{2}{x}_{t-2}+{u}_{t}+{\theta}_{1}{u}_{t-1},$$

where $${u}_{t}$$ is Gaussian with mean 0 and known standard deviation 0.5.

The variables $${x}_{t}$$, $${x}_{t-1}$$, and $${u}_{t}$$ are in the state-space model framework. Therefore, the terms $$c$$, $${\varphi}_{2}{x}_{t-2}$$, and $${\theta}_{1}{u}_{t-1}$$ require "dummy states" to be included in the model.

Subsequently, the state equation is

$$\left[\begin{array}{c}{x}_{1,t}\\ {x}_{2,t}\\ {x}_{3,t}\\ {x}_{4,t}\end{array}\right]=\left[\begin{array}{cccc}{\varphi}_{1}& c& {\varphi}_{2}& {\theta}_{1}\\ 0& 1& 0& 0\\ 1& 0& 0& 0\\ 0& 0& 0& 0\end{array}\right]\left[\begin{array}{c}{x}_{1,t-1}\\ {x}_{2,t-1}\\ {x}_{3,t-1}\\ {x}_{4,t-1}\end{array}\right]+\left[\begin{array}{c}0.5\\ 0\\ 0\\ 1\end{array}\right]{u}_{1,t}$$

Note that:

*c*corresponds to a state ($${x}_{2,t}$$) that is always`1`

.$${x}_{3,t}={x}_{1,t-1}$$, and $${x}_{1,t}$$ has the term $${\varphi}_{2}{x}_{3,t-1}={\varphi}_{2}{x}_{1,t-2}$$.

$${x}_{1,t}$$ has the term $$0.5{u}_{1,t}$$.

`ssm`

puts state disturbances as Gaussian random variables with mean 0 and variance 1. Therefore, the factor`0.5`

is the standard deviation of the state disturbance.$${x}_{4,t}={u}_{1,t}$$, and $${x}_{1,t}$$ has the term $${\theta}_{1}{x}_{4,t}={\theta}_{1}{u}_{1,t-1}$$.

The observation equation is unbiased for the ARMA(2,1) state process. The observation innovations are Gaussian with mean 0 and known standard deviation 0.1. Symbolically, the observation equation is

$${y}_{t}=\left[\begin{array}{cccc}1& 0& 0& 0\end{array}\right]\left[\begin{array}{c}{x}_{1,t}\\ {x}_{2,t}\\ {x}_{3,t}\\ {x}_{4,t}\end{array}\right]+0.1{\epsilon}_{t}.$$

You can include a measurement-sensitivity factor (a bias) by replacing `1`

in the row vector by a scalar or unknown parameter.

Define the state-transition coefficient matrix. Use `NaN`

values to indicate unknown parameters.

A = [NaN NaN NaN NaN; 0 1 0 0; 1 0 0 0; 0 0 0 0];

Define the state-disturbance-loading coefficient matrix.

B = [0.5; 0; 0; 1];

Define the measurement-sensitivity coefficient matrix.

C = [1 0 0 0];

Define the observation-innovation coefficient matrix.

D = 0.1;

Use `ssm`

to create the state-space model. Set the initial-state mean (`Mean0`

) to a vector of zeros and covariance matrix (`Cov0`

) to the identity matrix, except set the mean and variance of the constant state to `1`

and `0`

, respectively. Specify the type of initial state distributions (`StateType`

) by noting that:

$${x}_{1,t}$$ is a stationary, ARMA(2,1) process.

$${x}_{2,t}$$ is the constant 1 for all periods.

$${x}_{3,t}$$ is the lagged ARMA process, so it is stationary.

$${x}_{4,t}$$ is a white-noise process, so it is stationary.

Mean0 = [0; 1; 0; 0]; Cov0 = eye(4); Cov0(2,2) = 0; StateType = [0; 1; 0; 0]; Mdl = ssm(A,B,C,D,'Mean0',Mean0,'Cov0',Cov0,'StateType',StateType);

`Mdl`

is an `ssm`

model. You can use dot notation to access its properties. For example, print `A`

by entering `Mdl.A`

.

Use `disp`

to verify the state-space model.

disp(Mdl)

State-space model type: ssm State vector length: 4 Observation vector length: 1 State disturbance vector length: 1 Observation innovation vector length: 1 Sample size supported by model: Unlimited Unknown parameters for estimation: 4 State variables: x1, x2,... State disturbances: u1, u2,... Observation series: y1, y2,... Observation innovations: e1, e2,... Unknown parameters: c1, c2,... State equations: x1(t) = (c1)x1(t-1) + (c2)x2(t-1) + (c3)x3(t-1) + (c4)x4(t-1) + (0.50)u1(t) x2(t) = x2(t-1) x3(t) = x1(t-1) x4(t) = u1(t) Observation equation: y1(t) = x1(t) + (0.10)e1(t) Initial state distribution: Initial state means x1 x2 x3 x4 0 1 0 0 Initial state covariance matrix x1 x2 x3 x4 x1 1 0 0 0 x2 0 0 0 0 x3 0 0 1 0 x4 0 0 0 1 State types x1 x2 x3 x4 Stationary Constant Stationary Stationary

If you have a set of responses, you can pass them and `Mdl`

to `estimate`

to estimate the parameters.

- Explicitly Create State-Space Model Containing Known Parameter Values
- Explicitly Create State-Space Model Containing Unknown Parameters
- Implicitly Create Time-Invariant State-Space Model
- Implicitly Create Time-Varying State-Space Model
- Estimate Time-Invariant State-Space Model
- Create State-Space Model with Random State Coefficient