## Identifying State-Space Models with Separate Process and Measurement Noise Descriptions

### General Model Structure

An identified linear model is used to simulate and predict system outputs for given
input and noise signals. The input signals are measured while the noise signals are only
known via their statistical mean and variance. The *general form* of
the state-space model, often associated with Kalman filtering, is an example of such a
model, and is defined as:

$$\begin{array}{c}x(t+1)=A(\theta )x(t)+B(\theta )u(t)+w(t)\\ \text{\hspace{1em}}\text{\hspace{0.17em}}y(t)=C(\theta )x(t)+D(\theta )u(t)+v(t),\end{array}$$ | (1) |

where, at time *t*:

*x*(*t*) is the vector of model states.*u*(*t*) is the measured input data.*y*(*t*) is the measured output data.*w*(*t*) is the process noise.*v*(*t*) is the measurement noise.

The noise disturbances are independent random variables with zero mean and covariances:

$$\begin{array}{c}E\left[w(t){w}^{\u22ba}(t)\right]={R}_{1}(\theta )\\ \text{\hspace{0.05em}}\text{\hspace{0.05em}}\text{\hspace{0.17em}}\text{\hspace{0.05em}}E\left[v(t){v}^{\u22ba}(t)\right]={R}_{2}(\theta )\\ E\left[w(t){v}^{\u22ba}(t)\right]={R}_{12}(\theta )\end{array}$$

The vector *θ* parameterizes the model, including the coefficients of
the system matrices and the noise covariances. However, all elements of the model are not
necessarily free. If you have physical insight into the states of the system and sources of
noise, the model can have a specific structure with few parameters in the vector
*θ*.

### Innovations Form and One-Step Ahead Predictor

For a given value of *θ*, you want to predict the best estimates of
*x*(*t*) and *y*(*t*)
in the presence of any disturbances. The required *predictor model*
equations are derived from the Kalman filtering technique:

$$\begin{array}{c}\widehat{x}(t+1,\theta )=A(\theta )x(t)+B(\theta )u(t)+K(\theta )\left[y(t)-C(\theta )\widehat{x}(t,\theta )-D(\theta )u(t)\right]\\ \text{\hspace{1em}}\text{\hspace{0.17em}}\widehat{y}(t,\theta )=C(\theta )\widehat{x}(t)+D(\theta )u(t),\end{array}$$ | (2) |

where $$\widehat{x}(t,\theta )$$ is the predicted value of the state vector
*x*(*t*) at time instant *t*, and $$\widehat{y}(t,\theta )$$ is the predicted value of output
*y*(*t*). The variables
*u*(*t*) and *y*(*t*)
in the above equation represent the measured input and output values at time
*t*. The *Kalman Gain* matrix,
*K*(*θ*), is derived from the system matrices and noise
covariances as follows:

$$K(\theta )=\left[A(\theta )\Gamma (\theta ){C}^{\u22ba}(\theta )+{R}_{12}(\theta )\right]{\left[C(\theta )\Gamma (\theta ){C}^{\u22ba}(\theta )+{R}_{2}(\theta )\right]}^{-1},$$

where $$\Gamma (\theta )$$ is the covariance of the state estimate error:

$$\Gamma (\theta )=\overline{E}\left[\left[x(t)-\widehat{x}(t,\theta )\right]{\left[x(t)-\widehat{x}(t,\theta )\right]}^{\u22ba}\right].$$

$$\Gamma (\theta )$$ is the solution of an algebraic Riccati equation. For more information,
see `dare`

(Control System Toolbox) and [1]

Denoting the output prediction error as $$e(t)=y(t)-\widehat{y}(t,\theta )$$, you can write the general state-space model in a simpler form:

$$\begin{array}{c}x(t+1,\theta )=A(\theta )x(t)+B(\theta )u(t)+K(\theta )e(t)\\ \text{\hspace{1em}}\text{\hspace{0.17em}}y(t)=C(\theta )x(t)+D(\theta )u(t)+e(t).\end{array}$$ | (3) |

This simpler representation is the *innovations form* of the
state-space model, and has only one unique disturbance source,
*e*(*t*). This form corresponds to choosing
*R _{2}*=

*I*,

*R*=

_{12}*K*, and

*R*=

_{1}*KK*for the general model structure. System Identification Toolbox™ software uses the innovations form as its primary representation of state-space models.

^{T}Both the general and innovations form of the model lead to the same predictor model as
shown in Equation 2. Use the `predict`

command to compute the predicted model response and to generate this
predictor system.

### Model Identification

The identification task is to use input and output measurement data to determine the
parameterization vector, *θ*. The approach to take depends on the amount of
prior information available regarding the system and the noise disturbances.

#### Black Box Identification

When only input-output data measurements are available, and you have no knowledge of
the noise structure, you can only estimate the model in the innovations form. To do so, we
use the one-step ahead prediction error minimization approach (PEM) to compute the best
output predictor. For this approach, the matrix *K* is parameterized
independently of the other system matrices, and no prior information about the system
states or output covariances is considered for estimation. The estimated model can be cast
back into the general model structure in many nonunique ways, one of which is to assume
*R _{2}*=

*I*,

*R*=

_{12}*K*, and

*R*=

_{1}*KK*. The innovations form is a system representation of the predictor in which

^{T}*e*(

*t*) does not necessarily represent the actual measurement noise.

Estimate state-space models in the innovations form using the `n4sid`

, `ssest`

, and `ssregest`

commands. The system matrices *A*,
*B*, *C*, *D*, and
*K* are parameterized independently and the identification minimizes
the weighted norm of the prediction error, *e*(*t*). For
more information, see Estimating State-Space Models Using ssest, ssregest and n4sid and the
estimation examples in `ssest`

.

**Note**

In this case, the estimation algorithm chooses the model states arbitrarily. As a result, it is difficult to imagine physically meaningful descriptions of the states and the sources for the disturbances affecting them.

#### Structured Identification

In some situations, in addition to the input-output data, you know something about the
state and measurement disturbances. To make the notion of state disturbances meaningful,
it is necessary that the states be well-defined, such as the positions and velocities in a
mechanical lumped-mass system. Well-defined states and known noise sources result in a
*structured* state-space model, which you can then parameterize using
the general model structure of Equation 1.

To identify such models, use a grey-box modeling approach, which lets you use any
prior knowledge regarding the system parameters and noise covariances. For example, you
may know that only the first element of *R _{1}* is
nonzero, or that all the off-diagonal terms of

*R*are zero. When using grey-box modeling, provide initial guess values for the parameterization vector,

_{2}*θ*. If the model states are physically meaningful, it should be possible to determine initial estimates for the parameters in

*θ*.

To estimate a grey-box model with parameterized disturbances:

Create a MATLAB

^{®}function, called the ODE file, that:Computes the parameterized state-space matrices,

*A*,*B*,*C*, and*D*, using the parameter vector*θ*, which is supplied as an input argument.Computes the noise covariance matrices

*R*,_{1}*R*, and_{2}*R*. Each of these matrices can be completely or partially unknown. Any unknown matrix elements are defined in terms of parameters in_{12}*θ*.Uses the system matrices

*A*and*C*, and the noise covariances with the`kalman`

(Control System Toolbox) command to find the Kalman gain matrix,*K*.[~,K] = kalman(ss(A,eye(nx),C,zeros(ny,nx),Ts),R1,R2,R12);

Here,

`nx`

is the number of model states,`ny`

is the number of model outputs, and`Ts`

is the sample time. The`kalman`

command requires Control System Toolbox™ software.Returns

*A*,*B*,*C*,*D*, and*K*as output arguments.

Create an

`idgrey`

model that uses the ODE function and an initial guess value for the parameter vector,*θ*.Configure any estimation options using the

`greyestOptions`

command.Estimate

*θ*using`greyest`

command.

For an example of using parameterized disturbances with grey-box modeling, see Estimate Discrete-Time Grey-Box Model with Parameterized Disturbance.

### Summary

Use the innovations form if all you have is measured input-output data. It is worthwhile to use the general form only if you can define a system parameterization with meaningful states, and you have nontrivial knowledge about the noise covariances. In this case, use grey-box estimation to identify the state-space model.

Both the general form and the innovations form lead to the same predictor. So, if your end goal is to deploy the model for predicting future outputs or to perform simulations, it is more convenient to use the innovations form of the model.

## References

[1] Ljung, L. “State-Space Models.” Section 4.3 in
*System Identification: Theory for the User*. 2nd ed. Upper Saddle
River, NJ: Prentice Hall, 1999, pp. 93–102.

## See Also

`idgrey`

| `greyest`

| `predict`

| `ssest`

| `ssregest`

| `n4sid`