I am trying to us EM method to estimate follow codes. The error message says "## OP4. The Option DOM Is Already Set By This Instruction
>>>>omu,dovar,domustar)<<<<" I am not sure where the mistake is. Could you please kindly take a look at my codes? Thank you
Code: Select all
set dummy = t>=1983:01
dec vect mustar(2)
*******************************************************
*
* Common setup
*
compute nlags=4
*
source msvarsetup.src
compute gstart=1948:6,gend=1992:8
@MSVARSetup(lags=nlags)
# g
*********************************************************************
function %MSVARFVec time
type vect %MSVARFVec
type integer time
local integer i j state
local vect u
dim %MSVARFVec(nexpand)
do i=1, nexpand
com state=MSVARLagState(i,1)
com u=%xt(y,time)-mu(state)(1)-mustar(state)*dummy(time)
do j=1,nlags
com statej=MSVARLagState(i,j+1),$
u=u-phi(j)*(%xt(y,time-j)-mu(statej)(1)-mustar(statej)*dummy(time-j))
end do j
com state=MSVARLagState(i,1)
com %MSVARFVec(i)=exp(-.5*MSVARLogDetV(state)-.5*%qform(MSVARSigmaInv(state),u))
end do i
end
* Fixed probabilities
*
nonlin(parmset=common) mu phi sigma mustar
nonlin(parmset=fixed) p
*
frml msvarf = log(%MSVarProb(t))
*********************************************************************
@MSVARInitial gstart gend
@msvarEMgeneralsetup
*
* Guess values which make 1 the low growth state as in the paper.
*
compute mu(1)=-1.7,mu(2)=.3, mustar(1)=0.0, mustar(2)=0.0
compute p(1,1)=.3,p(1,2)=.1
*
* Estimate by the quicker EM algorithm
*
@msvartestvector(dop,domu,dovar,domustar) baseparms
do emits=1,50
@msvaremstep gstart gend
@msvartestvector(dop,domu,dovar,domustar) testparms
compute %cvcrit=%testdiff(baseparms,testparms)
if %cvcrit<.0001
break
compute baseparms=testparms
disp "Iteration" emits "Log Likelihood" %logl %cvcrit
end do emits
*
* Do five iterations with BHHH to get standard errors.
*
maximize(start=(pstar=%MSVARInit()),parmset=fixed+common,$
method=bhhh,iters=20) msvarf gstart gend