Page 1 of 1
ewise error
Posted: Thu Jul 23, 2015 12:51 pm
by luching
Hi, I am trying to store the historical decomposition from a VAR, so that I can compute confidence bands later on. I am following the montevar codes. The ewise doesn't work and there seems to be a looping error. Please help. Here's the relevant section:
history(model=varmodel,add,results=history,cv=sigmad,from=hstart,to=hend)
declare vect[rect] history1(ndraws)
dim history1(draws)((nvar+1)*nvar,nhor)
ewise history1(draws)(i,j)=history((i-1)/nvar+1,%clock(i,nvar+1))(j)
Re: ewise error
Posted: Thu Jul 23, 2015 3:17 pm
by TomDoan
luching wrote:Hi, I am trying to store the historical decomposition from a VAR, so that I can compute confidence bands later on. I am following the montevar codes. The ewise doesn't work and there seems to be a looping error. Please help. Here's the relevant section:
history(model=varmodel,add,results=history,cv=sigmad,from=hstart,to=hend)
declare vect[rect] history1(ndraws)
dim history1(draws)((nvar+1)*nvar,nhor)
ewise history1(draws)(i,j)=history((i-1)/nvar+1,%clock(i,nvar+1))(j)
The "J" needs to be mapped down from the natural entry range of HSTART to HEND down to 1 to NHOR. And HISTORY has NVAR+1 rows so your first subscript isn't right (that would be OK if there were NVAR rows). It's easier to use the %BLOCK, which is the counterpart of %CLOCK for getting the column number. This maintains the normal arrangement of a matrix in RATS (stored by columns):
ewise history1(draws)(i,j)=history(%clock(i,nvar+1),%block(i,nvar+1))(hstart+j-1)
Re: ewise error
Posted: Thu Jul 23, 2015 3:39 pm
by luching
Thanks Tom. The %block command doesn't seem to be working with my version. Is there an alternative way?
Re: ewise error
Posted: Fri Jul 24, 2015 8:01 am
by TomDoan
%block(m,n) is equivalent to (m-1)/(n)+1
Re: ewise error
Posted: Fri Jul 24, 2015 8:33 am
by luching
Thanks much. I had to change the time loop as hstart+j-1, but it worked.
Re: ewise error
Posted: Fri Jul 24, 2015 4:48 pm
by TomDoan
Thanks for pointing that out. I corrected the original post.