I am trying to replicate Filardo(1994) by using MLE method. I am keeping getting the following error message
I am not sure how to solve the problem and I am seeking for your help.## MAT15. Subscripts Too Large or Non-Positive
The Error Occurred At Location 216, Line 21 of %MSVARPROB
Here is my code
Code: Select all
cal(m) 1948
open data filardo.dat
data(format=prn,org=cols) 1948:1 1992:8 year month ip cli dfi xli sp fed tspread
*
set ipgr = 100.0*log(ip/ip{1})
*
* The graph in the paper appears to be standardized (probably by dividing through
* by 2.0 times the sample standard deviation).
*
graph(footer="Figure 1. Log Growth Rate of Monthly IP")
# ipgr
*
stats(noprint) ipgr * 1959:12
compute stdearly=sqrt(%variance)
stats(noprint) ipgr 1960:1 *
compute stdlate=sqrt(%variance)
*
set ipgradjust = %if(t<=1959:12,ipgr*stdlate/stdearly,ipgr)
*
set g = ipgradjust
*
* Transform the information variables
*
set cligr = 100.0*log(cli/cli{1})
set spgr = 100.0*log(sp/sp{1})
set xlidiff = xli-xli{1}
set ffdiff = fed-fed{1}
set tspdiff = tspread-tspread{1}
set dfismooth = dfi+2*dfi{1}+2*dfi{2}+dfi{3}
*
* And center them to zero means
*
dofor s = cligr spgr xlidiff ffdiff tspdiff dfismooth
diff(center) s
end dofor s
*******************************************************
*
* Common setup
*
compute nlags=4
*
source msvarsetup.src
compute gstart=1948:6,gend=1992:8
@MSVARSetup(lags=nlags)
# g
*********************************************************************
*
*
nonlin(parmset=common) mu phi sigma
*********************************************************************
*
* Time varying probabilities
*
dec equation p1eq p2eq
dec vector v1 v2
nonlin(parmset=tv) v1 v2
*********************************************************************
*
* This overrides the standard fixed definition
*
function %MSVARPmat time
type rect %MSVARPmat
type int time
*
local integer i j
local rect pexpand
local real z
*
compute p(1,1)=%(z=exp(%dot(%eqnxvector(p1eq,time),v1)),z/(1+z))
compute p(1,2)=%(z=exp(%dot(%eqnxvector(p2eq,time),v2)),1/(1+z))
compute %MSVARInitTransition()
*
if nexpand==nstates {
dim pexpand(nstates,nstates-1)
ewise pexpand(i,j)=%if(i==nstates,-1.0,i==j)
compute %MSVARPmat=pexpand*p
ewise %MSVARPmat(i,j)=%if(i==nstates,1.0+%MSVARPmat(i,j),%MSVARPmat(i,j))
}
else {
dim %MSVARPmat(nexpand,nexpand)
ewise %MSVARPmat(i,j)=MSVARTransProbs(MSVARTransLookup(i,j))
}
end
*********************************************************************
*
* Initialize the probabilities using only the intercepts
*
function TVPInit
type vector TVPInit
*
local rect a
local integer i j
*
compute p=||%logistic(v1(1),1.0),1-%logistic(v2(1),1.0)||
compute TVPInit=%MSVARInit()
end
*********************************************************************
frml logltvtp = %MSVARPMat(t),log(%MSVarProb(t))
*********************************************************************
*
* Define the logistic index for the transitions
*
equation p1eq *
# constant cligr{1}
equation p2eq *
# constant cligr{1}
*
* Standard guess values aiming to make state 1 the low growth state.
*
compute v1=log(.7/.3)~~0.0
compute v2=log(.95/.05)~~0.0
compute mu(1)=-1.7,mu(2)=.3
boxjenk(ar=nlags) g
compute phi=||%beta(1),%beta(2),%beta(3),%beta(4)||
compute sigma=%seesq
*
maximize(parmset=tv+common,start=(pstar=TVPInit()),$
method=bhhh,iters=20) logltvtp gstart gend