' impulse response functions
' replicates Lutkepohl (1991) pp.105-113
' 1/7/2000 h
' last checked 10/27/2000 h

'change path to program path
%path = @runpath
cd "{%path}"

' load workfile
load lut1

' estimate VAR
smpl 1960:1 1978:4
var1.ls 1 2 y1 y2 y3 @ c

'--------------------------------------------------------------
' unit impulse
'--------------------------------------------------------------
' Fig 3.4 (p.107)
freeze(fig34) var1.impulse(m,imp=unit,matbys=tab33_1) y3 @ y2

' Fig 3.5 (p.107)
freeze(fig35) var1.impulse(m,imp=unit) y1 @ y3

' combine two graphs into one
freeze(fig_p107) fig34 fig35
show fig_p107

'--------------------------------------------------------------
' accumulated response to unit impulse
'--------------------------------------------------------------
' Fig 3.6 (p.109)
freeze(fig36) var1.impulse(m,a,imp=unit,matbys=tab33_2) y3 @ y2

' get long-run response (bottom right matrix in Table 3.3, p.106)
matrix lrrsp33 = var1.@lrrsp

' add long-run response to impulse response graph
!dtmp = lrrsp33(3,2)
fig36.draw(dashline,left) !dtmp

' Fig 3.7 (p.109)
freeze(fig37) var1.impulse(m,a,imp=unit) y1 @ y3
' add long-run response to impulse response graph
!dtmp = lrrsp33(1,3)
fig37.draw(dashline,left) !dtmp

' combine two graphs into one
freeze(fig_p109) fig36 fig37
show fig_p109

'--------------------------------------------------------------
' cholesky impulse
'--------------------------------------------------------------
' Fig 3.8 (p.112)
freeze(fig38) var1.impulse(m,imp=chol,matbys=tab34_1) y3 @ y2

' Fig 3.9 (p.112)
freeze(fig39) var1.impulse(m,a,imp=chol,matbys=tab34_2) y3 @ y2

' get long-run response (bottom right matrix in Table 3.4, p.111)
matrix lrrsp34 = var1.@lrrsp

' add long-run response to impulse response graph
!dtmp = lrrsp34(3,2)
fig39.draw(dashline,left) !dtmp

' combine two graphs into one
freeze(fig_p112) fig38 fig39
show fig_p112

