Dear Doan,
I finally come up with the following model. The code is working without no problem. But there are still some questions stick to my mind .
- First I am not sure whether the calculated girfs are correct or not. Which girfs, girf(1) or girf(2) ..... corresponds to which variable.
- If you look at my data you will see that I am using the levels of the variables in the estimates. That may explain why the produced GIRF's are explosive, but i don't know how to fix this
- Forecasting function is working properly but as I said before I don't know whether the forecasting sample is chosen correctly.
- Furthermore based on this model I have to also calculate nonlinear irfs for the upper and the lower regime. for int>.228 and int<.228 similar to one in the paper of Balke (2000) that I have posted to you. Can I produce the girfs for regime 1 regime 2 by selecting different starting points for forecasting function?
- I have to also produce the responses of each variable under both regimes with their error bands.
I am also attaching my data file in case you need.
Thanks for your help again.
Nazif
- Code: Select all
* SMS_5_2.RPF
* Switching Models and Structural Breaks
* Example 5.2
*
* Based upon Balke and Fomby(1997), "Threshold Cointegration,"
* International Economic Review, vol 38, no 3, 627-45.
*
* Data file is a reconstruction.
*
* This estimates the thresholds using the bivariate likelihood, computes
* an eventual forecast function and GIRF.
*
open data montra_2011_4.xls
calendar(m) 1986
data(format=xls,org=columns) 1986:1 2010:11
*
set thresh = INTBRATE{1}
dec frml[int] switch
frml switch = 1+fix(INTBRATE{1}>=0.228)
*
* Estimate the model at the best breaks to get the covariance matrix.
*
sweep(group=switch(t))
# LIP LCPI INTBRATE LRERCPI_SA LCRE
# constant LIP{1 to 4} LCPI{1 to 4} INTBRATE{1 to 4} LRERCPI_SA{1 to 4} LCRE{1 to 4} lpetpri{1 to 4} ffr{1 to 4} indus{1 to 4}
compute tvecmsigma=%sigma
*
*
compute nvar=5
compute nregime=2
*
system(model=basevecm)
variables LIP LCPI INTBRATE LRERCPI_SA LCRE
lags 1 to 4
det constant lpetpri{1 to 4} ffr{1 to 4} indus{1 to 4}
end(system)
dec rect[frml] tvecfrml(nvar,nregime)
do i=1,nregime
estimate(smpl=(switch(t)==i))
do j=1,nvar
frml(equation=%modeleqn(basevecm,j)) tvecfrml(j,i)
end do j
end do i
*
dec vect[frml] switchf(nvar)
do j=1,nvar
frml switchf(j) %modeldepvars(basevecm)(j) = tvecfrml(j, switch(t))
end do j
* My endogenous variables are LIP LCPI INTBRATE LRERCPI_SA LCRE
group tvecm switchf(1) switchf(2) switchf(3) switchf(4) switchf(5)
*
* Eventual forecast function, starting with 2003:4 data (Post-inflation targeting period).
*
forecast(model=tvecm,from=2003:4,steps=24,results=eff)
graph(footer=$
"Eventual Forecast Function for Credit, starting at 2003:4")
# eff(5)
graph(footer=$
"Eventual Forecast Function for CPI, starting at 2003:4")
# eff(2)
*
* GIRF starting in 1998:3 for a one s.d. shock to DR correlated with FF
* using the estimated covariance matrix. (1969:3 has values for both
* rates which are close to the average for the full period).
*
compute ndraws=5000
compute baseentry=2003:3
compute nsteps =40
*
dec vect[series] fshocks(5) girf(5)
dec series[vect] bishocks
dec vect ishocks
*
smpl baseentry baseentry+(nsteps-1)
do i=1,5
set girf(i) = 0.0
end do i
*
compute fsigma=%psdfactor(tvecmsigma,||1,2,3,4,5||)
*
do draw=1,ndraws
gset bishocks = %ranmvnormal(fsigma)
set fshocks(1) = bishocks(t)(1)
set fshocks(2) = bishocks(t)(2)
set fshocks(3) = bishocks(t)(3)
set fshocks(4) = bishocks(t)(4)
set fshocks(5) = bishocks(t)(5)
forecast(paths,model=tvecm,results=basesims)
# fshocks
compute ishock=fsigma(5,5)
compute ishocks=inv(fsigma)*bishocks(baseentry)
compute ishocks(5)=ishock/fsigma(5,5)
compute bishocks(baseentry)=fsigma*ishocks
compute fshocks(1)(baseentry)=bishocks(baseentry)(1)
compute fshocks(2)(baseentry)=bishocks(baseentry)(2)
compute fshocks(3)(baseentry)=bishocks(baseentry)(3)
compute fshocks(4)(baseentry)=bishocks(baseentry)(4)
compute fshocks(5)(baseentry)=bishocks(baseentry)(5)
forecast(paths,model=tvecm,results=sims)
# fshocks
do i=1,5
set girf(i) = girf(i)+(sims(i)-basesims(i))
end do i
end do draw
*
do i=1,5
set girf(i) = girf(i)/ndraws
end do i
*
graph(footer=$
"GIRF for What to One S.D. Shock in What")
# girf(4)
graph(footer=$
"GIRF for What to One S.D. Shock in What")
# girf(3)
graph(footer=$
"GIRF for What to One S.D. Shock in What")
# girf(1)
*
table