|
Examples / IRFCONSTRAIN.RPF |
IRFCONSTRAIN.RPF is an example of the use of the @IRFRESTRICT procedure to put restrictions at steps other than just impact and long-run. Note that this is different from what is done in SHUTDOWN.RPF, as the latter computes a sequence of shocks (not just impact shocks) to zero out responses, while @IRFRESTRICT computes a factorization so the shocks themselves produce the desired effects at steps higher than impact. As a result, you are limited to only a modest number of constraints: for an \(N\) variable VAR, the model is just identified with \(N(N-1)/2\) constraints.
This example is based upon the four variable short- and long-run model from Peersman(2005) with the long-run zero restrictions replaced with a one step out zero restriction. The impact shape is
\begin{equation} \begin{array}{*{20}c} \bullet & 0 & 0 & 0 \\ \bullet & \bullet & \bullet & 0 \\ \bullet & \bullet & \bullet & \bullet \\ \bullet & \bullet & \bullet & \bullet \\ \end{array} \label{eq:irfconstrain_impact} \end{equation}
and one step out is
\begin{equation} \begin{array}{*{20}c} \bullet & \bullet & \bullet & \bullet \\ \bullet & \bullet & 0 & 0 \\ \bullet & \bullet & \bullet & \bullet \\ \bullet & \bullet & \bullet & \bullet \\ \end{array} \end{equation}
That satisfies the RRWZ conditions for a B model as it has 0-1-2-3 zeros in the columns (in some order).
After estimating the VAR, the following computes the responses to unit shocks in each variable.
impulse(model=peersman,factor=%identity(%nvar),steps=3,results=irfs)
and this pulls out from IRFS the matrix of impact and one-step-out responses:
compute step0=%xt(irfs,1)
compute step1=%xt(irfs,2)
The following sequence builds up the matrix of restrictions on the vec of the \(\bf{B}\) matrix:
dec rect rr(0,0)
@IRFRestrict(irf=step0,variable=1,shock=2) rr
@IRFRestrict(irf=step0,variable=1,shock=3) rr
@IRFRestrict(irf=step0,variable=1,shock=4) rr
@IRFRestrict(irf=step0,variable=2,shock=4) rr
@IRFRestrict(irf=step1,variable=2,shock=3) rr
@IRFRestrict(irf=step1,variable=2,shock=4) rr
The first four of those will do the obvious: directly setting specific elements of B to zero as shown in \(\eqref{irfconstrain_impact}\). The last two add columns to RR that will make the one step out response zero for shock 3 on variable 2 (output) and for shock 4, also on output. We can then use the %PERP function to convert
\begin{equation} {\bf{R}}vec({\bf{B}}) = 0 \end{equation}
into the form
\begin{equation} vec({\bf{B}}) = {{\bf{R}}^ \bot }\Theta \end{equation}
where \(\Theta\) are the free parameters that we can use in a CVMODEL instruction.
compute rp=%perp(rr)
dec vect theta(%cols(rp))
This creates a FRML which maps the THETA vector back to the implied \(\bf{B}\) matrix:
dec frml[rect] lrfrml
frml lrfrml = %vectorect(rp*theta,%nvar)
The THETA vector has no obvious interpretation, so it's not clear what a good set of guess values would be. What this does is to pick the guess values which comes closest to a Cholesky factor of the covariance matrix:
compute [vect] theta=%ginv(rp)*%vec(%decomp(%sigma))
and this estimates the model:
nonlin theta
cvmodel(b=lrfrml,factor=f,dmatrix=identity) %sigma
and this checks that the factor has the desired properties:
?"Impact responses with multi-step restrictions" ###.### f
?"Step one responses" ###.### step1*f
Full Program
open data peersman_data.dat
calendar(q) 1970:1
data(format=prn,nolabels,org=columns) 1970:01 2002:02 oilprice outputemu $
cpiemu rateemu outputus cpius rateus
*
set groil = 100.0*(log(oilprice/oilprice{1}))
set grout = 100.0*(log(outputus/outputus{1}))
set grp = 100.0*(log(cpius/cpius{1}))
set r = rateus
*
set trend = t
*
system(model=peersman)
variables groil grout grp r
lags 1 2 3
det constant trend
end(system)
*
estimate(sigma) 1979:5 *
*
* These need to be responses to unit shocks, hence the FACTOR=%IDENTITY(%NVAR)
*
impulse(model=peersman,factor=%identity(%nvar),steps=3,results=irfs)
*
* This will do constraints of the form
*
* Impact:
* . 0 0 0
* . . . 0
* . . . .
* . . . .
*
* First step:
* . . . .
* . . 0 0
* . . . .
* . . . .
*
compute step0=%xt(irfs,1)
compute step1=%xt(irfs,2)
***************************************************************************
dec rect rr(0,0)
@IRFRestrict(irf=step0,variable=1,shock=2) rr
@IRFRestrict(irf=step0,variable=1,shock=3) rr
@IRFRestrict(irf=step0,variable=1,shock=4) rr
@IRFRestrict(irf=step0,variable=2,shock=4) rr
@IRFRestrict(irf=step1,variable=2,shock=3) rr
@IRFRestrict(irf=step1,variable=2,shock=4) rr
*
compute rp=%perp(rr)
dec vect theta(%cols(rp))
dec frml[rect] lrfrml
*
frml lrfrml = %vectorect(rp*theta,%nvar)
*
* Get guess values as closest to a Cholesky factor
*
compute [vect] theta=%ginv(rp)*%vec(%chol(%sigma))
*
nonlin theta
cvmodel(b=lrfrml,factor=f,dmatrix=identity) %sigma
?"Impact responses with multi-step restrictions" ###.### f
?"Step one responses" ###.### step1*f
Output
VAR/System - Estimation by Least Squares
Quarterly Data From 1980:01 To 2002:02
Usable Observations 90
Dependent Variable GROIL
Mean of Dependent Variable -0.52882624
Std Error of Dependent Variable 14.63158931
Standard Error of Estimate 14.11004908
Sum of Squared Residuals 15131.104867
Durbin-Watson Statistic 2.0055
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. GROIL{1} 0.22534895 0.12337533 1.82653 0.07169704
2. GROIL{2} -0.43423891 0.12557276 -3.45807 0.00089464
3. GROIL{3} 0.15593820 0.12191368 1.27909 0.20475811
4. GROUT{1} 3.06894295 2.81275016 1.09108 0.27868356
5. GROUT{2} 1.23549417 2.82479878 0.43737 0.66308035
6. GROUT{3} -0.26920860 2.16748670 -0.12420 0.90148237
7. GRP{1} 1.96759913 7.16940892 0.27444 0.78448828
8. GRP{2} 9.91409078 7.76761918 1.27634 0.20572338
9. GRP{3} -6.72635085 7.27073613 -0.92513 0.35782835
10. R{1} -0.37745577 1.74372783 -0.21646 0.82920541
11. R{2} -1.01071543 2.20012084 -0.45939 0.64726485
12. R{3} 1.80175458 1.77402131 1.01563 0.31302662
13. Constant -25.39422369 18.73585331 -1.35538 0.17931064
14. TREND 0.16576962 0.12246401 1.35362 0.17987005
F-Tests, Dependent Variable GROIL
Variable F-Statistic Signif
*******************************************************
GROIL 4.8777 0.0037250
GROUT 0.5027 0.6815454
GRP 0.8185 0.4876489
R 0.3736 0.7722730
Dependent Variable GROUT
Mean of Dependent Variable 0.7130123583
Std Error of Dependent Variable 0.7723798141
Standard Error of Estimate 0.5772537367
Sum of Squared Residuals 25.324862614
Durbin-Watson Statistic 1.9712
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. GROIL{1} -0.000681960 0.005047386 -0.13511 0.89288086
2. GROIL{2} 0.012234253 0.005137285 2.38146 0.01974751
3. GROIL{3} -0.004696148 0.004987589 -0.94157 0.34939783
4. GROUT{1} 0.298096997 0.115071927 2.59053 0.01148271
5. GROUT{2} 0.393804582 0.115564846 3.40765 0.00105066
6. GROUT{3} -0.033488259 0.088673667 -0.37766 0.70673783
7. GRP{1} -0.753534228 0.293306427 -2.56910 0.01215545
8. GRP{2} 0.254907073 0.317779702 0.80215 0.42496721
9. GRP{3} 0.537294293 0.297451807 1.80632 0.07482658
10. R{1} -0.015051005 0.071337343 -0.21098 0.83346481
11. R{2} -0.407076868 0.090008757 -4.52264 0.00002212
12. R{3} 0.323482595 0.072576674 4.45712 0.00002821
13. Constant 1.647074297 0.766499200 2.14883 0.03483234
14. TREND -0.008802387 0.005010104 -1.75693 0.08295783
F-Tests, Dependent Variable GROUT
Variable F-Statistic Signif
*******************************************************
GROIL 1.9954 0.1217798
GROUT 6.9731 0.0003311
GRP 2.7335 0.0494781
R 11.7950 0.0000020
Dependent Variable GRP
Mean of Dependent Variable 0.8480124029
Std Error of Dependent Variable 0.5459623590
Standard Error of Estimate 0.2357486026
Sum of Squared Residuals 4.2238826762
Durbin-Watson Statistic 1.8792
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. GROIL{1} 0.006469164 0.002061337 3.13833 0.00241867
2. GROIL{2} -0.004793438 0.002098051 -2.28471 0.02512095
3. GROIL{3} 0.002264989 0.002036916 1.11197 0.26965622
4. GROUT{1} -0.016278566 0.046995012 -0.34639 0.73000739
5. GROUT{2} 0.002669069 0.047196318 0.05655 0.95505010
6. GROUT{3} -0.052445708 0.036214046 -1.44821 0.15167016
7. GRP{1} 0.359217167 0.119785418 2.99884 0.00366185
8. GRP{2} 0.201840033 0.129780227 1.55524 0.12404244
9. GRP{3} 0.182583963 0.121478379 1.50302 0.13697900
10. R{1} 0.050091575 0.029133945 1.71935 0.08962040
11. R{2} -0.050631770 0.036759292 -1.37739 0.17243568
12. R{3} -0.011385255 0.029640084 -0.38412 0.70196448
13. Constant 0.652570858 0.313035852 2.08465 0.04046008
14. TREND -0.003760847 0.002046111 -1.83805 0.06996315
F-Tests, Dependent Variable GRP
Variable F-Statistic Signif
*******************************************************
GROIL 4.7200 0.0044906
GROUT 0.7928 0.5016731
GRP 14.9563 0.0000001
R 1.5906 0.1986110
Dependent Variable R
Mean of Dependent Variable 7.2516666667
Std Error of Dependent Variable 3.3681179521
Standard Error of Estimate 0.9505662131
Sum of Squared Residuals 68.671785533
Durbin-Watson Statistic 1.9800
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. GROIL{1} 0.005195422 0.008311553 0.62508 0.53378807
2. GROIL{2} 0.004713180 0.008459589 0.55714 0.57906861
3. GROIL{3} -0.006775541 0.008213085 -0.82497 0.41197102
4. GROUT{1} 0.431784017 0.189489438 2.27867 0.02549564
5. GROUT{2} 0.620819990 0.190301129 3.26230 0.00165652
6. GROUT{3} 0.105351767 0.146019309 0.72149 0.47282068
7. GRP{1} 0.100960167 0.482988957 0.20903 0.83498249
8. GRP{2} 0.890088701 0.523289204 1.70095 0.09304089
9. GRP{3} 1.048473330 0.489815172 2.14055 0.03551774
10. R{1} 0.717687246 0.117471509 6.10946 0.00000004
11. R{2} -0.408239906 0.148217807 -2.75432 0.00735532
12. R{3} 0.457223146 0.119512321 3.82574 0.00026558
13. Constant -1.730636608 1.262197532 -1.37113 0.17436976
14. TREND 0.007237484 0.008250159 0.87725 0.38311346
F-Tests, Dependent Variable R
Variable F-Statistic Signif
*******************************************************
GROIL 0.5196 0.6700529
GROUT 6.8713 0.0003714
GRP 7.1476 0.0002722
R 49.6658 0.0000000
Covariance\Correlation Matrix of Residuals
GROIL GROUT GRP R
GROIL 168.12338741 0.02513615 0.42361138 0.17084446
GROUT 0.17288813 0.28138736 0.11012051 0.37325540
GRP 1.18991613 0.01265480 0.04693203 0.13606964
R 1.93500847 0.17295229 0.02574920 0.76301984
Responses to Shock in GROIL
Entry GROIL GROUT GRP R
1 1.0000000 0.0000000 0.0000000 0.00000000
2 0.2253490 -0.0006820 0.0064692 0.00519542
3 -0.3747820 0.0069244 -0.0007404 0.00997132
Responses to Shock in GROUT
Entry GROIL GROUT GRP R
1 0.0000000 1.0000000 0.0000000 0.00000000
2 3.0689429 0.2980970 -0.0162786 0.43178402
3 2.6469109 0.4863412 0.0334512 1.07372036
Responses to Shock in GRP
Entry GROIL GROUT GRP R
1 0.0000000 0.0000000 1.0000000 0.00000000
2 1.9675991 -0.7535342 0.3592172 0.10096017
3 8.7136210 -0.2432630 0.3609294 0.68367162
Responses to Shock in R
Entry GROIL GROUT GRP R
1 0.0000000 0.0000000 0.0000000 1.00000000
2 -0.3774558 -0.0150510 0.0500916 0.71768725
3 -1.3143004 -0.4598537 0.0011153 0.10343251
Covariance Model-Likelihood - Estimation by BFGS
Convergence in 22 Iterations. Final criterion was 0.0000063 <= 0.0000100
Observations 90
Log Likelihood -516.8800
Log Likelihood Unrestricted -516.8800
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. THETA(1) 12.96624057 0.99976819 12.96925 0.00000000
2. THETA(2) 0.15246586 0.09315225 1.63674 0.10168515
3. THETA(3) -0.09177035 0.02249968 -4.07874 0.00004528
4. THETA(4) 0.44389748 0.04503593 9.85652 0.00000000
5. THETA(5) 0.00918847 0.08785408 0.10459 0.91670285
6. THETA(6) 0.29546063 0.08750216 3.37661 0.00073385
7. THETA(7) 0.12829000 0.01867063 6.87122 0.00000000
8. THETA(8) 0.01333377 0.05832839 0.22860 0.81918112
9. THETA(9) 0.34436656 0.04973888 6.92349 0.00000000
10. THETA(10) 0.80001274 0.05982697 13.37211 0.00000000
Impact responses with multi-step restrictions
12.966 0.000 0.000 -0.000
0.013 0.360 0.389 -0.000
0.092 -0.128 0.148 -0.016
0.149 0.152 0.298 0.793
Step one responses
3.087 0.797 1.372 -0.330
-0.076 0.202 -0.000 -0.000
0.124 -0.044 0.062 0.034
0.189 0.252 0.397 0.567
Copyright © 2026 Thomas A. Doan