Markov model

Discussion of models with structural breaks or endogenous switching.
terrya
Posts: 41
Joined: Mon Aug 24, 2009 6:05 pm

Markov model

Unread post by terrya »

Is it possible to use RATS to estimate a model like the one on p 28 of the file below? If so how can the code be modified for the MSVar?
http://www.rbnz.govt.nz/research/bullet ... wallis.pdf
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Markov model

Unread post by TomDoan »

The MSVAR is quite a bit more complicated than necessary to deal with the effect of lagged states. The following general structure will work:

source markov.src
compute n=3
dec rect p(n-1,n)
dec vect f(n) pstar(n)
nonlin(parmset=markovparms) p
nonlin(parmset=regparms) .....
*
* initialize the p's and the regression parameters
*
frml markov = f=SimpleRegimeF(t),$
pstar=%msupdate(f,%mcstate(p,pstar),fpt),log(fpt)
maximize(parmset=markovparms+regparms,start=(pstar=%mcergodic(p))) markov start end

All you need is to write a function to do the likelihoods for each branch:

function simpleregimef time
type vector simpleregimef
type integer time
*
dim simpleregimef(3)
*
* instructions for computing likelihoods (not log likelihoods) of the three branches
* at entry <<time>>
*
end

See, for instance, the SWARCH example.
terrya
Posts: 41
Joined: Mon Aug 24, 2009 6:05 pm

Re: Markov model

Unread post by terrya »

Thanks
billmil
Posts: 5
Joined: Thu Mar 10, 2011 4:28 pm

Re: Markov model

Unread post by billmil »

Does anyone know about implementing the new Filardo procedure for estimating an MS model with time-varying probabilities? I have version 8 of RATS, and I follow all of the commands in Filardo, but I get an error message about missing operands. In particular, I do the following:
compute nlags=4
*
source msvarsetup.src
compute gstart=1948:6,gend=1992:8
@MSVARSetup(lags=nlags)
# g
dec equation p1eq p2eq
dec vector v1 v2
nonlin(parmset=tv) v1 v2
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
## SX16. Missing Operand or Adjacent Operators
>>>> ewise<<<<
I am not sure what I am doing wrong.
Thanks
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Markov model

Unread post by TomDoan »

You're missing the rest of that last EWISE instruction. If you have code that was sent through an e-mail, it might have wrapped the rest of the line down to the next line. It probably should be reading:

ewise %MSVARPmat(i,j)=%if(i==nstates,1.0+%MSVARPmat(i,j),%MSVARPmat(i,j))
Post Reply