public class KalmanFilterEx1 extends Object
Computes the filtered estimates and the one-step-ahead estimates using the Kalman filter.
In this example, KalmanFilter
is used to compute the filtered
estimates and one-step-ahead
estimates for a scalar problem discussed by Harvey (1981, pages 116-117). The
observation equation and state equation are given by
$$y_k = b_k + e_k$$
$$b_{k+1} = b_k + w_{k+1}$$
for \(k = 1,2,3,4\). The \(e_k\)s are identically and independently distributed normal with
mean 0 and variance \(\sigma ^2\), the \(w_k\)s are identically and
independently distributed normal with mean 0 and variance \(4 \sigma ^2\),
and \(b_1\) is distributed normal with mean 4 and variance \(16 \sigma ^2\).
Two KalmanFilter
objects are needed for each time point in order to compute
the filtered estimate and the one-step-ahead estimate. The first object does
not use the methods SetTransitionMatrix
and setQ
so
that the prediction equations are skipped in the computations. The update
equations are skipped in the computations in the second object.
This example also computes the one-step-ahead prediction errors. Note that
Harvey (1981, page 117) contains a misprint for the value \(v_4\) that he
gives as \(1.197\). The correct value of \(v_4 = 1.003\) is computed by
KalmanFilter
.
Constructor and Description |
---|
KalmanFilterEx1() |
public static void main(String[] args)
Copyright © 2020 Rogue Wave Software. All rights reserved.