I am trying to estimate time-varying variance decompositions for 7 variables over 200-week rolling sample windows, using Cholesky factorization.
I wrote a program pasted at the bottom (based on the program shared at http://www.estima.com/forum/viewtopic.p ... old+yilmaz), but am getting two problems for which I need your help.
First, running the program returns a following error message.
It is probably due to a following line, but I could not figure out how I can resolve this.## MAT13. Store into Out-of-Range Matrix or Series Element
The Error Occurred At Location 213, Line 12 of loop/block
Code: Select all
set %s(%string(count)+"_from_"+%l(i)+"_to_"+%l(j)) end end = gfevd(j,i)(asteps)*100Second, I would like to repeat the process for 120 different orderings.
In the program below, you find I made two different orderings and a loop for them using dofor command:
Code: Select all
dec vect[int] order1
enter(varying) order1; # 1 2 3 4 5 6 7
dec vect[int] order2
enter(varying) order2; # 1 2 3 4 5 7 6
*
*
dofor order = order1 order2
*
*
It gives me 5! = 120 orderings.
It is next to impossible to establish 120 orderings as I do above.
Could you let me know how I can efficiently establish the 120 orderings and repeat the loop for the orderings?
Thank you so much for your support, and any advice is highly appreciated.
Best,
Masafumi
Code: Select all
*********************************************************************
* Replication file for Diebold and Yilmaz(2009), "Measuring Financial
* Asset Return and Volatility Spillovers, with Application to Global
* Equity Markets," Economic Journal, vol. 119, no. 534, 158-171.
*
* Analysis of returns data
*
* If you make usegirf=1, this will use the generalized spillover
* measures proposed in Diebold and Yilmaz(2011), "Better to Give than to
* Receive: Predictive Directional Measurement of Volatility Spillovers",
* IJF, to appear. usegirf=0 does the Choleski factorization used in the
* 2009 paper.
*********************************************************************
*
compute usegirf=0
*
OPEN DATA NEER_EAC.XLS
CALENDAR(W) 2000:1:9
DATA(FORMAT=XLS,ORG=COLUMNS,LEFT=2,DATEFORM="m/d/y") 2000:01:09 2012:09:09 $
R_USA R_EUR R_KEN R_TZA R_UGA R_RWA R_BDI
*
Labels 1 2 3 4 5 6 7
# 'USA' 'EUR' 'KEN' 'TZA' 'UGA' 'RWA' 'BDI'
*
*********************************************************************
* Produce the appropriate "factor" matrix from %sigma
*
function FactorMatrix
type rect FactorMatrix
if usegirf
compute FactorMatrix=%sigma*inv(%diag(%sqrt(%xdiag(%sigma))))
else
compute FactorMatrix=%decomp(%sigma)
end
*********************************************************************
*********************************************************************
* Creating different orders
*********************************************************************
dec vect[int] order1
enter(varying) order1; # 1 2 3 4 5 6 7
*
dec vect[int] order2
enter(varying) order2; # 1 2 3 4 5 7 6
*
*********************************************************************
* Rolling window analysis
*********************************************************************
compute nspan=200
* Width of rolling windows = 200 weeks
compute nsteps=10, asteps=4
* Compute variance decompositions up to 10 step and analyze the 4 step responses
compute rstart=2000:01:09, rend=2012:09:09
*
compute count = 0
dofor order = order1 order2
compute count=count+1
do end=rstart+nspan-1,rend
* Setup and estimate one lag VAR
system(model=var)
variables order
lags 1
det constant
end(system)
* Coefficients Restricted
compute coeffs = %modelgetcoeffs(var)
compute coeffs(3,1) = 0
compute coeffs(4,1) = 0
compute coeffs(5,1) = 0
compute coeffs(6,1) = 0
compute coeffs(7,1) = 0
compute coeffs(3,2) = 0
compute coeffs(4,2) = 0
compute coeffs(5,2) = 0
compute coeffs(6,2) = 0
compute coeffs(7,2) = 0
compute %modelsetcoeffs(var, coeffs)
*
estimate(noprint) end-nspan+1 end
*
compute gfactor=FactorMatrix()
errors(model=var,steps=nsteps,factor=gfactor,stderrs=gstderrs,noprint,results=gfevd)
do i=1,7
do j=1, 7
set %s(%string(count)+"_from_"+%l(i)+"_to_"+%l(j)) end end = gfevd(j,i)(asteps)*100
end do j
end do i
end do end
end dofor