Replacement for SMODIFY to reformulate VAR

Questions and discussions on Vector Autoregressions
mboldin
Posts: 5
Joined: Fri Oct 04, 2013 9:36 am

Replacement for SMODIFY to reformulate VAR

Unread post by mboldin »

I am updating old code (not written by me) that uses SMODIFY as a command on a VAR structure to create a small system out of a large equation system, where some series/equations will be treated as predetermined for a forecasting exercise.

I found out that SMODIFY is not in RATs 8.2, and I wonder if there is a replacement or SRC example that does what I need.

In essence a triangular contemporaneous relationship must be estimated (the structure VAR part) to transform the reduced form back to the structural system-- but only for 1/2 of the equations. I guess I could work out the effect using matrices to construct the new coefficients but did not want to re-invent something already prepared and tested.

Code example with smodify is below (I modified a few things to simplify). Note the estimations is BVAR, complicating things slightly.

Code: Select all

system 1 to 4
variables y1 y2 y3 y4
lags 1 to 4
det constant
specify(tight=.20) .5
end(system)

estimate(noprint) begdat  enddat

smodify(block=2) 4 v
# 1 11
# 2 12
# 3 13
# 4 14

forecast 2 8 begfor
# 13 fy3
# 14 fy4
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Replacement for SMODIFY to reformulate VAR

Unread post by TomDoan »

We actually have a fix for SMODIFY, which is still in the program but hadn't been tested for several versions. The following does the same transformation just using MODELS rather than numbered equations.

Code: Select all

procedure SModify model0 model1
type model model0 *model1
option symm sigma
option int  block
*
local integer     neqn i j
local symm        wsigma
local rect[rect]  sblocks
local rect        rotate
local vect[equ]   workeq
*
compute neqn=%modelsize(model0)
if %defined(sigma)
   compute wsigma=sigma
else
   compute wsigma=%modelgetvcv(model0)
*
if %defined(block) {
   compute sblocks=%blocksplit(wsigma,||block,neqn-block||)
   compute rotate=-1.0*sblocks(2,1)*inv(sblocks(1,1))
   compute model1=%modeleqn(model0,1)
   do i=2,block
      compute model1=model1+%modeleqn(model0,i)
   end do i
   dim workeq(neqn-block)
   do i=block+1,neqn
      compute workeq(i-block)=%modeleqn(model0,i)
      do j=1,block
         compute workeq(i-block)=workeq(i-block)+rotate(i-block,j)*$
            (%modeleqn(model0,j)-%eqnserieslag(%modeldepvars(model0)(j),0))
         disp workeq(i-block)
      end do j
      compute model1=model1+workeq(i-block)
   end do i
   compute %modelsetvcv(model1,%blockdiag(||sblocks(1,1),sblocks(2,2)+rotate*sblocks(1,2)||))
}
else {
   disp "Need BLOCK option"
   compute model1=model0
}
end
mboldin
Posts: 5
Joined: Fri Oct 04, 2013 9:36 am

Re: Replacement for SMODIFY to reformulate VAR

Unread post by mboldin »

Thanks Tom but Rats freezes and aborts when it gets to this line

compute sblocks=%blocksplit(wsigma,||block,neqn-block||)

I get a message box saying "A problem caused the program to stop working correctly. Please close the program"

same problem with using %smodify
Post Reply