Question about guess values in MS models
Posted: Sat Mar 26, 2016 7:07 pm
Hi Tom, could you please kindly help me understand the code in example KIMNP082.RPF?
In addition, could you please kindly share with us how to get the guess values, such as for means and variances, in MS models?
Thank you and Happy Easter
Code: Select all
compute temp=mu(3), mu(3)=mu(1),mu(1)=tempCode: Select all
*
* KIMNP082.RPF
* 4.5 Application 2 from pp 82-86 of Kim and Nelson, "State-space Models
* with Regime Switching"
*
* MS AR model with switches in mean and variance.
*
open data int_cpuq.prn
calendar(q) 1947:1
data(format=free,org=columns) 1947:01 1990:04 qtr tbill cpu
*
set infl = log(cpu/cpu{1})*400.0
*
set rrate = tbill-infl
*
boxjenk(ar=4,constant) rrate 1960:1 *
*
@msvarsetup(lags=2,states=3,switch=mh)
# rrate
*
compute gstart=1960:1,gend=1990:4
frml msvarf = log(%MSVARProb(t))
*
nonlin(parmset=msparms) theta
nonlin(parmset=varparms) mu phi sigmav
@msvarinitial gstart gend
*
* Switch around the mu's to match up with the states in the book.
*
compute temp=mu(3),mu(3)=mu(1),mu(1)=temp
*
* Estimate the model by maximum likelihood. This effectively converges,
* but because some of the theta's are very large negative (producing
* transition probabilities which are nearly zero), the convergence
* tests fail because the transition probabilities are extremely flat in
* that neighborhood.
*
maximize(parmset=varparms+msparms,$
start=%(p=%mslogisticp(theta),pstar=%MSVARInit()),$
reject=%MSVARInitTransition()==0,$
pmethod=simplex,piters=5,method=bfgs,iters=300) msvarf gstart gend
*
* This pegs the two parameters that are pushed to -infinity as large
* fixed negative values.
*
nonlin(parmset=pegs) theta(1,2)=-50.00 theta(2,3)=-50.00
maximize(parmset=varparms+msparms+pegs,$
start=%(p=%mslogisticp(theta),pstar=%MSVARInit()),$
reject=%MSVARInitTransition()==0,$
method=bfgs,iters=300) msvarf gstart gend
Thank you and Happy Easter