Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010)

Discussion of State Space and Dynamic Stochastic General Equilibrium Models
fan
Posts: 215
Joined: Wed Jun 19, 2013 5:14 pm

Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010

Unread post by fan »

TomDoan wrote:Next period's predicted states are this period's filtered states premultiplied by A. Since A is a diagonal matrix with constants (free parameters, but constant across time) on the diagonal, the ex-ante factors are (effectively) just last period's filtered factors.

Thank you so much for answering my questions. I did what you suggested but I found that my results are very different from the reported results, for instance my estimates are negative while the reported ones are positive. I am not sure what caused the difference here. Could you please kindly check my code? In addition, could you please give me a little tip about to perform Fama-Macbeth regression in this case using the estimated state factors?

Code: Select all

dec frml[rect] af
frml af = ||psi1,0.0,0.0|$
            0.0,psi2,0.0|$
            0.0,0.0,psi3|

set mkt1 1955:01 2004:12 = xstates(t)(1)
set size1 1955:01 2004:12 = xstates(t)(2)
set btm1 1955:01 2004:12 = xstates(t)(3)

set mkt0 = mkt1{1}*psi1
set size0 = size1{1}*psi2
set btm0 = btm1{1}*psi3

linreg r11
# constant mkt1 size1 btm1 mkt0 size0 btm0

Last edited by fan on Thu Oct 02, 2014 3:59 am, edited 1 time in total.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010

Unread post by TomDoan »

fan wrote:
TomDoan wrote:Next period's predicted states are this period's filtered states premultiplied by A. Since A is a diagonal matrix with constants (free parameters, but constant across time) on the diagonal, the ex-ante factors are (effectively) just last period's filtered factors.

Thank you so much. Could you please give me a little tip about to perform Fama-Macbeth regression in this case using the estimated state factors?
The estimated state factors become data, but I'm not sure how you would incorporate those into a Fama-Macbeth regression. You're generating one set of time series. In the first stage Fame-Macbeth regression, those are constant across returns, so you can't estimate anything useful.
fan
Posts: 215
Joined: Wed Jun 19, 2013 5:14 pm

Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010

Unread post by fan »

TomDoan wrote:
fan wrote:
TomDoan wrote:Next period's predicted states are this period's filtered states premultiplied by A. Since A is a diagonal matrix with constants (free parameters, but constant across time) on the diagonal, the ex-ante factors are (effectively) just last period's filtered factors.

Thank you so much. Could you please give me a little tip about to perform Fama-Macbeth regression in this case using the estimated state factors?
The estimated state factors become data, but I'm not sure how you would incorporate those into a Fama-Macbeth regression. You're generating one set of time series. In the first stage Fame-Macbeth regression, those are constant across returns, so you can't estimate anything useful.
Hi Tom, thank you for the reply. In the paper, the estimated factors are the new factors, similar to the fama-freach 3 factors. The authors first use the time-series regressions to obtain the factor exposures to the estimated factors and then use the cross-section regressions to obtain the factor risk premiums.

I studied the example code posted by you; I found the code is for panel data. What if the sample data are organized in time series format? What code we should use? Second the example code seems only for the cross-sectional regressions. Could you please advise us how to conduct the time series regressions in the first stage? Please, kindly correct me if my understanding is incorrect. And I am looking forward to hearing from you. Once again, thank you for your valuable advice.
Attachments
he's model.png
he's model.png (1.92 KiB) Viewed 61647 times
fan
Posts: 215
Joined: Wed Jun 19, 2013 5:14 pm

Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010

Unread post by fan »

TomDoan wrote:That's a relatively straightforward state-space model. How far have you gotten?
Hi Tom, following He's paper, I am trying to estimate the following model. By construction, the three proposed risk factors should be orthogonal to each other. But the correlation is among the three extracted factors is not close to zero, instead of being quite high, e.g. -0.51 for market return factor and change in investment opportunity set factor. I am not sure what caused this high correlation. Could you please kindly share your advice on what i might did wrong? Many Thanks

Code: Select all

OPEN DATA "C:\Users\Sam\Desktop\workdata2.xlsx"
CALENDAR(M) 1965:7
DATA(FORMAT=XLSX,ORG=COLUMNS,SHEET="ew") 1965:07 2010:12 default term term2 divyield senti adjsenti II $
SL SM SH BL BM BH pr11 pr12 pr13 pr14 pr15 pr21 pr22 pr23 pr24 pr25 pr31 pr32 pr33 pr34 pr35 pr41 pr42 $
pr43 pr44 pr45 pr51 pr52 pr53 pr54 pr55 m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 MktRF SMB HML RF demo yr34 crisis $
crisis2 crisis3 crisis4 reelection  crisis5

set tbill = rf
set yr12 = 1-yr34
set rep = 1-demo
set yr34re = yr34*reelection

set slrf = sl-tbill
set smrf = sm-tbill
set shrf = sh-tbill
set blrf = bl-tbill
set bmrf = bm-tbill
set bhrf = bh-tbill


set r11 = pr11-tbill
set r12 = pr12-tbill
set r13 = pr13-tbill
set r14 = pr14-tbill
set r15 = pr15-tbill
set r21 = pr21-tbill
set r22 = pr22-tbill
set r23 = pr23-tbill
set r24 = pr24-tbill
set r25 = pr25-tbill
set r31 = pr31-tbill
set r32 = pr32-tbill
set r33 = pr33-tbill
set r34 = pr34-tbill
set r35 = pr35-tbill
set r41 = pr41-tbill
set r42 = pr42-tbill
set r43 = pr43-tbill
set r44 = pr44-tbill
set r45 = pr45-tbill
set r51 = pr51-tbill
set r52 = pr52-tbill
set r53 = pr53-tbill
set r54 = pr54-tbill
set r55 = pr55-tbill


stats(noprint) slrf
compute slm=%mean
set sl1 = sl-slm

stats(noprint) smrf
compute smm=%mean
set sm1 = sm-smm

stats(noprint) shrf
compute shm=%mean
set sh1 = sh-shm

stats(noprint) blrf
compute blm=%mean
set bl1 = bl-blm

stats(noprint) bmrf
compute bmm=%mean
set bm1 = bm-bmm

stats(noprint) bhrf
compute bhm=%mean
set bh1 = bh-bhm

stats(noprint) term
compute termm=%mean
set term1 = term-termm


stats(noprint) default
compute defaultm=%mean
set default1 = default-defaultm


stats(noprint) divyield
compute divyieldm=%mean
set divyield1 = divyield-divyieldm


stats(noprint) tbill
compute tbillm=%mean
set tbill1 = tbill-tbillm


stats(noprint) mktrf
compute mktrfm=%mean
set mktrf1 = mktrf-mktrfm
stats(noprint) mktrf1
compute sigmktrf=%variance*0.5


stats(noprint) II
compute IIm=%mean
set II1 = II-IIm
stats(noprint) II1
compute sigII1=%variance*0.5

/*stats(noprint) senti
compute sentim=%mean
set  senti1 = senti-sentim
stats(noprint) senti1
compute sigsenti1=%variance*0.5 */

stats(noprint) adjsenti
compute adjsentim=%mean
set  adjsenti1 = adjsenti-adjsentim
stats(noprint) adjsenti1
compute sigadjsenti1=%variance*0.5


linreg(noprint) divyield1 / r1
#  mktrf1{1} divyield1{1} term1{1} default1{1} tbill1{1}
frml(lastreg,vector=x1) eq1
compute sigdiv=%seesq*0.5


linreg(noprint) term1  / r2
#  mktrf1{1} divyield1{1} term1{1} default1{1} tbill1{1}
frml(lastreg,vector=x2) eq2
compute sigterm=%seesq*0.5


linreg(noprint) default1  / r3
#  mktrf1{1} divyield1{1} term1{1} default1{1} tbill1{1}
frml(lastreg,vector=x3) eq3
compute sigdf=%seesq*0.5


linreg(noprint) tbill1 / r4
#  mktrf1{1} divyield1{1} term1{1} default1{1} tbill1{1}
frml(lastreg,vector=x4) eq4
compute sigtbill=%seesq*0.5

/*linreg(noprint) II1 / r5
#  mktrf1{1}
frml(lastreg,vector=x5) eq5
compute sigII1=%seesq*0.5

linreg(noprint) II1 / r6
#  mktrf1{1}
frml(lastreg,vector=x6) eq6
compute sigadjsenti1=%seesq*0.5 */


/*dofor i = sl1 to bh1
linreg i
# constant yr34
end fori
linreg mktrf1
#  constant yr34 */


nonlin x1 x2 x3 x4 $
       a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 $
       g0 g1 g2 g3 g4 g5 g6 $
       sigsl sigsm sigsh sigbl sigbm sigbh sigmktrf sigdiv sigterm sigdf sigtbill sigII1 sigadjsenti1 $
       psi1 psi2 psi3 dummy1 dummy2 dummy3

* dummy 4 (reelection)

dec frml[rect] cf
frml cf = ||a1,a4,a7,a10,a13,a16,g0,0.0,0.0,0.0,0.0,0.0,0.0|$
            a2,a5,a8,a11,a14,a17,0.0,g1,g2,g3,g4,0.0,0.0|$
            a3,a6,a9,a12,a15,a18,0.0,0.0,0.0,0.0,0.0,g5,g6||

linreg(noprint) sl1
# mktrf1 II1
compute a1=%beta(1),a3=%beta(2),sigsl=%seesq*0.5

linreg(noprint) sm1
# mktrf1 II1
compute a4=%beta(1),a6=%beta(2),sigsm=%seesq*0.5

linreg(noprint) sh1
# mktrf1 II1
compute a7=%beta(1),a9=%beta(2),sigsh=%seesq*0.5

linreg(noprint) bl1
# mktrf1 II1
compute a10=%beta(1),a12=%beta(2),sigbl=%seesq*0.5

linreg(noprint) bm1
# mktrf1 II1
compute a13=%beta(1),a15=%beta(2),sigbm=%seesq*0.5

linreg(noprint) bh1
# mktrf1 II1
compute a16=%beta(1),a18=%beta(2),sigbh=%seesq*0.5

dec frml[symm] svf
frml svf = %diag(||sigsl,sigsm,sigsh,sigbl,sigbm,sigbh,sigmktrf,sigdiv,sigterm,sigdf,sigtbill,sigadjsenti1,sigII1||)

dec frml[vect]  zf
frml zf = ||0.0,0.0,dummy1*yr34-psi3*dummy1*yr34{1}+dummy2*demo-psi3*dummy2*demo{1}+dummy3*crisis5-psi3*dummy3*crisis5{1}||
*frml zf = ||0.0,0.0,dummy1*yr34-psi3*dummy1*yr34{1}+dummy2*demo-psi3*dummy2*demo{1}+dummy3*crisis4-psi3*dummy3*crisis4{1}+dummy4*yr34re-psi3*dummy4*yr34re{1}||

dec frml[vect] muf
frml muf = ||0.0,0.0,0.0,0.0,0.0,0.0,0.0,eq1,eq2,eq3,eq4,0.0,0.0||
*frml muf = ||0.0,0.0,0.0,0.0,0.0,0.0,0.0,eq1,eq2,eq3,eq4,eq5,eq6||

dec frml[rect] af

frml af = ||psi1,0.0,0.0|$
            0.0,psi2,0.0|$
            0.0,0.0,psi3||

linreg(noprint) mktrf1
#  mktrf1{1}
compute psi1=%beta(1)

linreg(noprint) II1
#  II1{1} yr34  demo crisis5
compute psi3=%beta(1),dummy1=%beta(2),dummy2=%beta(3),dummy3=%beta(4)
*#  II1{1} yr34  demo crisis2 yr34re
*compute psi3=%beta(1),dummy1=%beta(2),dummy2=%beta(3),dummy3=%beta(4),dummy4=%beta(5)

compute [symm] swf =%diag(||1.0,1.0,1.0||)
compute [rect] f=%identity(3)


dlm(presample=ergodic,a=af,c=cf,z=zf,mu=muf,f=f,sv=svf,sw=swf,y=||sl1,sm1,sh1,bl1,bm1,bh1,mktrf1,divyield1,term1,default1,tbill1,adjsenti1,II1||,method=bfgs,type=filter,pmehod=simplex,piters=20,iters=100) / states

set mkt = states(t)(1)
set opp = states(t)(2)
set senti = states(t)(3)
@nbercycles(downs=recession)

SPGRAPH(HFIELDS=2,VFIELDS=2)
GRAPH(shade=recession,header="mkt")
# mkt
GRAPH(shade=recession,header="opp")
# opp
GRAPH(shade=recession,header="senti")
# senti
SPGRAPH(DONE)

stats mkt
stats opp
stats senti

graph(shade=recession)
# senti

cmom(corr,matrix=corr,print)
# mkt opp senti


/*
dec vect[series] betas(2)
dec series avgret
clear(zeros) betas avgret
compute port=0
dofor s = r11 to r55
linreg s
# constant mkt opp
compute port=port+1
compute %pt(betas,port,%xsubvec(%beta,2,3))
compute avgret(port)=%mean
end dofor s
linreg avgret 1 port
# betas

dec vect[series] betas(3)
dec series avgret
clear(zeros) betas avgret
compute port=0
dofor s = r11 to r55
linreg s
# constant mkt opp senti
compute port=port+1
compute %pt(betas,port,%xsubvec(%beta,2,4))
compute avgret(port)=%mean
end dofor s
linreg avgret 1 port
# betas

*/
graph
# senti

Attachments
workdata2.xlsx
sample data
(474.79 KiB) Downloaded 675 times
The measurement equation is given by.docx
my model
(17.75 KiB) Downloaded 670 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010

Unread post by TomDoan »

You already asked effectively the same question:

https://estima.com/forum/viewtopic.php?p=10118#p10118
fan
Posts: 215
Joined: Wed Jun 19, 2013 5:14 pm

Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010

Unread post by fan »

TomDoan wrote:You already asked effectively the same question:

https://estima.com/forum/viewtopic.php?p=10118#p10118

Sorry for the posting the same question again. Thank you for the quick reply
Post Reply