VARLAGSUM

Questions and discussions on Vector Autoregressions

VARLAGSUM

Dear Estima,

After estimating the VAR model, I can get the matrix for varlagsum in RATS 6.0. But I am not able to get the same in RATS 7.2. Why is that?

My estimated VAR is in differences. I want to derive the impulse responses and variance decompositions for some more variables say given by the following identities.

equation(identity) 12 Base
# AMBSLDIFF logAMBSL{1}
equation(identity) 13 Money
# M1Multi logAMBSL
equation(identity) 14 Price
# logM1 M1RealBal

associate 12
# 1.0 1.0
associate 13
# 1.0 1.0
associate 14
# 1.0 -1.0

TG81

Posts: 5
Joined: Fri Oct 15, 2010 8:15 pm

Re: VARLAGSUM

TG81 wrote:Dear Estima,

After estimating the VAR model, I can get the matrix for varlagsum in RATS 6.0. But I am not able to get the same in RATS 7.2. Why is that?

My estimated VAR is in differences. I want to derive the impulse responses and variance decompositions for some more variables say given by the following identities.

equation(identity) 12 Base
# AMBSLDIFF logAMBSL{1}
equation(identity) 13 Money
# M1Multi logAMBSL
equation(identity) 14 Price
# logM1 M1RealBal

associate 12
# 1.0 1.0
associate 13
# 1.0 1.0
associate 14
# 1.0 -1.0

Without seeing how you're setting up the VAR, I can't really tell about the %VARLAGSUMS. As far as I can tell, it works fine if you use

SYSTEM(MODEL=...)
etc.

The added identities are much easier to handle as well if you use a MODEL for the VAR and names (rather than numbers) for your equations. The setup from the Gali QJE 1992 replication is:

system(model=islm)
variables cygr cdrate crr crmgr
lags 1 to 4
end(system)
*
estimate(noprint)
*
* Define the identities for accumulating growth rates and other variables
* constructed from the four variables included in the VAR.
*
equation(identity,coeffs=||1.0,1.0||) yaccum logy
# logy{1} cygr
equation(identity,coeffs=||1.0,1.0||) raccum tb3
# tb3{1} cdrate
equation(identity,coeffs=||1.0,-1.0||) infid inf
# tb3 crr
equation(identity,coeffs=||1.0,1.0||) realaccum realm1
# realm1{1} crmgr
group identities yaccum raccum infid realaccum

You just use MODEL=ISLM+IDENTITIES on the IMPULSE and ERRORS instructions.
TomDoan

Posts: 2725
Joined: Wed Nov 01, 2006 5:36 pm

Re: VARLAGSUM

Thank you very much for the reply! Its been a great help.

We figured that %modellagsums is working in place of %varlagsums in RATS 7.2 and 7.3. I ran in to another problem. My model has long run restrictions (and no short run restrictions). When I am imposing that and calling in the procedure @ShortAndLong, I am getting results only for low values of nkeep. For nkeep>190(approx), RATS is giving the following error message

## MAT14. Non-invertible Matrix. Using Generalized Inverse for SYMMETRIC.

In the bootstrap simulations, for a certain value of nkeep, noninvertible matrix is generated and the program stops. The following are some portion of my program. I am not sure what is going wrong as the same set of codes work perfectly fine if I do not impose any short run or long run restrictions. Please help Tom. I have a journal deadline next week.

CODES:
dec rect[series] impulses(nvar,nvar) impuls(nvar,nvar) responses(nvar,nvar) responses2(nvar,nvar) vdecomp(nvar,nvar)
dec vect[series] udraws(nvar) resids(nvar) resample(nvar)
declare rect[series] vdbkeep(nvar,nvar) vdbkeep2(nvar,nvar) deco(nvar,nvar)
do i = 1,nvar
do j = 1,nvar
set responses(i,j) = 0
set responses2(i,j) = 0
set vdbkeep(i,j) = 0
set vdbkeep2(i,j) = 0
end do j
end do i

system(model=varmodel)
variables RDIFF OutputDIFF HoursDIFF RealBalDIFF MultiDIFF AMBSLDIFF
lags 1 to optlags
det constant
end(system)
*
*estimate the multivariate model
*

dec rect f(nvar,nvar)

dec rect sr(nvar,nvar)
input sr
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .
. . . . . .

dec rect lr(nvar,nvar)
input lr
. 0 0 0 0 0
. . 0 0 0 0
. . . 0 0 0
. . . . 0 0
. . . . . 0
. . . . . .

estimate(model=varmodel,cvout=vsigma,resids=resids,noprint)

source "C:\Users\Documents\WinRATS 7.3\ShortAndLong.src"
@ShortAndLong(sr=sr,lr=lr,masums=inv(%modellagsums(varmodel)),factor=f) %sigma
disp ###.### "Impact Responses" f

impulse(noprint,model=varmodel,factor=f,results=impuls,steps=horizon)
errors(print,model=varmodel,steps=horizon,factor=f,results=deco)

compute rstart=%regstart(),rend=%regend()
infobox(action=define,progress,lower=1,upper=nkeep) "Bootstrap Simulations"
do draws=1,nkeep
* Draw a bootstrapped sample
boot entries rstart rend
do i=1,nvar
set udraws(i) = resids(i)(entries(t))
end do i
forecast(path,model=varmodel,from=rstart,to=rend,results=resample)
# udraws

system(model=bootvar)
variables resample
lags 1 to optlags
det constant
end(system)

* Estimate the model with resampled data
estimate(noprint,model=bootvar,noftests,cvout=v)
dec rect fb(nvar,nvar)
source "C:\Users\Documents\WinRATS 7.3\ShortAndLong.src"
@ShortAndLong(sr=sr,lr=lr,masums=inv(%modellagsums(bootvar)),factor=fb) %sigma
disp ###.### "Impact Responsesb" fb

impulse(noprint,model=bootvar,factor=fb,results=impulses,steps=horizon)
errors(noprint,model=bootvar,factor=fb,results=vdecomp,steps=horizon)
do i = 1,nvar
do j = 1,nvar
set responses(i,j) = responses(i,j)+impulses(i,j)
set responses2(i,j) = responses2(i,j)+impulses(i,j)^2
set vdbkeep(i,j) = vdbkeep(i,j)+vdecomp(i,j)
set vdbkeep2(i,j) = vdbkeep2(i,j)+vdecomp(i,j)^2
end do j
end do i

infobox(current=draws)
end do draws
infobox(action=remove)
******
TG81

Posts: 5
Joined: Fri Oct 15, 2010 8:15 pm

Re: VARLAGSUM

I don't know whether it would have any effect, but don't include the source instruction for shortandlong inside the loop. You already did that once with the original data. Once it's in, it's in.

That particular long run restriction can just be done with the %BQFACTOR function as described in the User's Guide which will simplify everything considerably.
TomDoan

Posts: 2725
Joined: Wed Nov 01, 2006 5:36 pm

Re: VARLAGSUM

Thanks Tom! The %BQFACTOR is working. Now, in order to use the procedures @MCGraphIRF and @MCFEVDTable, I am imposing the long run restrictions (given by %bqfactor) in the portion of the codes in MCVardodraws as given below.

Codes:
compute fxx =%decomp(varxx)
compute fwish =%decomp(inv(%nobs*%sigma))
compute wishdof=%nobs-varnreg
compute betaols=%modelgetcoeffs(varmodel)
infobox(action=define,progress,lower=1,upper=ndraws) "Monte Carlo Integration"
do draw=1,ndraws
if %clock(draw,2)==1 {
}
else

TG81

Posts: 5
Joined: Fri Oct 15, 2010 8:15 pm

Re: VARLAGSUM

TG81 wrote:Thanks Tom! The %BQFACTOR is working. Now, in order to use the procedures @MCGraphIRF and @MCFEVDTable, I am imposing the long run restrictions (given by %bqfactor) in the portion of the codes in MCVardodraws as given below.

Code: Select all
`compute fxx    =%decomp(varxx)compute fwish  =%decomp(inv(%nobs*%sigma))compute wishdof=%nobs-varnregcompute betaols=%modelgetcoeffs(varmodel)infobox(action=define,progress,lower=1,upper=ndraws) "Monte Carlo Integration"do draw=1,ndraws   if %clock(draw,2)==1 {      compute sigmad  =%ranwisharti(fwish,wishdof)      compute fsigmad  =%bqfactor(%sigma,%modellagsums(varmodel))      compute betau   =%ranmvkron(fsigmad,fxx)      compute betadraw=betaols+betau   }   else      compute betadraw=betaols-betau   compute %modelsetcoeffs(varmodel,betadraw)impulse(noprint,model=varmodel+identities,factor=fsigmad,results=impulses,steps=steps)`

Replace the IMPULSE instruction with:

Code: Select all
`   compute factor=%bqfactor(sigmad,%modellagsums(model))   impulse(noprint,model=varmodel+identities,factor=factor,results=impulses,steps=steps)`
TomDoan

Posts: 2725
Joined: Wed Nov 01, 2006 5:36 pm

Re: VARLAGSUM

Thanks Tom for the reply! I tried that before as well. RATS is giving me the following error message
## SX11. Identifier %SIGMAD is Not Recognizable. Incorrect Option Field or Parameter Order?
TG81

Posts: 5
Joined: Fri Oct 15, 2010 8:15 pm

Re: VARLAGSUM

TomDoan

Posts: 2725
Joined: Wed Nov 01, 2006 5:36 pm