Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010)
Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010
Hi Tom,
The paper I would like to replicate is He, Huh, and Lee (2010), "Dynamic Factors and Asset Pricing",Journal of Financial and Quantitative Analysis, Volume 45 / Issue 03 / June 2010, pp 707-737. Do you happen to have the codes for their paper? I am really interested in how to obtain the ex-ante factors in the paper by using Rats. Many Thanks!
The paper I would like to replicate is He, Huh, and Lee (2010), "Dynamic Factors and Asset Pricing",Journal of Financial and Quantitative Analysis, Volume 45 / Issue 03 / June 2010, pp 707-737. Do you happen to have the codes for their paper? I am really interested in how to obtain the ex-ante factors in the paper by using Rats. Many Thanks!
Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010
That's a relatively straightforward state-space model. How far have you gotten?
Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010
Hi Tom,TomDoan wrote:That's a relatively straightforward state-space model. How far have you gotten?
So far I think I can set the state space representation in Rats and impose the restrictions on the parameters. My problems now are that first, how I can assign the initial values for W_(sl,t) , W_(sm,t) ,W_(sh,t) and W_(bl,t) , W_(bm,t) ,W_(bh,t) .Second, I think the xstates command after the DLM command gives us the ex-post (updated) factors D_(t|t) only. I am wondering how to get the ex-ante (forecasted) factor D_(t|t-1). Please kindly correct me if I am wrong.
Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010
Why do you need "initial values" for the measurement errors? Are you talking about the variances of the measurement errors? The variances of the raw data would be reasonable for that.
DLM doesn't produce the ex ante states, but it's not clear it's needed. You can get the ex ante predictions of the observables (using YHAT), and that's what's actually used.
DLM doesn't produce the ex ante states, but it's not clear it's needed. You can get the ex ante predictions of the observables (using YHAT), and that's what's actually used.
Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010
Thank you, Tom. I have attached my own code here. Is it possible for you to take a quick look and let me know whether the code make sense to you? Have a nice weekend.TomDoan wrote:Why do you need "initial values" for the measurement errors? Are you talking about the variances of the measurement errors? The variances of the raw data would be reasonable for that.
DLM doesn't produce the ex ante states, but it's not clear it's needed. You can get the ex ante predictions of the observables (using YHAT), and that's what's actually used.
Code: Select all
nonlin beta11 beta12 beta13 beta21 beta22=beta12 beta23 beta31 beta32=beta12 beta33 $
beta41 beta42 beta43=beta13 beta51 beta52=beta42 beta53=beta23 beta61 beta62=beta42 beta63=beta33 $
sigsl sigsm sigsh sigbl sigbm sigbh psi1 psi2 psi3 $
dec frml[rect] cf
frml cf = ||beta11,beta12,beta13|$
beta21,beta22,beta23|$
beta31,beta32,beta33|$
beta41,beta42,beta43|$
beta51,beta52,beta53|$
beta61,beta62,beta63|$
inreg sl
# constant mktrf smb hml
compute beta11=%beta(2),beta12=%beta(3),beta13=%beta(4),sigsl=sqrt(%seesq)
linreg sm
# constant mktrf smb hml
compute beta21=%beta(2),beta22=%beta(3),beta23=%beta(4),sigsm=sqrt(%seesq)
linreg sh
# constant mktrf smb hml
compute beta31=%beta(2),beta32=%beta(3),beta33=%beta(4),sigsh=sqrt(%seesq)
linreg bl
# constant mktrf smb hml
compute beta41=%beta(2),beta42=%beta(3),beta43=%beta(4),sigbl=sqrt(%seesq)
linreg bm
# constant mktrf smb hml
compute beta51=%beta(2),beta52=%beta(3),beta53=%beta(4),sigbm=sqrt(%seesq)
linreg bh
# constant mktrf smb hml
compute beta61=%beta(2),beta62=%beta(3),beta63=%beta(4),sigbh=sqrt(%seesq)
dec frml[symm] svf
frml svf = %diag(||sigsl^2,sigsm^2,sigsh^2,sigbl^2,sigbm^2,sigbh^2||)
dec frml[rect] af
frml af = ||psi1,0.0,0.0|$
0.0,psi2,0.0|$
0.0,0.0,psi3|$
compute [symm] swf=||1.0,0.0,0.0|$
0.0,1.0,0.0|$
0.0,0.0,1.0||
compute [rect] f=%identity(3)
dlm(presample=ergodic,a=af,c=cf,f=f,sv=svf,sw=swf,y=||sl,sm,sh,bl,bm,bh||,method=bfgs,type=filter,yhat=yhat) / xstates
Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010
If you mean to have three independent factors, normalized to have unit innovation variances, identified using equality restrictions on the loadings, it looks like you have that correct. BTW, you don't need the F option if F is the identity.
Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010
Thank you so much for looking at my codeTomDoan wrote:If you mean to have three independent factors, normalized to have unit innovation variances, identified using equality restrictions on the loadings, it looks like you have that correct. BTW, you don't need the F option if F is the identity.
Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010
Hi Tom,
I am trying to replicate and extend their study. In my model, I am trying to identify 4 unobserved factors. The 4 factors are mkt, size , btm and sentiment. My dependent variables are returns on 6 size and BTM sorted portfolios (Rsl, Rsm, Rsh, Rbl, Rbm, Rbh). Following He, Huh and Lee (2010), in order to identify mkt , size and btm, I imposed the same restrictions as they did in the paper. I allowed Mkt to have different effects on the 6 portfolios but, size to have the same effect on portfolios from the same class, big or small class, and btm to have the identical effect on portfolios from the same class, high, medium or low class. In order to identify sentiment factor, I imposed gamma1 to be 1. All the unobserved factors are assumed to follow a AR(1) process and sentiment is affected by dummy variables (yr34 and demo) . However, the estimated results seem to suffer from no convergence issue as the program indicates no convergence in 100 iterations. My understanding is that the no convergence means that either the model specification is problematic or the initial values I assigned are problematic. After many tries, I am not sure what my problem is. My code is attached so you can see what I have done so far. Any suggestion from you are highly appreciated
I am trying to replicate and extend their study. In my model, I am trying to identify 4 unobserved factors. The 4 factors are mkt, size , btm and sentiment. My dependent variables are returns on 6 size and BTM sorted portfolios (Rsl, Rsm, Rsh, Rbl, Rbm, Rbh). Following He, Huh and Lee (2010), in order to identify mkt , size and btm, I imposed the same restrictions as they did in the paper. I allowed Mkt to have different effects on the 6 portfolios but, size to have the same effect on portfolios from the same class, big or small class, and btm to have the identical effect on portfolios from the same class, high, medium or low class. In order to identify sentiment factor, I imposed gamma1 to be 1. All the unobserved factors are assumed to follow a AR(1) process and sentiment is affected by dummy variables (yr34 and demo) . However, the estimated results seem to suffer from no convergence issue as the program indicates no convergence in 100 iterations. My understanding is that the no convergence means that either the model specification is problematic or the initial values I assigned are problematic. After many tries, I am not sure what my problem is. My code is attached so you can see what I have done so far. Any suggestion from you are highly appreciated
Code: Select all
nonlin beta1 beta2 beta3 beta4 beta5 beta6 $
beta7 beta8 beta9 beta7=beta8=beta9 $
beta10 beta11 beta12 beta10=beta11=beta12 $
beta13 beta14 beta15 beta16 beta17 beta18 beta13=beta16 beta14=beta17 beta15=beta18 $
alpha1 alpha2 alpha3 alpha4 alpha5 alpha6 alpha7 alpha8 alpha9 $
garma1=1.0 garma2 garma3 garma4 garma5 garma6 garma7 garma8 garma9 $
sigsl sigsm sigsh sigbl sigbm sigbh sigmktrf sigsmb sighml sigdi sigdf sigterm $
psi1 psi2 psi3 psi4 dummy1 dummy2 dummy2=-dummy1*psi4 dummy3 dummy4 dummy4=-dummy3*psi4 $
sigmkt sigsize sigbtm sigsenti
dec frml[rect] cf
frml cf = ||beta1,beta2,beta3,beta4,beta5,beta6,1.0,0.0,0.0,alpha1,alpha2,alpha3|$
beta7,beta8,beta9,beta10,beta11,beta12,0.0,1.0,0.0,alpha4,alpha5,alpha6|$
beta13,beta14,beta15,beta16,beta17,beta18,0.0,0.0,1.0,alpha7,alpha8,alpha9|$
garma1,garma2,garma3,garma4,garma5,garma6,garma7,garma8,garma9,0.0,0.0,0.0||
linreg sl
# constant mktrf smb hml sentindex
compute beta1=%beta(2),beta7=%beta(3),beta13=%beta(4),garma1=%beta(5),sigsl=sqrt(%seesq)
linreg sm
# constant mktrf smb hml sentindex
compute beta2=%beta(2),beta8=%beta(3),beta14=%beta(4),garma2=%beta(5),sigsm=sqrt(%seesq)
linreg sh
# constant mktrf smb hml sentindex
compute beta3=%beta(2),beta9=%beta(3),beta15=%beta(4),garma3=%beta(5),sigsh=sqrt(%seesq)
linreg bl
# constant mktrf smb hml sentindex
compute beta4=%beta(2),beta10=%beta(3),beta16=%beta(4),garma4=%beta(5),sigbl=sqrt(%seesq)
linreg bm
# constant mktrf smb hml sentindex
compute beta5=%beta(2),beta11=%beta(3),beta17=%beta(4),garma5=%beta(5),sigbm=sqrt(%seesq)
linreg bh
# constant mktrf smb hml sentindex
compute beta6=%beta(2),beta12=%beta(3),beta18=%beta(4),garma6=%beta(5),sigbh=sqrt(%seesq)
linreg mktrf
# constant sentindex
compute garma7=%beta(2),sigmktrf=(%seesq)
linreg smb
# constant sentindex
compute garma8=%beta(2),sigsmb=(%seesq)
linreg hml
# constant sentindex
compute garma9=%beta(2),sighml=(%seesq)
linreg dyield1
#constant mktrf smb hml sentindex
compute alpha1=%beta(2),alpha4=%beta(3),alpha7=%beta(4),sigdi=sqrt(%seesq)
linreg default
#constant mktrf smb hml sentindex
compute alpha2=%beta(2),alpha5=%beta(3),alpha8=%beta(4),sigdf=sqrt(%seesq)
linreg term
#constant mktrf smb hml sentindex
compute alpha3=%beta(2),alpha6=%beta(3),alpha9=%beta(4),sigterm=sqrt(%seesq)
dec frml[symm] svf
frml svf = %diag(||sigsl^2,sigsm^2,sigsh^2,sigbl^2,sigbm^2,sigbh^2,sigmktrf^2,sigsmb^2,sighml^2,sigdi^2,sigdf^2,sigterm^2||)
dec frml[vect] zf
frml zf = ||0.0,0.0,0.0,dummy1*yr34+dummy2*yr34{1}+dummy3*demo+dummy4*demo{1}||
dec frml[rect] af
frml af = ||psi1,0.0,0.0,0.0|$
0.0,psi2,0.0,0.0|$
0.0,0.0,psi3,0.0|$
0.0,0.0,0.0,psi4||
linreg mktrf
# constant mktrf{1}
compute psi1=%beta(2),sigmkt=sqrt(%seesq)
linreg smb
# constant smb{1}
compute psi2=%beta(2),sigsize=sqrt(%seesq)
linreg hml
# constant hml{1}
compute psi3=%beta(2),sigbtm=sqrt(%seesq)
linreg sentindex
# constant sentindex{1} yr34 demo
compute psi4=%beta(2),dummy1=%beta(3),dummy3=%beta(4),sigsenti=sqrt(%seesq)
dec frml[symm] swf
frml swf =%diag(||sigmkt^2,sigsize^2,sigbtm^2,sigsenti^2||)
compute [rect] f=%identity(4)
dlm(presample=ergodic,a=af,c=cf,z=zf,f=f,sv=svf,sw=swf,y=||sl,sm,sh,bl,bm,bh,Mktrf,SMB,HML,dyield,Default,Term||,method=bfgs,type=filter)
- Attachments
-
- model
- model.png (10.1 KiB) Viewed 19355 times
Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010
If it's simply not converging in 100 iterations, give it more. That's a fairly large parameter set.
Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010
Thank you for the reply. Can I ask one more question here? Commonly, we assume that the shocks to the states variables are orthogonal to each other. But if the shocks are correlated with each other. For example, it is not strange to assume that shock to investor sentiment can affect shocks to mkt, size and btm. Could you please kindly let me know how I can modify my swf in such case? Any advice is highly appreciatedTomDoan wrote:If it's simply not converging in 100 iterations, give it more. That's a fairly large parameter set.
Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010
Add a 4x4 SYMMETRIC (say SW) to the parameter set in place of the diagonal elements. The formula for SWF is then
FRML SWF = SW
However, if you're having problems with convergence already, you will really have problems if you allow the factors to be correlated. Your model is already putting rather tight restrictions on the behavior of the factors. If the factors are correlated, why would they be expected to be modeled by separate AR processes with no cross lag terms? The extension from what you have would really go a VAR, rather than a 4 x AR with correlated errors.
FRML SWF = SW
However, if you're having problems with convergence already, you will really have problems if you allow the factors to be correlated. Your model is already putting rather tight restrictions on the behavior of the factors. If the factors are correlated, why would they be expected to be modeled by separate AR processes with no cross lag terms? The extension from what you have would really go a VAR, rather than a 4 x AR with correlated errors.
Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010
Hi Tom,
I am sorry for asking question here again. It has been troubling me for two days. I am trying to replicate He, Huh and Lee’s (2010) study with almost identical data as they used for the paper. However, the parameter estimates I got are far away from the ones reported in the paper. For example, the estimated sigma is negative from my exercise. By definition, sigma is the square root of variance. It is really strange to see a negative sigma .I believe that if my estimation model is correct and the problem for getting the bad results is the initial values I assigned. I have tried different ways to give the initial values but I am no near to their results. Can I steal a few minutes from you? Could you please kindly take a quick look at my code and the way how I gave the initial values? Any advice from you will be highly appreciated.
I am sorry for asking question here again. It has been troubling me for two days. I am trying to replicate He, Huh and Lee’s (2010) study with almost identical data as they used for the paper. However, the parameter estimates I got are far away from the ones reported in the paper. For example, the estimated sigma is negative from my exercise. By definition, sigma is the square root of variance. It is really strange to see a negative sigma .I believe that if my estimation model is correct and the problem for getting the bad results is the initial values I assigned. I have tried different ways to give the initial values but I am no near to their results. Can I steal a few minutes from you? Could you please kindly take a quick look at my code and the way how I gave the initial values? Any advice from you will be highly appreciated.
Code: Select all
set sl = sl-rf
set sm = sm-rf
set sh = sh-rf
set bl = bl-rf
set bm = bm-rf
set bh = bh-rf
stats(noprint) sl
compute slm=%mean
stats(noprint) sm
compute smm=%mean
stats(noprint) sh
compute shm=%mean
stats(noprint) bl
compute blm=%mean
stats(noprint) bm
compute bmm=%mean
stats(noprint) bh
compute bhm=%mean
set sl1 = sl-slm
set sm1 = sm-smm
set sh1 = sh-shm
set bl1 = bl=blm
set bm1 = bm-bmm
set bh1 = bh-bhm
stats(noprint) mktrf
compute mktrfm=%mean
stats(noprint) smb
compute smbm=%mean
stats(noprint) hml
compute hmlm=%mean
set mktrf1 = mktrf-mktrfm
set smb1 = smb-smbm
set hml1 = hml-hmlm
nonlin beta11 beta12 beta13 beta21 beta22 beta22=beta12 beta23 beta31 beta32 beta32=beta12 beta33 $
beta41 beta42 beta43 beta43=beta13 beta51 beta52 beta52=beta42 beta53 beta53=beta23 beta61 beta62 beta62=beta42 beta63 beta63=beta33 $
sigsl sigsm sigsh sigbl sigbm sigbh psi1 psi2 psi3
dec frml[rect] cf
frml cf = ||beta11,beta21,beta31,beta41,beta51,beta61|$
beta12,beta22,beta32,beta42,beta52,beta62|$
beta13,beta23,beta33,beta43,beta53,beta63||
linreg sl1
# constant mktrf1 smb1 hml1
compute beta11=%beta(2),beta12=%beta(3),beta13=%beta(4),sigsl=sqrt(%seesq)
linreg sm1
# constant mktrf1 smb1 hml1
compute beta21=%beta(2),beta22=%beta(3),beta23=%beta(4),sigsm=sqrt(%seesq)
linreg sh1
# constant mktrf1 smb1 hml1
compute beta31=%beta(2),beta32=%beta(3),beta33=%beta(4),sigsh=sqrt(%seesq)
linreg bl1
# constant mktrf1 smb1 hml1
compute beta41=%beta(2),beta42=%beta(3),beta43=%beta(4),sigbl=sqrt(%seesq)
linreg bm1
# constant mktrf1 smb1 hml1
compute beta51=%beta(2),beta52=%beta(3),beta53=%beta(4),sigbm=sqrt(%seesq)
linreg bh1
# constant mktrf1 smb1 hml1
compute beta61=%beta(2),beta62=%beta(3),beta63=%beta(4),sigbh=sqrt(%seesq)
dec frml[symm] svf
frml svf = %diag(||sigsl^2,sigsm^2,sigsh^2,sigbl^2,sigbm^2,sigbh^2||)
dec frml[rect] af
frml af = ||psi1,0.0,0.0|$
0.0,psi2,0.0|$
0.0,0.0,psi3||
linreg mktrf1
# constant mktrf1{1}
compute psi1=%beta(2)
linreg smb1
# constant smb1{1}
compute psi2=%beta(2)
linreg hml1
# constant hml1{1}
compute psi3=%beta(2)
compute [symm] swf=||1.0,0.0,0.0|$
0.0,1.0,0.0|$
0.0,0.0,1.0||
compute [rect] f=%identity(3)
dlm(presample=ergodic,a=af,c=cf,f=f,sv=svf,sw=swf,y=||sl1,sm1,sh1,bl1,bm1,bh1||,method=bfgs,type=filter,yhat=yhat,iters=200,pmehod=simplex,piters=100) 1955:01 2004:12 xstates
Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010
If you square a parameter, its sign is arbitrary so don't worry about that.
You have an error here:
set bl1 = bl=blm
with an = rather than a - over on the right side.
Have you checked to see if the statistics on the raw data roughly match with theirs?
You have an error here:
set bl1 = bl=blm
with an = rather than a - over on the right side.
Have you checked to see if the statistics on the raw data roughly match with theirs?
Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010
Thank you for the reply. One of the contributions for the paper is that the authors are able to obtain the ex-ante factors and find that the ex-ante factors are key components in asset pricing and predicting. I understand that DML does not give ex-ante factors, I am wondering what I need to do in order to generate those ex-ante factors as the authors did in the paper. In addition, could you please let me know how I can preform the Fama-MacBeth (1973) two-pass cross sectional regression in Rats? Thank you.TomDoan wrote:If you square a parameter, its sign is arbitrary so don't worry about that.
You have an error here:
set bl1 = bl=blm
with an = rather than a - over on the right side.
Have you checked to see if the statistics on the raw data roughly match with theirs?
Re: Dynamic Factors and Asset Pricing (He,Huh, and Lee, 2010
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.