Hamilton Switching Model (new coding)

Discussion of models with structural breaks or endogenous switching.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Hamilton Switching Model (new coding)

Unread post by TomDoan »

This is the example of the Hamilton switching model from the RATS User's Guide, rewritten to use the MSVAR procedures. It requires the newest version of the MSVARSETUP file (http://www.estima.com/forum/viewtopic.php?f=7&t=512).

Code: Select all

*
* HAMILTON.PRG
* Hamilton Markov chain model for US GNP from page 697 of Hamilton,
* "Time Series Analysis"
*
cal(q) 1951:1
open data gnpdata.prn
data(format=prn,org=columns) 1951:1 1984:4
*
set g = 100*log(gnp/gnp{1})
graph(header="GNP growth")
# g
*
@msvarsetup(lags=4,switch=m)
# g
compute gstart=1952:2,gend=1984:4
frml msvarf = log(%MSVARProb(t))
*
nonlin(parmset=msparms) p
nonlin(parmset=varparms) mu phi sigma
@msvarinitial gstart gend
maximize(parmset=varparms+msparms,$
  start=(pstar=%MSVARInit()),$
  reject=%MSVARInitTransition()==0.0,$
  pmethod=simplex,piters=5,method=bfgs) msvarf gstart gend
@msvarsmoothed gstart gend psmooth
set pcontract gstart gend = psmooth(t)(2)
*
* To create the shading marking the recessions, create a dummy series
* which is 1 when the recessq series is 1, and 0 otherwise. (recessq is
* 1 for NBER recessions and -1 for expansions).
*
set contract = recessq==1
*
spgraph(vfields=2)
graph(header="Quarterly Growth Rate of US GNP",shade=contract)
# g %regstart() %regend()
graph(style=polygon,header="Probability of Economy Being in Contraction",shade=contract)
# pcontract %regstart() %regend()
spgraph(done)
sana
Posts: 14
Joined: Sat Jun 21, 2008 3:35 am

Re: Hamilton Switching Model (new coding)

Unread post by sana »

Hi Tom
I tried to run the program but I faced a problem.
The output indicates an error:

## SX16. Missing Operand or Adjacent Operators
>>>>pstar=MSVARInitial(<<<<

Please can you suggest me a solution?
Your help will be much appreciated
Thanks
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Hamilton Switching Model (new coding)

Unread post by TomDoan »

sana wrote:Hi Tom
I tried to run the program but I faced a problem.
The output indicates an error:

## SX16. Missing Operand or Adjacent Operators
>>>>pstar=MSVARInitial(<<<<

Please can you suggest me a solution?
Your help will be much appreciated
Thanks
Copy and paste out of the code segment above instead of trying to re-type everything. That line is supposed to read %MSVARInit() not MSVARInitial()
sana
Posts: 14
Joined: Sat Jun 21, 2008 3:35 am

Re: Hamilton Switching Model (new coding)

Unread post by sana »

Thank you for your prompt response. I tried again and here is the message:

## SX11. Identifier %MSVARPROB is Not Recognizable. Incorrect Option Field or Parameter Order?
>>>>f = log(%MSVARProb(<<<<
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Hamilton Switching Model (new coding)

Unread post by TomDoan »

If you read the original message, you need an updated MSVARSETUP.SRC file. You're using an older one. If you did download that, then it's not in the correct location to be read in automatically, so you would need do

source full path to new version of.../msvarsetup.src

before the @msvarsetup line. If you're still having problems, you should contact support@estima.com directly. Be sure you include your serial number and the version that you're using.
Post Reply