I'm currently conducting a research on asymmetric influences Fama & French factors in dependence on the prevailing stock market regime. More precisely, I'm using a MSregression EM-setup to estimate the influence of the Fama & French 3-factor model on the S&P 500, EWRETD, VWRETD and the capitalization decile portfolios. The setup follows a four state Markov setup that allows changing coefficients in the mean equations and also changing variances. The Markov regime switching model is running smoothly and produces estimates in accordance to my expectations. The source looks as follows and is in line with the one presented in the course on regime switching models.
Code: Select all
OPEN DATA "E:\Dataset.xlsx"
DATA(FORMAT=XLSX,ORG=COLUMNS) 1 4819
*
*VWRETD Results on 3-Factor Model
*
*Robust OLS Regression
*
set g = VWRETD
LINREG(ROBUST,VCV) g / VWRETD_RESID
# Constant MKTRF SMB HML
*
*Regression 4-regimes EM on 3-Factor Model
*
@msregression(switch=ch,states=4) g
# Constant MKTRF SMB HML
nonlin(parmset=regparms) gammas betas sigsqv
nonlin(parmset=msparms) p
*
compute gstart=4,gend=4819
@MSRegInitial gstart gend
*
@MSRegEMGeneralSetup
do emits=1,50
@MSRegEMStep gstart gend
disp "Iteration" emits "Log Likelihood" %logl
end do emits
*
* Polish estimates with 10 BHHH iterations
*
compute p=%xsubmat(p,1,nstates-1,1,nstates)
nonlin(parmset=regparms) betas sigsqv
nonlin(parmset=msparms) p
frml logl = f=%MSRegFVec(t),fpt=%MSProb(t,f),log(fpt)
@MSFilterInit
maximize(start=%(%MSRegInitVariances(),pstar=%msinit()),$
parmset=regparms+msparms,$
method=bhhh,iters=10) logl gstart gend
*
set pregime1 gstart gend = psmooth(t)(1)
set pregime2 gstart gend = psmooth(t)(2)
set pregime3 gstart gend = psmooth(t)(3)
*
* Graph results
*
set contract = nber==1
spgraph(vfields=4)
graph(header="Daily VWRETD Return",shade=contract)
# g %regstart() %regend()
graph(style=polygon,header="Probability of Stock Market Being in State 1",shade=contract)
# pregime1 %regstart() %regend()
graph(style=polygon,header="Probability of Stock Market Being in State 2",shade=contract)
# pregime2 %regstart() %regend()
graph(style=polygon,header="Probability of Stock Market Being in State 3",shade=contract)
# pregime3 %regstart() %regend()
*
spgraph(done)
I hope that my problem has become clear.