Hamilton Switching Model (new coding)

Discussion of models with structural breaks or endogenous switching.

Hamilton Switching Model (new coding)

Postby TomDoan » Thu Feb 25, 2010 6:01 pm

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)
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Hamilton Switching Model (new coding)

Postby sana » Tue Aug 09, 2011 7:11 am

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
sana
 
Posts: 14
Joined: Sat Jun 21, 2008 3:35 am
Location: tunisia

Re: Hamilton Switching Model (new coding)

Postby TomDoan » Tue Aug 09, 2011 8:01 am

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()
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Hamilton Switching Model (new coding)

Postby sana » Wed Aug 10, 2011 7:53 am

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(<<<<
sana
 
Posts: 14
Joined: Sat Jun 21, 2008 3:35 am
Location: tunisia

Re: Hamilton Switching Model (new coding)

Postby TomDoan » Wed Aug 10, 2011 11:04 am

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.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm


Return to Structural Breaks and Switching Models

Who is online

Users browsing this forum: No registered users and 1 guest