## Documentation Center |

` X = filter(Mdl,Y)` performs
forward recursion of the fully specified, linear state-space model

` X = filter(Mdl,Y,Name,Value)` performs
forward recursion of the state-space model

`[ X,logL,Output]
= filter(___)` additionally returns the loglikelihood
value (

Filtered and forecasted states

Estimated covariance matrices of the filtered and forecasted states

Loglikelihood value

Forecasted observations and its estimated covariance matrix

Adjusted Kalman gain

Vector indicating which data the software used to filter

Consider obtaining the 1-step-ahead states forecast for
period *t* + 1 using all information up to period *t*.
The *adjusted Kalman gain* (
) is the amount of weight put
on the estimated observation innovation for period *t* (
) as compared to the two-step-ahead
state forecast (
).

That is,

States
forecasts at period *t*, updated using all
information (for example the observed responses) up to period *t*.

The *m _{t}*-by-1 vector
of filtered states at period

where:

is the vector of state forecasts at period

*t*using the observed responses from periods 1 through*t*– 1.*K*is the_{t}*m*-by-_{t}*h*raw Kalman gain matrix for period_{t}*t*.is the

*h*-by-1 vector of estimated observation innovations at period_{t}*t*.

In other words, the filtered states at period *t* are
the forecasted states at period *t* plus an adjustment
based on the trustworthiness of the observation. Trustworthy observations
have very little corresponding observation innovation variance (for
example, the maximum eigenvalue of *D _{t}D_{t}′* is
relatively small). Consequently, for a given estimated observation
innovation, the term
has a higher impact
on the values of the filtered states than untrustworthy observations.

At period *t*, the filtered states have variance-covariance
matrix

where
is
the estimated variance-covariance matrix of the state forecasts at period *t*,
given all information up to period *t* – 1.

*s*-step-ahead, forecasted
observations are estimates of the observations at period *t* using
all information (for example, the observed responses) up to period *t* – *s*.

The *n _{t}*-by-1 vector
of 1-step-ahead, forecasted observations at period

where
is the *m _{t}*-by-1
estimated vector of state
forecasts at period

At period *t*, the 1-step-ahead, forecasted
observations have variance-covariance matrix

where
is the estimated variance-covariance
matrix of the state
forecasts at period *t*, given all information
up to period *t* – 1.

In general, the *s*-step-ahead, vector of state
forecasts is
. The *s*-step-ahead,
forecasted observation vector is

In the state-space model framework, the Kalman filter estimates the values of a latent, linear, stochastic, dynamic process based on possibly mismeasured observations. Given distribution assumptions on the uncertainty, the Kalman filter also estimates model parameters via maximum likelihood.

Starting with initial values for states (*x*_{0|0}),
the initial state variance-covariance matrix (*P*_{0|0}),
and initial values for all unknown parameters (*θ*_{0}),
the simple Kalman filter:

Estimates, for

*t*= 1,...,*T*:The 1-step-ahead vector of state forecasts vector for period

*t*( ) and its variance-covariance matrix ( )The 1-step-ahead vector of observation forecasts for period

*t*( ) and its estimated variance-covariance matrix ( )The filtered states for period

*t*( ) and its estimated variance-covariance matrix ( )

Feeds the forecasted and filtered estimates into the data likelihood function

where is the multivariate normal probability density function with mean and variance .

Feeds this procedure into an optimizer to maximize the likelihood with respect to the model parameters.

The *raw Kalman gain* is
a matrix that indicates how much to weigh the observations during
recursions of the Kalman filter.

The raw Kalman gain is an *m _{t }*-by-

where
is
the estimated variance-covariance matrix of the state forecasts, given
all information up to period *t* – 1.

The value of the raw Kalman gain determines how much weight
to put on the observations. For a given estimated observation innovation,
if the maximum eigenvalue of *D _{t}D_{t}′* is
relatively small, then the raw Kalman gain imparts a relatively large
weight on the observations. If the maximum eigenvalue of

*s*-step-ahead, state forecasts
are estimates of the states at period *t* using all
information (for example, the observed responses) up to period *t* – *s*.

The *m _{t}*-by-1 vector
of 1-step-ahead, state forecasts at period

where
is
the *m*_{t – 1}-by-1 filtered state vector
at period *t* – 1.

At period *t*, the 1-step-ahead, state forecasts
have the variance-covariance matrix

where
is the estimated variance-covariance
matrix of the filtered
states at period *t* – 1, given all
information up to period *t* – 1.

The corresponding 1-step-ahead forecasted observation is , and its variance-covariance matrix is

In general, the *s*-step-ahead, forecasted
state vector is
. The *s*-step-ahead,
vector of state forecasts is

and the *s*-step-ahead,
forecasted observation vector is

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*), and another describing how an observer measures
the latent process at each period (the *observation equation*).

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

for *t* = 1,...,*T*.

, which is an

*m*-dimensional state vector describing the dynamics of some, possibly unobservable, phenomenon at period_{t}*t*., which is an

*n*-dimensional observation vector describing how the states are measured by observers at period_{t}*t*.*A*is the_{t}*m*-by-_{t}*m*_{t – 1}state-transition matrix describing how the states at time*t*transition to the states at period*t*– 1.*B*is the_{t}*m*-by-_{t}*k*state-disturbance-loading matrix describing how the states at period_{t}*t*combine with the innovations at period*t*.*C*is the_{t}*n*-by-_{t}*m*measurement-sensitivity matrix describing how the observations at period_{t}*t*relate to the states at period*t*.*D*is the_{t}*n*-by-_{t}*h*observation-innovation matrix describing how the observations at period_{t}*t*combine with the observation errors at period*t*.The matrices

*A*,_{t}*B*,_{t}*C*, and_{t}*D*are referred to as_{t}*coefficient matrices*, and might contain unknown parameters., which is a

*k*-dimensional, Gaussian, white-noise, unit-variance vector of state disturbances at period_{t}*t*., which is an

*h*-dimensional, Gaussian, white-noise, unit-variance vector of observation innovations at period_{t}*t*.*ε*and_{t}*u*are uncorrelated._{t}

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

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

represents a time-invariant 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

for *t* = 11

and for *t* = 1,..,*T*

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

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

Was this topic helpful?