What Is the Kalman Filter?
Standard Kalman Filter
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 (x0|0), the initial state variance-covariance matrix (P0|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.
State Forecasts
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 mt-by-1 vector of 1-step-ahead, state forecasts at period t is . The estimated vector of state forecasts is
where is the mt – 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
Filtered States
State forecasts at period t, updated using all information (for example the observed responses) up to period t.
The mt-by-1 vector of filtered states at period t is . The estimated vector of filtered states is
where:
is the vector of state forecasts at period t using the observed responses from periods 1 through t – 1.
Kt is the mt-by-ht raw Kalman gain matrix for period t.
is the ht-by-1 vector of estimated observation innovations at period 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 DtDt′ 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.
Smoothed States
Smoothed states are estimated states at period t, which are updated using all available information (for example, all of the observed responses).
The mt-by-1 vector of smoothed states at period t is . The estimated vector of smoothed states is
where:
are the state forecasts at period t using the observed responses from periods 1 to t – 1.
is the estimated variance-covariance matrix of the state forecasts, given all information up to period t – 1.
where,
Kt is the mt-by-ht raw Kalman gain matrix for period t.
, which is the estimated variance-covariance matrix of the forecasted observations.
, which is the difference between the observation and its forecast at period t.
Smoothed State Disturbances
Smoothed state disturbances are estimated, state disturbances at period t, which are updated using all available information (for example, all of the observed responses).
The kt-by-1 vector of smoothed, state disturbances at period t is . The estimated vector of smoothed, state disturbances is
where rt is the variable in the formula to estimate the smoothed states.
At period t, the smoothed state disturbances have variance-covariance matrix
where Nt is the variable in the formula to estimate the variance-covariance matrix of the smoothed states.
The software computes smoothed estimates using backward recursion of the Kalman filter.
Forecasted Observations
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 nt-by-1 vector of 1-step-ahead, forecasted observations at period t is . The estimated vector of forecasted observations is
where is the mt-by-1 estimated vector of state forecasts at period t.
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
Smoothed Observation Innovations
Smoothed observation innovations are estimated, observation innovations at period t, which are updated using all available information (for example, all of the observed responses).
The ht-by-1 vector of smoothed, observation innovations at period t is . The estimated vector of smoothed, observation innovations is
where:
rt and νt are the variables in the formula to estimate the smoothed states.
Kt is the mt-by-ht raw Kalman gain matrix for period t.
, which is the estimated variance-covariance matrix of the forecasted observations.
At period t, the smoothed observation innovations have variance-covariance matrix
The software computes smoothed estimates using backward recursion of the Kalman filter.
Kalman Gain
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 mt -by-ht matrix computed using
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 DtDt′ is relatively small, then the raw Kalman gain imparts a relatively large weight on the observations. If the maximum eigenvalue of DtDt′ is relatively large, then the raw Kalman gain imparts a relatively small weight on the observations. Consequently, the filtered states at period t are close to the corresponding state forecasts.
Consider obtaining the 1-step-ahead state forecasts 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 2-step-ahead state forecast ().
That is,
Backward Recursion of the Kalman Filter
Backward recursion of the Kalman filter estimates smoothed states, state disturbances, and observation innovations.
The software estimates the smoothed values by:
Setting rT + 1 = 0, and NT + 1 to an mT-by-mT matrix of 0s
For t = T,...,1, it recursively computes:
rt (see Smoothed States)
, which is the matrix of smoothed states
Nt (see Smoothed States)
, which is the estimated variance-covariance matrix of the smoothed states
, which is the matrix of smoothed state disturbances
, which is the estimated variance-covariance matrix of the smoothed state disturbances
, which is the matrix of smoothed observation innovations
, which is the estimated variance-covariance matrix of the smoothed observation innovations
Diffuse Kalman Filter
Consider a state-space model written so that the m diffuse states (xd) are segregated from the n stationary states (xs). That is, the moments of the initial distributions are
μd0 is an m-vector of zeros
μs0 is an n-vector of real numbers
Σd0 = κIm, where Im is the m-by-m identity matrix and κ is a positive real number.
Σs0 is an n-by-n positive definite matrix.
The diffuse states are uncorrelated with each other and the stationary states.
One way to analyze such a model is to set κ to a relatively
large, positive real number, and then implement the standard Kalman filter (see ssm
). This treatment is an approximation to an analysis that treats the
diffuse states as if their initial state covariance approaches infinity.
The diffuse Kalman filter or exact-initial Kalman filter [68] treats the diffuse states by taking κ to ∞. The diffuse Kalman filter filters in two stages: the first stage initializes the model so that it can subsequently be filtered using the standard Kalman filter, which is the second stage. The initialization stage mirrors the standard Kalman filter. It sets all initial filtered states to zero, and then augments that vector of initial filtered states with the identity matrix, which composes an (m + n)-by-(m + n + 1) matrix. After a sufficient number of periods, the precision matrices become nonsingular. That is, the diffuse Kalman filter uses enough periods at the beginning of the series to initialize the model. You can consider this period as presample data.
The second stage commences when the precision matrices are nonsingular.
Specifically, the initialization stage returns a vector of filtered states and their
precision matrix. Then, the standard Kalman filter uses those estimates and the
remaining data to filter, smooth, and estimate parameters. For more details, see
dssm
and [68], Sec. 5.2.
References
[1] Durbin J., and S. J. Koopman. Time Series Analysis by State Space Methods. 2nd ed. Oxford: Oxford University Press, 2012.
See Also
Objects
Functions
estimate
|estimate
|filter
|filter
|update
|smooth
|smooth
|forecast
|forecast
|irf
|irfplot