Kalman filter Recursions – Main Equations the Prediction and Updating
-
Upload
anjalishitole -
Category
Documents
-
view
213 -
download
0
Transcript of Kalman filter Recursions – Main Equations the Prediction and Updating
-
8/14/2019 Kalman filter Recursions Main Equations the Prediction and Updating
1/20
Kalman filter recursions main equations
The prediction and updating equations leading us to calculate the prediciton errors and the
resulting variance are as follows:
Given at1 the MMSE oft1 at time t 1, with
at1 t1 WS(0, Pt1),
the prediction equations are:
at/t1 = Tat1,
and
at/t1 t
0,
2
Pt/t1
where
Pt/t1 = TPt1T + RQR
Given that at/t1 is MMSE oft at time t 1, the MMSE of zt at time time t 1 clearly is,
zt/t1 = ytat/t1.
The associated prediction error is
zt zt/t1
= t = y
t
t at/t1
+ Nt
the expectation of which is zero. Hence,
var t = E(2
t ) = E
ytt at/t1
t at/t1
y
+ E(N2t )
[since cross product terms have zero expectations]
= 2ytPt|t1yt + 2h = 2ft
The updating equations are given by:
at = at|t1 + Pt|t1yt
zt ytat|t1
/ft,
and
Pt = Pt|t1 Pt|t1ytytPt|t1/ft where ft = y
tPt|t1yt + h.
1
-
8/14/2019 Kalman filter Recursions Main Equations the Prediction and Updating
2/20
We have to highlight here the role played by,
1. the prediction error given by
t = zt ytat|t1,
and the variance associated with it, 2ft and
2. the Kalman gain given by
Pt|t1yt.
If prior information is available, that is,
0 WS(a0, P0),
where a0 and P0 are known, the Kalman filter recursions can be used to get the prediction errors
and the variance associated with them.
2
-
8/14/2019 Kalman filter Recursions Main Equations the Prediction and Updating
3/20
Series A -- Chemical process concentration readings
15
15.5
16
16.5
17
17.5
18
18.5
1 26 51 76 101 126 151 176
Series D -- Chemical process viscocity readings
0
2
4
6
8
10
12
1 51 101 151 201 251 301
Series E -- Wolfer sun spot numbers
0
20
40
60
80
100
120
140
160
180
1 21 41 61 81
Series F -- Yields from a batch chemical process
0
10
20
30
40
50
60
70
80
90
1 11 21 31 41 51 61
-
8/14/2019 Kalman filter Recursions Main Equations the Prediction and Updating
4/20
Series A -- ACF
0
0.1
0.20.3
0.4
0.5
0.6
1 6 11 16
Series A -- PACF
-0.2
0
0.2
0.4
0.6
0.8
1 6 11 16
Series D -- ACF
0
0.20.4
0.6
0.8
1
1 6 11 16
Series D -- PACF
-0.2
0
0.2
0.4
0.6
0.8
1
1 6 11 16
Series E -- ACF
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
1 6 11 16
Series E -- PACF
-1
-0.5
0
0.5
1
1 6 11 16
Series F -- ACF
-0.6
-0.4
-0.2
0
0.2
0.4
1 6 11 16
Series F -- PACF
-0.6
-0.4
-0.2
0
0.2
0.4
1 6 11 16
-
8/14/2019 Kalman filter Recursions Main Equations the Prediction and Updating
5/20
Table1:S
ummaryofModelsFitted
Series
NOBS
FittedMode
ls
ResidualVariance
A
197
z
t
0.9
2
(0.0
4)z
t1
=
1.3
8
(0.7
0)
+
et
+0.5
8
(0.0
8)
et1
0.0
98
D
310
zt
0.8
7
(0.0
3)z
t1
=
1.2
2
(
0.2
5)
+
et
0.0
9
E
100
zt
1.5
6
(0.1
0)z
t1
+
1.0
1
(0.1
6)z
t2
0.2
1
(
0.1
0)z
t3
=
11.4
6
(2.8
7)
+
et
230.4
3
z
t
1.4
1
(0.0
7)z
t1
+
0.7
2
(0.0
7)zt2
=
14.5
3
(2.5
2)
+
et
230.4
3
F
70
zt
+
0.3
4
(0.1
3)z
t1
0.2
0
(0.1
3)zt2
=
58.7
6
(11.0
0)
+
et
117.5
6
Note:Valuesin()under
eachestimatedenotestandar
derrors.
Table2:SummaryofDiag
nosticTestsonResiduals
ofFittedModels
Series
NOBS
FittedModels
Q
DF
A
197
zt
0.9
2zt1
=
1.3
8
+
et
+0
.58et1
25.5
6
18
D
310
zt
0.8
7zt1
=
1.2
2
+
et
8.8
2
19
E
100
zt
1.5
6zt1
+
1.0
1zt2
0.2
1zt3
=
11.4
6+
et
18.0
1
17
100
zt
1.4
1zt1
+
0.7
2zt2
=
14.
53+
et
23.7
2
18
F
70
zt
+
0.3
4zt1
0.2
0zt2
=
58.
76+
et
11.8
8
18
1
-
8/14/2019 Kalman filter Recursions Main Equations the Prediction and Updating
6/20
Forecasts from stationary and DS models
100
120
140
160
180
1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58
Lead time
Forecasts
Forecast standard error
0
20
40
60
1 6 11 16 21 26 31 36 41 46 51 56
Lead time
Std.error
-
8/14/2019 Kalman filter Recursions Main Equations the Prediction and Updating
7/20
CPI -- 1955:1 2002:12
35
235
435
635
835
1035
1235
1 51 101 151 201 251 301 351 401 451 501 551
Logarithm of CPI
3.5
3.7
3.9
4.1
4.3
4.5
4.7
4.9
5.1
5.3
5.5
5.7
5.9
6.1
6.3
6.5
6.7
6.9
1 51 101 151 201 251 301 351 401 451 50
WPI -- 1970:1 2000:12
30
80
130
180
230
280
330
1 51 101 151 201 251 301 351
Logarithm of WPI
3.4
3.6
3.8
4
4.2
4.4
4.6
4.8
5
5.2
5.4
5.6
5.8
6
1 51 101 151 201 251 301
-
8/14/2019 Kalman filter Recursions Main Equations the Prediction and Updating
8/20
M1: 1955:1 2002:12
0
50000
100000
150000
200000
250000
300000
350000
400000
450000
1 51 101 151 201 251 301 351 401 451 501 551
Logarithm of M1
7.5
8.5
9.5
10.5
11.5
12.5
13.5
1 51 101 151 201 251 301 351 4
M3: 1955:1 2002:12
0
200000
400000
600000
800000
1000000
1200000
1400000
1600000
1800000
1 51 101 151 201 251 301 351 401 451 501 551
Logarithm of M3
7.5
8.5
9.5
10.5
11.5
12.5
13.5
14.5
1 51 101 151 201 251 301 351 4
-
8/14/2019 Kalman filter Recursions Main Equations the Prediction and Updating
9/20
Export: 1970:1 2000:12
1
30
59
88
117
146
175
1 51 101 151 201 251 301 351
Logarithm of Ex
-0.06
0.44
0.94
1.44
1.94
2.44
2.94
3.44
3.94
4.44
4.94
1 51 101 151 20
Imports: 1970:1 2000:12
1
41
81
121
161
201
1 51 101 151 201 251 301 351
Logarithm of im
-0.05
0.45
0.95
1.45
1.95
2.45
2.95
3.45
3.95
4.45
4.95
5.45
1 51 101 151 20
-
8/14/2019 Kalman filter Recursions Main Equations the Prediction and Updating
10/20
Food credit: 1970:4 2003:3
0
10000
20000
30000
40000
50000
60000
70000
1 51 101 151 201 251 301 351
Logarithm of food credit
4.5
5.5
6.5
7.5
8.5
9.5
10.5
11.5
1 51 101 151 201 251
Nonfood credit: 1970:3 2003:3
0
100000
200000
300000
400000
500000
600000
700000
800000
1 51 101 151 201 251 301 351
Logarithm of nonfood cred
8
9
10
11
12
13
14
1 51 101 151 201 251
-
8/14/2019 Kalman filter Recursions Main Equations the Prediction and Updating
11/20
Fig1: White Noise
-4
-2
0
2
4
1 18 35 52 69 86 103 120 137 154 171 188
Time
Z_
{t}
Fig 2: MA(1) model. Theta=-0.8
-4
-2
0
2
4
1 18 35 52 69 86 103 120 137 154 171 188
Time
z_
{t}
Fig3: MA(1) model; Theta=0.8
-4
-2
0
2
4
1 18 35 52 69 86 103 120 137 154 171 188
Time
z_
{t}
Fig 4: AR(1) model; Phi = 0.65
-4
-2
0
2
4
6
1 18 35 52 69 86 103 120 137 154 171 188
Time
z_
{t}
-
8/14/2019 Kalman filter Recursions Main Equations the Prediction and Updating
12/20
-
8/14/2019 Kalman filter Recursions Main Equations the Prediction and Updating
13/20
M1: 1955:1 2002:12
0
50000
100000
150000
200000
250000
300000
350000
400000
450000
1 51 101 151 201 251 301 351 401 451 501 551
Logarithm of M1
7.5
8.5
9.5
10.5
11.5
12.5
13.5
1 51 101 151 201 251 301 351 401 451 501 551
-
8/14/2019 Kalman filter Recursions Main Equations the Prediction and Updating
14/20
Empirical applications
We shall apply the unit root test procedures discussed above on some major Indian macro series.Since many Indian studies have confirmed the existence of unit roots in many Indian time series,we shall consider our attempts in this section as a confirmatory exercise, besides being a pedagogicdemonstration of unit root test procedures. Hence we shall employ these test procedures on narrow
money series (M1) only as a demonstration. This is monthly data, ranging from 1955:1 to 2002:12 a sample of 576 observations and this data was collected from the various issues of the RBI bulletin.A plot of the series is attached at the end.
Which of the three models that we have discussed, should one choose to employ? An inspectionof the plots reveals that since all the series are upward trending, Case 3 would be better model.But we have to check if this upward movement is better characterized as a drift or as stationaryfluctuations around a time trend. We shall be using the ADF test procedure as well as demonstratethe application of the PP test. But, as an extended exercise, we also shall estimate the other twocases as well and check for the null if these series can be labelled as pure random walk or randomwalk with drift. We select the correct number of lags using Halls general to specific methodology.
All results are discussed at the 5% level.
The following model was estimated for M1 data by OLS, with the number of lags decided byHalls methodology. (standard errors in parentheses)
m1t = 0.086722(0.030965)
+ 0.000126(0.000045)
t + 0.988506(0.004377)
m1t1 0.018542(0.042389)
m1t1 + 0.024024(0.039460)
m1t2
0.008666(0.039064)
m1t3 0.123152(0.039061)
m1t4 0.099201(0.039087)
m1t5 + 0.085646(0.039208)
m1t6
0.104373(0.039127)
m1t7 0.085999(0.039212)
m1t8 0.127945(0.039152)
m1t9 0.025808(0.039217)
m1t10
+ 0.126156(0.039181)m1t11 + 0.361437(0.039554)m1
t12 + 0.083216(0.042464)m1t13
RSS = 0.158604.
Since the available sample size in this case will be 562, the ADF normalized bias test can be calculatedas:
T( 1)
1 1
2
12
13
=562(0.988506 1)
1 + 0.18542 0.024024 0.361437 0.083216= 6.46.
Refering to Table B.5, Case 4 critical values tabulated in Hamilton, the calculated value of6.46 is
much greater than the asymptotic critical value of21.8. Hence, the unit root of null is accepted.The equivalent t statistic for the same null is calculated as,
(0.988506 1)/(0.004377) = 2.63.
Since the calculated t statistic is greater than the asymptotic critical value of3.41, (refer to TableB.6,Case 4) we again conclude that the null of unit root is accepted. Thus, the test conducted sofar accepts that M1 may be modelled as an ARIMA(13, 1, 0) process. Finally, since the distributionof has been derived maintaining that = 0, we need to conduct an F test to test the joint nullof = 1, = 0. But the calculated F test value of 8.07 is greater than the 5% asymptotic criticalvalue of 6.25 but is less than the 1% value of 8.25. Hence the null of unit root with a possible drift,is rejected at the 5% level, but accpeted at the 1% level.
-
8/14/2019 Kalman filter Recursions Main Equations the Prediction and Updating
15/20
Next we shall check if the first two cases fit any better. We shall assume the test regression asabove. The results of the regression exercises are given below:
m1t = 0.000276(0.005121)
+ 1.00093(0.000506)
m1t1, RSS = 0.234373
m1t = 1.00096(0.000083)
m1t1, RSS = 0.234374
Here the F statistic for the joint null = = 0, = 1 against the general alternative that isgiven by the test regression is calculated as
F = (0.234374 0.158604)/15(0.158604/562) = 17.9,
which is much greater than the 5% asymptotic critical value of 4.68 and this means, we can reject thenull of unit root without a drift. Next we compute the F statistic to test the joint null = 0, = 1a follows:
F = (0.234373 0.158604)/14(0.158604/562) = 19.18
which is again much greater than the 5% asymptotic critical value of 6 .25. So once again the null isrejected.
But ADF test is sensitive to the correct lag size. So these rejections have to be viewed in thatlight. Perhaps M1 has a significant time trend, a drift as well as a unit root. So is there a case for aquadratic time trend as against the null ofsecond unit root? Since the plot of the levels data clearlyshows a quadratic trend, I did a preliminary check calculating the autocorrelation values of residualsobtained from models with (1) a linear time trend only and (2) with a quadratic time trend added.But the lag 10 autocorrelation values remained as high as 0.893 and 0.689 for models (1) and (2)respectively even after these regressions. Hence, it looks like, our ADF test with the joint null, at
the 1% significance level, is likely a better model! We shall discuss more about this series later.
-
8/14/2019 Kalman filter Recursions Main Equations the Prediction and Updating
16/20
Unit roots versus breaking trends alternative
The null and the alternatives have been parameterized as follows:
Null Hypotheses:
Model (A) zt = + dDT Bt
+ zt1 + et
Model (B) zt = 1 + zt1 +
2 1
DUt + et
Model (C) zt = 1 + zt1 + dD
T Bt
+
2 1
DUt + et where
D
T Bt
= 1 if t = TB + 1, 0 otherwise;
DUt = 1 if t > TB, 0 otherwise
and et could be either an uncorrelated innovation sequence or a stationary process. Instead of
considering the alternative hypothesis that zt is a stationary series around a deterministic linear
trend with time invariant parameters, Perron considers the following alternative models:
Model (A) zt = 1 + t +
2 1
DUt + et
Model (B) zt = + 1t +
2 1
DTt
+ et
Model (C) zt = 1 + 1t + +
2 1
DUt +
2 1
DTt + et
where
DT
t = t TB, and DTt = t if t > TB and 0 otherwise.
Here TB refers to the time of break, that is, the period at which the change in the parameters of the
trend function occurs.
Extension to more general processes: ets correlated
Using the regression under Case 1 and the critical values sited above is valid only for uncorrelated
es. When there is correlation among the error terms, Perron suggests the following model which is
along the lines of ADF testing procedures and uses the literature on outlier specification. He nests
the null and the alternative models in the following fashion:
zt = A + ADUt +
At + dAD
T Bt
+ Azt1 +k
i=1
cizti + et,
zt = B + BDUt +
Bt + BDTt
+ Bzt1 +k
i=1
cizti + et,
zt = C + CDUt +
Ct + CDTt + dCD
T Bt
+ Czt1 +k
i=1
cizti + et.
1
-
8/14/2019 Kalman filter Recursions Main Equations the Prediction and Updating
17/20
Figure -- 1 Logarithm of Nominal wages
6
6.2
6.4
6.6
6.8
7
7.2
7.4
7.6
7.8
88.2
8.4
8.6
8.8
9
9.2
1 3 5 7 9 11 1 3 15 1 7 19 2 1 23 2 5 2 7 29 3 1 33 3 5 37 3 9 41 4 3 45 4 7 49 5 1 5 3 55 5 7 59 6 1 63 6 5 67 6 9 71
Figure --3 Logarithm of common stock prices
1
1.5
2
2.5
3
3.5
4
4.5
5
1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82 85 88 91 94 97 100
Figure 2 -- Logarithm of quarterly real GNP
6.9
7.1
7.3
7.5
7.7
7.9
8.1
8.3
1 7 13 19 25 31 37 43 49 55 61 67 73 79 85 91 97 103 109 115 121 127 133 139 145 151 157
-
8/14/2019 Kalman filter Recursions Main Equations the Prediction and Updating
18/20
Figure 4 -- CDF of alpha under the
"crash" model
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
-0.4 -0.2 0 0.2 0.4 0.6 0.8 1
Figure 5 -- CDF of alpha under the
"breaking trend" model
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
-0.4 -0.2 0 0.2 0.4 0.6 0.8 1 1.2
-
8/14/2019 Kalman filter Recursions Main Equations the Prediction and Updating
19/20
Table 1
Results of ADF unit root test procedure
Regression: zt = + t + zt1 +k
i=1
izt1 + et
Series k t t t RSS S(e
M11955:1-2002:12 13 0.087 2.80 0.1103 2.84 0.989 -2.63 0.159 0.3101955:1-1980:12 13 0.229 2.95 0.3103 2.84 0.969 -2.92 0.09 0.3101981:1-2002:12 14 0.363 1.72 0.4103 1.60 0.965 -1.66 0.045 0.210
M3 7 0.2120 3.25 0.11103 3.21 0.974 -2.81 0.961 0.1710
CPI1955:1-2002:12 12 0.046 3.46 0.8104 3.32 0.987 -3.22 0.041 0.74101955:1-1974:12 12 0.089 2.11 0.1103 2.26 0.975 -2.09 0.02 0.9101975:1-2002:12 12 0.123 2.48 0.1103 2.36 0.975 -2.41 0.00 0.510
WPI1970:1-2000:12 12 0.151 5.09 0.3103 4.95 0.957 -5.01 0.09 0.8101970:1-1974:8 8 -0.135 -1.1 0.7103 2.20 1.03 1.06 0.004 0.1110
1974:9-2000:12 12 0.153 3.76 0.25103 3.64 0.962 -3.68 0.02 0.6810
Exports1970:1-2000:12 13 0.036 2.70 0.6103 1.57 0.957 -1.52 3.54 0.0111970:1-1985:2 12 0.084 2.69 0.12102 1.31 0.896 -1.40 0.09 0.016
1985:3-2000:12 12 0.147 1.41 0.305103 0.38 0.969 -0.65 0.009 0.5510
Imports 12 0.069 3.96 0.1102 2.39 0.893 -2.43 0.0149 0.014
Food credit1970:4-2003:3 12 0.227 3.92 0.4103 3.54 0.962 -3.89 0.09 0.0101970:4-1987:7 13 0.300 2.50 0.75103 1.90 0.950 -2.35 0.003 0.0121987:8-2003:3 13 0.871 4.79 0.21102 4.18 0.89 -4.66 0.09 0.8510
Non-food credit 12 0.319 3.10 0.5103 3.00 0.962 -3.00 0.001 0.210
Note: k for all models was fixed using Halls general-to-specific method. All data are in logs. S(e)refers to the residual variance.
Table 2
Sample autocorrelations of the detrended series
Series T Variance r1 r2 r3 r4 r5 r6 r7 r8M1 576 0.031 0.99 0.97 0.96 0.95 0.93 0.92 0.91 0.91 CPI 576 0.009 0.99 0.97 0.95 0.93 0.91 0.89 0.87 0.86 WPI 372 0.004 0.98 0.95 0.91 0.86 0.82 0.78 0.74 0.70
Exports 372 0.042 0.74 0.72 0.69 0.70 0.68 0.70 0.70 0.68 Food credit 396 0.164 0.93 0.83 0.76 0.71 0.68 0.64 0.59 0.54
Note: All series were detrended using Model A under the alternative hypothesis.
1
-
8/14/2019 Kalman filter Recursions Main Equations the Prediction and Updating
20/20
Table3
ResultsofPe
rronunitroottestproced
ure
Regression,ModelA:zt=+DU
t+t+dD(TB)t+zt1
+
k i=1
izt1+et
Series
T
TB
t
t
t
d
td
t
S(e)
M1
576
312
0.54
0.093
3.05
-0.006
-1.88
0.0001
3.59
-0.003
-0.54
0.988
-2.77
0.0003
CPI
576
240
0.42
0.045
3.51
-0.001
-0.83
0.0001
3.47
0.004
0.79
0.986
-3.39
0.0001
WPI
372
57
0.15
0.131
4.73
-0.006
-2.81
0.0002
4.72
0.001
0.19
0.962
-4.67
0.0001
Exports
372
183
0.49
0.020
1.05
-0.021
-0.76
0.001
1.81
-0.015
-0.35
0.935
-1.78
0.012
oodcredit
396
209
0.53
0.44
5.51
-0.12
-3.82
0.001
4.97
-0.05
-0.43
0.920
-5.45
0.0104
Note:=T
B/T
andkfor
allthemodelswasfixedat12asbefore.Alldataareinlog
s.S(e)isvarianceoftheresid
uals.
Table4
ResultsofZivot-Andrewsunitroottestprocedure
Mo
delA
Mod
elB
Mode
lC
Series
t-statistics
Breakyear
tstatistics
Breakyear
tstatistics
Breakyear
M1
-3.75
1989:2
(410)
-3.35
1980:5
(305)
-3.57
1980:4
(304)
CPI
-4.64
1958:10
(58)
-5.02
1970:11
(191)
-5.12
1968:1
(157)
WPI
-5.68
1972:5
(29)
-5.67
1973:5
(41)
-5.94
1977:2
(86)
Exports
-2.81
1979:5
(113)
-2.20
1985:6
(186)
-3.12
1977:4
(88)
Imports
-3.83
1984:2
(170)
-3.12
1974:2
(50)
-3.89
1972:11
(35)
Foodcredit
-5.72
1987:3
(204)
-4.38
1975:10
(67)
-5.71
1987:3
(204)
on-foodcredit
-5.25
1978:9
(102)
-5.14
1983:8
(161)
-5.52
1980:6
(123)