Variance Decomposition

Questions and discussions on Vector Autoregressions
HypatiaCU
Posts: 12
Joined: Mon Nov 12, 2012 6:02 pm

Variance Decomposition

Unread post by HypatiaCU »

Hi,

I am working on variance decomposition of a simple triangular VAR with 1 lag.
[y1_t,y2_t]'=A*[y1_{t-1},y2_{t-1}]'+[error1, erro2]'.
I know how to do the standard variance decomposition. But what I am interested in is a variable
x_t = y2_t - y1_t + y1_{t-1}
How to do the variance decomposition of x_{t+h} for h=10 periods? I know how to compute this step by step in Matlab. Is there a function in Rats that could give me the result directly?

Thank you very much,
Hypatia
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Variance Decomposition

Unread post by TomDoan »

Add the definitional identity for X:

equation(identity,coeffs=||1.0,-1.0,1.0||) xdef x
# y2 y1{0 1}

and do

ERRORS(model=mymodel+xdef,other options)

where mymodel is your VAR. The Makridakis, et al example mwhp423.rpf does something similar.
HypatiaCU
Posts: 12
Joined: Mon Nov 12, 2012 6:02 pm

Re: Variance Decomposition

Unread post by HypatiaCU »

Thanks a lot.
When I do ERRORS(model=mymodel+xdef, STEPS=10), it seems the variance decomposition result of y1 and y2 are changed. They are not the same as the result from ERRORS(model=mymodel, STEPS=10). Why?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Variance Decomposition

Unread post by TomDoan »

Add the option CV=%SIGMA to the ERRORS instruction. It looks like the covariance matrix doesn't copy through when you do the + on the model.
cczzwhy
Posts: 48
Joined: Tue Jun 16, 2015 3:47 am

Re: Variance Decomposition

Unread post by cczzwhy »

Hello,Tom!
I want to ask about how to do the variance decomposition for a recursive var via cholesky factorization?
I run the code ERRORS(model=mymodel, factor=f,other options),but the result is different each time.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Variance Decomposition

Unread post by TomDoan »

"each time" what? What's the F matrix that you're using in the FACTOR option?
cczzwhy
Posts: 48
Joined: Tue Jun 16, 2015 3:47 am

Re: Variance Decomposition

Unread post by cczzwhy »

I revised a mistake and this is the code using now,I am not sure if it is OK...

Code: Select all

system(model=varmodel)
var y1 y2 y3 y4 x1
lags 1 to 4
det constant
end(system)
estimate(resids=resids)
compute vsigma=%sigma

compute f=%decomp(vsigma)
compute fd=%xdiag(f)
ewise f(i,j)=f(i,j)/fd(j)
impulse(steps=nstep,model=varmodel,responses=responsefirst,factor=f,noprint)
errors(model=varmodel,steps=nstep,factor=f)
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Variance Decomposition

Unread post by TomDoan »

That would give you impulse responses to Cholesky shocks standardized to unit impacts. However, because F is no longer a factor of the covariance matrix, the ERRORS is not computing a decomposition of variance.
cczzwhy
Posts: 48
Joined: Tue Jun 16, 2015 3:47 am

Re: Variance Decomposition

Unread post by cczzwhy »

I have no idea about how to generate the variance decompositon,should I use errors(model=varmodel,steps=nstep,factor=swish)?

Code: Select all

*1. Cholesky factorizations
*
compute f=%decomp(vsigma)
compute fd=%xdiag(f)
ewise f(i,j)=f(i,j)/fd(j)
impulse(steps=nstep,model=varmodel,responses=responsefirst,factor=f)

compute swish=%decomp(%sigma)
******************************************************************
estimate
compute nvar   =%nvar
compute fxx    =%decomp(%xx)
compute fwish  =%decomp(inv(%nobs*%sigma))
compute wishdof=%nobs-%nreg
compute betaols=%modelgetcoeffs(varmodel)
*
*
declare vect[rect] %%responses(ndraws)
declare rect[series] impulses(nvar,nvar)

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 fsigma  =%decomp(sigmad)
      compute betau   =%ranmvkron(fsigma,fxx)
      compute betadraw=betaols+betau
   }
   else
      compute betadraw=betaols-betau
   *
   * Push the draw for the coefficient back into the model.
   *
   compute %modelsetcoeffs(varmodel,betadraw)
   impulse(noprint,model=varmodel,factor=fsigma,$
     results=impulses,steps=nstep)
   *
   * Save the impulse responses
	*
   dim %%responses(draw)(nvar*nvar,nstep)
   ewise %%responses(draw)(i,j)=ix=%vec(%xt(impulses,j)),ix(i)
   infobox(current=draw)
end do draw
infobox(action=remove)
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Variance Decomposition

Unread post by TomDoan »

Outside the loop, it would need to be FACTOR=%DECOMP(VSIGMA). You can change the scales on impulse responses (which is done here to give unit impacts), but to do a FEVD, you need a factor of the actual covariance matrix.
cczzwhy
Posts: 48
Joined: Tue Jun 16, 2015 3:47 am

Re: Variance Decomposition

Unread post by cczzwhy »

Hello Tom!How Can I compute a variance decomposition for two series in a linear regression(y dependent variable,x independent variable) as in a VAR system?Thanks in advance!
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Variance Decomposition

Unread post by TomDoan »

You can't. You need a full dynamic model.
cczzwhy
Posts: 48
Joined: Tue Jun 16, 2015 3:47 am

Re: Variance Decomposition

Unread post by cczzwhy »

Is it possible for transform two correlated series into uncorrelated by doing cholesky decomposition?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Variance Decomposition

Unread post by TomDoan »

The inverse of any factor (Cholesky or not) of a covariance matrix can be used to transform a pair of series to a pair of theoretically uncorrelated series. If S is the covariance matrix of the series pair(x,y), then

compute ifac=inv(%decomp(s))
set ytilde = ifac(2,1)*x+ifac(2,2)*y

create ytilde that would have a zero correlation with x.
Post Reply