need small troubleshooting about VAR.

Questions and discussions on Vector Autoregressions
marvin2jhjh
Posts: 6
Joined: Fri Jun 15, 2012 8:58 pm

need small troubleshooting about VAR.

Unread post by marvin2jhjh »

This is a code provided by Bjornland (2010), "The role of house prices in the monetary policy transmission mechanism in small open economies".

When I run "system(model=varhousepr) 1 to 6", the message comes out."## OP9. Options MODEL and parameter list of equations May Not Be Used Together".

And after ignoring the message, when I run "@VARIRF(model=varhousepr,steps=40,DECOMP=f,byshock,errors)" , the following message comes out:
## OP3. This Instruction Does Not Have An Option BYS
>>>>0,DECOMP=f,byshock,<<<<

Please let me know how to fix it. Thank you very much!

Code: Select all

*********
**   Replication file for:
**
**   Bj?nland, Hilde C. and Dag Henning Jacobsen (2010): "The role of house prices in the monetary policy transmission mechanism in small open economies".
** 	Journal of Financial Stability, 6, 2010, 218-229.
**
**	Please cite the above reference if used.
**
clear all
*
source "C:\Users\hyun\Documents\WinRATS Standard 8.1\shortandlong.src"
source "C:\Users\hyun\Documents\WinRATS Standard 8.1\varirf.src"
*
CALENDAR 1980 1 4
ALLOCATE 20 2006:4
open data JFS_Bjornland&Jacobsen_Data_Sweden
data(format=xls,org=obs) / RER GDP CPI intr HPR RN3MF anninfl PCON DU92Q3 DU93Q1 DU95Q4
set lgdp / = log(gdp(t))
set lpcon / = log(pcon(t))
set infl / = anninfl(t)
set rdom / = intr(t)
set rtrade / = rn3mf(t)
set lhopr / = log(hpr(t))
set lrhopr / = log(hpr(t)/cpi(t))
set lcpi / = LOG(cpi(t))
set rexc / = LOG(1/rer(t))
*
set dmy92q1 = t == 1992:1
set dmy88q3 = t == 1988:3
*
diff rexc / drexc
diff lhopr / dlhopr
diff lrhopr / dlrhopr
diff lgdp / dlgdp
diff lpcon / dlpcon
diff lcpi / dlcpi
*
*
smpl 1983:1 2006:4
set trend = T
*open plot C:\Documents and Settings\hilde\My Documents\NB\graph.gsp
*graph 2
*# dlhopr
*# dlrhopr
*
*open plot C:\Documents and Settings\hilde\My Documents\NB\graph.gsp
*graph 1
*# rexc
*
system(model=varhousepr) 1 to 6
VAR rtrade dlgdp infl dlrhopr drexc rdom
*VAR rtrade dlpcon infl dlrhopr drexc rdom
lags 1 to 4
det constant DU92Q3 DU93Q1 DU95Q4
end(system)
scratch 6 / resids
estimate(sigma,outsigma=V,noftests) 1983:1 2006:4
*print 1993:1 1999:4 resids+1 resids+2  resids+3
*
*
dec rect lr(6,6) sr(6,6)
input lr
.. . . . . .
.. . . . . 0
.. . . . . .
.. . . . . .
.. . . . . 0
.. . . . . .
input sr
.. 0 0 0 0 0
.. . 0 0 0 0
.. . . 0 0 0
.. . . . 0 .
.. . . . . .
.. . . . . .
*
@ShortAndLong(lr=lr,sr=sr,masum=inv(%varlagsums)) %sigma f
*
@VARIRF(model=varhousepr,steps=40,DECOMP=f,byshock,errors)
*
*
impulse(model=varhousepr,decomp=f,steps=40)
*
errors(model=varhousepr,decomp=f,steps=40,impulses)
*
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: need small troubleshooting about VAR.

Unread post by TomDoan »

marvin2jhjh wrote:This is a code provided by Bjornland (2010), "The role of house prices in the monetary policy transmission mechanism in small open economies".

When I run "system(model=varhousepr) 1 to 6", the message comes out."## OP9. Options MODEL and parameter list of equations May Not Be Used Together".
That's a warning---the 1 to 6 has no effect.
marvin2jhjh wrote: And after ignoring the message, when I run "@VARIRF(model=varhousepr,steps=40,DECOMP=f,byshock,errors)" , the following message comes out:
## OP3. This Instruction Does Not Have An Option BYS
>>>>0,DECOMP=f,byshock,<<<<
The code you are following is using a older version of @VARIRF. The new form of the BYSHOCK option is PAGE=BYSHOCK.
marvin2jhjh
Posts: 6
Joined: Fri Jun 15, 2012 8:58 pm

Re: need small troubleshooting about VAR.

Unread post by marvin2jhjh »

Thank you very much! I have one more question. Is there any way to get the values of impulse responses rather than graphs?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: need small troubleshooting about VAR.

Unread post by TomDoan »

marvin2jhjh wrote:Thank you very much! I have one more question. Is there any way to get the values of impulse responses rather than graphs?
Sure. Just add a RESULTS option to the IMPULSE instruction.
kam
Posts: 3
Joined: Mon Feb 01, 2016 7:00 am

Re: need small troubleshooting about VAR.

Unread post by kam »

Hi there,
I'm trying o replicate the same paper Bjornland (2010), "The role of house prices in the monetary policy transmission mechanism in small open economies", but I'm using the code you provided for Bjørnland, Hilde C. and Kai Leitemo (2009) as the base since the methodology is very similar. I have narrowed down the model to 4 variables: real gdp (gdp), inflation (cpi), real house prices (hp) and interest rate (int). Since house prices are I(2) they have been differenciated twice to obtain stationarity. My main focus is on monetary policy shocks and hence interest rates. I ignore the part with Cheloski decomposition and I have long-run restriction of the monetary policy effects on gdp.
The problem is that IRF do not show up as expected, e.g. interest rate shock for interest rate do not decline steadily to zero, as if data wouldn't be stationary.Data has been double checked and couldn't find any faults in there, so I guess its my code which is wrong.
Any help would be much appreciated. Thanks!

Code: Select all

compute nsteps=72
compute ndraws=10000
OPEN DATA "C:\Users\Kar\Desktop\Excel\US\USdata III.xlsx"
CALENDAR(Q) 1984:4
DATA(FORMAT=XLSX,ORG=obs) 1984:4 2007:4 GDP CPI hp int
print
table
*************************************************************************************************
*TRANSFORMATIONS
*************************************************************************************************
set lgdp    = log(gdp)
set lcpi  = log(cpi)
set lhp      = log(hp)
set intr = int
*
set dmy01m09 = t == 2001:09
set dmy87m10 = t == 1987:10
*
diff lgdp   / dlgdp
diff intr   / dint
diff lcpi / dlcpi
diff lhp   / dlhp
diff dlhp / dlhp2
set trend  = t
set trend2 =t^2
************************************************************************************************
*VAR
************************************************************************************************
system(model=ussvar)
variables dlgdp dlcpi dlhp2 dint
lags 1 to 3
det constant
end(system)
estimate(resids=resids,noprint) 1984:4 2007:4
compute vsigma=%sigma
************************************************************************************************
*RESTRICTIONS
************************************************************************************************
dec rect lr(4,4) sr(4,4)
input sr
. 0 0 0
. . 0 0
. . . .
. . . .
input lr
. . . 0
. . . .
. . . .
. . . .
declare vect[strings] shocklabels varlabels
compute shocklabels=||"output shock","inflation shock","House Prices shock","Interest rates shock"||
compute varlabels=||"GDP","CPI","House Prices","Interest rates"||
@shortandlong(sr=sr,lr=lr,masum=inv(%varlagsums)) %sigma f

****************************************************************************************************
errors(model=ussvar,steps=nsteps,factor=f,labels=shocklabels,noprint)

* Normalize the shocks
*
compute f=%ddivide(f,%xdiag(f))
*
* Point estimates
*
@varirf(model=ussvar,steps=nsteps,page=byshock,factor=f,shocks=shocklabels,varlabels=varlabels,accumulate=||2,3,4||)
#

****************************************************************************************************

* Factor function for Monte Carlo integration. This relies upon the LR
* and SR matrices set above.
*
function SRLRFactor sigma model
type rect SRLRFactor
type symm sigma
type model model
*
@ShortAndLong(lr=lr,sr=sr,masum=inv(%modellagsums(model))) sigma SRLRFactor
*
* This is specific to this paper.
*
compute SRLRFactor=%ddivide(SRLRFactor,%xdiag(SRLRFactor))
*
end
*
* Monte Carlo integration using SRLRFactor to compute the factor matrix
* given a coefficient draw.
*
@MCVARDoDraws(model=ussvar,ffunction=SRLRFactor,accum=||2,3,4||,steps=nsteps,draws=ndraws)

@MCGraphIRF(model=ussvar,shocklabels=shocklabels,varlabels=varlabels,page=byshock,center=mean,percent=||.16,.84||)

Attachments
USdata III.xlsx
(12.65 KiB) Downloaded 784 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: need small troubleshooting about VAR.

Unread post by TomDoan »

You're accumulating the responses to the last three variables, so those will no longer be stationary variables.
kam
Posts: 3
Joined: Mon Feb 01, 2016 7:00 am

Re: need small troubleshooting about VAR.

Unread post by kam »

TomDoan wrote:You're accumulating the responses to the last three variables, so those will no longer be stationary variables.
Thanks! I fixed it and accumulated only differenciated variables. I altered the code a bit and got more reasonable results. Still I'm bit worried about my IRF's after Monte Carlo integration. For the United States the results for real house prices and GDP to interest rate shocks seem to be quite different from the Bjornland (2010) mentioned above or Bjornland (2008) "the role of house prices in the monetary policy transmission mechanism in the u.s", in these papers there is statistically significant decline of both gdp and real house prices in response to int. rate rise. I tried to replicate Norway from Bjornland (2010) and got similar (insignificant) results. So my question is:
Can you see any other mistakes in code that would influence my IRF's? Thanks. Sorry for being this vague.

Code: Select all

*********
**   Replication file for:
**
**   Bj?nland, Hilde C. and Dag Henning Jacobsen (2010): "The role of house prices in the monetary policy transmission mechanism in small open economies".
**    Journal of Financial Stability, 6, 2010, 218-229.
**
**   Please cite the above reference if used.
**
clear all
OPEN DATA "C:\Users\Kar\Desktop\Dissertation\Excel\US\unitedstates 84-07.xlsx"
CALENDAR(Q) 1984:4
DATA(FORMAT=XLSX,NOLABELS,ORG=COLUMNS,TOP=2) 1984:04 2007:04 GDP CPI HP INT
table
****************************************************************************************************
set lgdp / = log(gdp)
set lcpi / = log(cpi)
set lhp / = log(hp)
set intr / = int
*
diff lgdp / dlgdp
diff lhp / dlhp
diff dlhp / dlhp2
diff lcpi / dlcpi
diff dlcpi / dlcpi2
*
set trend = t
set trend2 = t^2
****************************************************************************************************
system(model=usvar)
var dlgdp dlcpi2 dlhp2 intr
lags 1 to 4
det constant
end(system)
estimate(resids=resids,noprint) 1984:04 2007:04
compute vsigma=%sigma
****************************************************************************************************
dec rect lr(4,4) sr(4,4)
input sr
. 0 0 0
. . 0 0
. . . .
. . . .
input lr
. . . 0
. . . .
. . . .
. . . .
@shortandlong(sr=sr,lr=lr,masum=inv(%varlagsums)) %sigma f

declare vect[strings] shocklabels varlabels
compute shocklabels=||"output shock","inflation shock","House Prices shock","Interest rates shock"||
compute varlabels=||"GDP","CPI","House Prices","Interest rates"||
estimate(noprint)
*
errors(model=usvar,steps=40,factor=f,labels=shocklabels,noprint)
* Normalize the shocks
*
compute f=%ddivide(f,%xdiag(f))
*
* Point estimates
*
@varirf(model=usvar,steps=40,page=byshock,factor=f,shocks=shocklabels,varlabels=varlabels,accumulate=||1,2,3||)
****************************************************************************************************
* Factor function for Monte Carlo integration. This relies upon the LR
* and SR matrices set above.
*
function SRLRFactor sigma model
type rect SRLRFactor
type symm sigma
type model model
*
@ShortAndLong(lr=lr,sr=sr,masum=inv(%modellagsums(model))) sigma SRLRFactor
*
* This is specific to this paper.
*
compute SRLRFactor=%ddivide(SRLRFactor,%xdiag(SRLRFactor))
*
end
*
* Monte Carlo integration using SRLRFactor to compute the factor matrix
* given a coefficient draw.
*
compute ndraws=10000
@MCVARDoDraws(model=usvar,ffunction=SRLRFactor,steps=40,draws=ndraws,accumulate=||1,2,3||)
@MCGraphIRF(model=usvar,shocklabels=shocklabels,varlabels=varlabels,page=byshock,center=mean,percent=||.16,.84||)
Attachments
unitedstates 84-07.xlsx
(12.54 KiB) Downloaded 737 times
Interest rate shockUS.jpg
Interest rate shockUS.jpg (131.1 KiB) Viewed 10358 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: need small troubleshooting about VAR.

Unread post by TomDoan »

I assume that the published work was subject to the same error described in another thread beginning at:

https://estima.com/forum/viewtopic.php?p=7974#p7974
kam
Posts: 3
Joined: Mon Feb 01, 2016 7:00 am

Re: need small troubleshooting about VAR.

Unread post by kam »

ok, thanks!
Post Reply