Create State-Space Model Containing ARMA State
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
where is Gaussian with mean 0 and known standard deviation 0.5.
The variables , , and are in the state-space model framework. Therefore, the terms , , and require "dummy states" to be included in the model.
Subsequently, the state equation is
Note that:
- c corresponds to a state () that is always 1.
- , and has the term .
- has the term . 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.
- , and has the term .
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
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:
- is a stationary, ARMA(2,1) process.
- is the constant 1 for all periods.
- is the lagged ARMA process, so it is stationary.
- 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: <a href="matlab: doc ssm">ssm</a> 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.