Code: Select all
*
* Lutkepohl, New Introduction to Multiple Time Series Analysis
* Example 9.4 from pp 377-383
*
open data kpswdata.rat
calendar(q) 1947
data(format=rats) 1947:1 1988:4 c in y mp dp r
*
* Data are already in logs. We need to scale by 100.
*
set c = c*100.0
set y = y*100.0
set in = in*100.0
*
graph(footer="Figure 9.1 Quarterly U.S. data",$
key=below,klabels=||"Income","Consumption","Investment"||) 3
# y
# c
# in
*
* With two cointegrating vectors, this would be easier to analyze using
* CATS.
*
@johmle(lags=2,det=constant,vectors=eigenvect)
# y c in
*
* Normalize first two eigenvectors to be identity in top 2 x 2 corner.
*
compute beta=%xsubmat(eigenvect,1,3,1,2)*inv(%xsubmat(eigenvect,1,2,1,2))
*
* Define the two cointegrating relations for input into ECT
*
dec vect[equation] ecteqns(2)
equation(coeffs=%xcol(beta,1)) ecteqns(1)
# y c in
equation(coeffs=%xcol(beta,2)) ecteqns(2)
# y c in
*
* Define and estimate the VECM
*
system(model=vecm)
variables y c in
det constant
lags 1 2
ect ecteqns
end(system)
*
estimate
*
* Compute the long-run response matrix for the VECM. For a model
* estimated with an ECT component, %varlagsums is the sum of lags on the
* differences only.
*
compute masums=%perp(beta)*$
inv(tr(%perp(%vecmalpha))*%varlagsums*%perp(beta))*$
tr(%perp(%vecmalpha))
*
dec rect lr(3,3) sr(3,3)
*
* Because of rank 2 cointegration, the masums matrix is rank one. As a
* result, restricting the (1,2) and (1,3) long-run responses to zero
* also forces the responses of the other two variables to zero as well.
* So three restrictions (in this pattern) will just identify the model.
*
input lr
. 0 0
. . .
. . .
input sr
. . .
. . 0
. . .
@ShortAndLong(lr=lr,sr=sr,masum=masums) %sigma f
disp ###.### "Impact Responses" f
disp ###.### "Long run Responses" masums*f
*
@varirf(factor=f,steps=30,model=vecm,shocklabels=||"Permanent","Trans 1","Trans 2"||)