Using gret l for Principles of Econometrics, 4th Edition
Impulse Response Functions and Variance Decompositions
Impulse response functions show the effects of shocks on the adjustment path of the variables. Forecast error variance decompositions measure the contribution of each type of shock to the forecast error variance. Both computations are useful in assessing how shocks to economic variables reverberate through a system.
Impulse response functions (IRFs) and forecast error variance decompositions (FEVD) can be produced after using the var or vecm commands. The results can be presented in a table or a graph.
Obtaining the impulse responses after estimating a VAR is easy in gretl. The first step is to estimate the VAR. From the main gretl window choose Model>Time series>Vector Autoregression. This brings up the dialog, shown in Figure 13.13. Set the lag order to 1, and add the differenced variables to the box labeled Endogenous Variables. Make sure the ‘Include a constant’ box is
VAR system, lag order 1
OLS estimates, observations 1960:3-2009:4 (T = 198)
Equation 1: d_c
Heteroskedasticity-robust standard errors, variant HC3
Coefficient |
Std. Error |
t-ratio |
p-value |
|
const |
0.00527761 |
0.000952508 |
5.5408 |
0.0000 |
d_c_1 |
0.215607 |
0.0903028 |
2.3876 |
0.0179 |
d-y-1 |
0.149380 |
0.0595427 |
2.5088 |
0.0129 |
Mean dependent var |
0.008308 |
S. D. dependent var |
0.006976 |
Sum squared resid |
0.008431 |
S. E. of regression |
0.006575 |
R2 |
0.120487 |
Adjusted R2 |
0.111466 |
F (2,195) |
10.39596 |
P-value(F) |
0.000051 |
p |
-0.052639 |
Durbin-Watson |
2.085697 |
Equation 2: d_y
Heteroskedasticity-robust standard errors, variant HC3
Coefficient |
Std. Error |
t-ratio |
p-value |
|
const |
0.00603667 |
0.00110476 |
5.4642 |
0.0000 |
d_c_1 |
0.475428 |
0.105260 |
4.5167 |
0.0000 |
d-y-1 |
-0.217168 |
0.0977454 |
-2.2218 |
0.0274 |
Mean dependent var |
0.008219 |
S. D. dependent var |
0.009038 |
Sum squared resid |
0.014293 |
S. E. of regression |
0.008562 |
R2 |
0.111815 |
Adjusted R2 |
0.102706 |
F(2, 195) |
10.22543 |
P-value(F) |
0.000060 |
p |
-0.003022 |
Durbin-Watson |
1.993480 |
checked and click OK. The results are shown in Table 13.1.
You can generate impulse responses by selecting Analysis>Impulse responses from the results window. An impulse response dialog appears that allows you to specify the forecast horizon and to change the ordering of the variables. Using 12 periods with d_c ordered first produces the results shown in Figure 13.2.
These can be graphed for easier interpretation from the results window by selecting Graphs>Impulse responses (combined) from the pull-down menu. This brings up a dialog that allows you to choose how the graph will be constructed. The dialog is shown in Figure 13.14.
This yields the graph shown in Figure 13.15. The forecast error variance decompositions (FEVD) are obtained similarly. Select Analysis>Forecast variance decomposition from the
Figure 13.13: From the main gretl window, choose Model>Time series>Vector Autogregression to bring up the VAR dialog box. |
vector autoregression model window to obtain the result shown in Table 13.3.
To generate the IRFs and the FEVDs using a script, simply employ the options —impulse-responses and —variance-decomp. These can be used with the var command as done here or the vecm command.
var 1 diff(c) diff(y) —impulse-responses —variance-decomp
1 open "@gretldirdatapoegdp. gdt"
2 set echo off
3 setobs 4 1970:1 —time-series
4 # plot multiple time-series
5 scatters usa diff(usa) aus diff(aus)
6
6 # ADF tests with test down
7 scalar mlag = int(12*(($nobs+1)/100)"(0.25))
8 adf mlag usa —ctt —test-down
9 adf mlag aus —ctt —test-down
11
10 adf mlag diff(usa) —ct —test-down
11 adf mlag diff(aus) —ct —test-down
14
12 # manually testing down based on LM tests
13 # USA
14 genr time
15 square time
16 diff usa aus
17 loop i=1..12
18 ols d_usa(0 to - i) usa(-1) const time sq_time —quiet
19 printf "ADF lag order = %dn",i
20 modtest 1 —autocorr —quiet
0.001 |
-0.001 |
4 6 8 periods |
10 12 |
4 6 8 periods |
10 12 |
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
-0.0005 |
4 6 8 pe riods |
10 12 |
4 6 8 periods |
10 12 |
Figure 13.15: U. S. ln(RDPI) and ln(RPCE) impulse responses
end loop
# Australia loop i=0..12
if i = 0
ols d_aus aus(-1) const time sq_time —quiet
else
ols d_aus(0 to - i) aus(-1) const time sq_time —quiet endif
printf "ADF lag order = /dn",i modtest 1 —autocorr —quiet end loop
# Section 13.2 in POE4 ols aus usa
series uhat = $uhat ols diff(uhat) uhat(-1) ols diff(aus) const uhat(-1) ols diff(usa) const uhat(-1) modtest 1 —autocorr
# Engle-Granger test
coint 8 aus usa —test-down —nc
# restricted VECM vecm 3 1 aus usa restrict —full
b[1]+b[2]=0 end restrict
# collecting error correction terms from restricted model matrix a = $vecGamma
matrix b =$jbeta
series ec = aus + $jbeta[2,1]*usa modtest 1 —autocorr
# VAR estimation
open "@gretldirdatapoefred. gdt" scatters c diff(c) y diff(y)
adf 12 c —ct —test-down —verbose adf 12 y —ct —test-down —verbose
adf 12 diff(c) —ct —test-down —verbose adf 12 diff(y) —ct —test-down —verbose
var 12 diff(c) diff(y) —lagselect var 1 diff(c) diff(y) —robust-hac modtest 1 —autocorr
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
var 1 diff(c) diff(y) —impulse-responses —variance-decomp