This is the program file for Hui Guo's article "A Rational Princing Explaination for the Failure of the CAPM" in the May/June 2004 issue of the Federal Reserve Bank of St. Louis's Review. data.tsp is an EViews batch program that generates results of Table 1 and Figures 1 and 2. capm.prg is the GAUSS program for model I of Table 3. icapmhom.prg is the GAUSS program for model II of Table 3. icapmhet.prg is the GAUSS program for model III of Table 3 and Figure 3. icapmu.prg is the GAUSS program for model IV of Table 3. NOTE: GMM codes which are required to run the Gauss programs are available from http://www.american.edu/academic.depts/cas/econ/gaussres/GMM/GMM.HTM *----------------------------------------------------------------* * * * DATA.TSP * * * *Table 1, Figure 1, Figure 2 * *----------------------------------------------------------------* options crt; noprint; load; print; freq q; smpl 1952:4 2000:4; ?write(file=0405hgd.xls, format=excel) ret cay var rrel; smpl 1953:1 2000:4; olsq(hctype=0) ret c ret(-1) cay(-1) var(-1) rrel(-1); genr fitret=@fit; olsq(hctype=0) var c ret(-1) cay(-1) var(-1) rrel(-1); genr fitvar=@fit; ?write(file=fit.xls, format=excel) fitret fitvar; stop; end; *----------------------------------------------------------------* * * * CAPM.PRG * * * *----------------------------------------------------------------* @file: CAPM.PRG @ @GMM of conditional CAPM: model I in Table 3@ @sample period: 1953:1 - 2000:4, total 192 observations@ output file=CAPM.OUT reset; @ variables@ @RET E11 E12 E21 E22 E31 E32 RREL CAY VAR DEF TERM@ @ret is excess stock market return@ @rrel, cay, and var are forecasting variables@ @e11-e32 are 6 size and book/market ratio portfolios, not used in the article@ @def and term are additional forecasting variables, not used in the article@ @load data@ load x[]=ff6full.dat; xa=reshape(x,rows(x)/12,12); tt=rows(xa); x=xa[2:tt,.]; ret=x[.,1]; e1=x[.,2]; e2=x[.,3]; e3=x[.,4]; e4=x[.,5]; e5=x[.,6]; e6=x[.,7]; rrel=x[.,8]; cay=x[.,9]; var=x[.,10]; def=x[.,11]; term=x[.,12]; @one-period lag@ x=xa[1:(tt-1),.]; gret=x[.,1]; ge1=x[.,2]; ge2=x[.,3]; ge3=x[.,4]; ge4=x[.,5]; ge5=x[.,6]; ge6=x[.,7]; grrel=x[.,8]; gcay=x[.,9]; gvar=x[.,10]; gdef=x[.,11]; gterm=x[.,12]; rho=.98; @consumption/wealth@ t=rows(ret); @number of obs used in the paper@ @GMM specification@ tend=t; bgm=ones(21,1); nw=25; nzv=5|5|5|5|5; @nzv=nz(1)|..|nz(nw); nw by 1 vector For each i, nz(i) is # of elements in zi(t) i=1,..,nw.@ rwv=ones(25,1); @ rwv=rw(1)|..|rw(nw); nw by 1 vector rw(i) is defined so that wi(t) is in I(t+rw(i)) i=1,..,nw @ gradname=&GRAD2; @ Specify the name of proc that calculates the gradient dgT(b)/db. @ const=1/sqrt(tend); @ Scaling Multiplier when W0=eye(L) @ const2=1/sqrt(tend); @ Scaing Multiplier when W0 is not eye(L) @ @we should stick to w0flag=0 and maxitegm=2@ w0flag=1; @ scalar; If w0flag=0, W0=I is used as the initial weighing matrix W0. If w0flag=1, initial bgm is used to calculate initial W0. If w0flag=2, W0 in the memory is used as initial W0. If w0flag=3, W0 and bgm in the memory are used to give the first GMM result. @ maxitegm=500; @Sets maximum # of iteration over weighting matrix, W0. Set w0flag=0 and maxitegm=2 to execute usual 2-Stage GMM. @ zero=1E-2; @ Iteration over W0 continues until the maximum difference of the current and the previous W0 in absolute value becomes less than 'zero', or the # of iteration exceeds maxitegm. @ calwflag=4; @ This variable is used to choose the method to calculate the distance matrics, W0. If calwflag=0, Durbin's method will be used when W0 is singular. If calwflag=1, Newey and West Method will be used when W0 is singular. If calwflag=2, Parzen's lag window will be used when W0 is singular. If calwflag=3, Durbin's method will be used. If calwflag=4, Newey and West Method will be used. If calwflag=5, Parzen's lag window will be used. Durbin's method imposes zero restrictions while Newey and West method dose not. @ ordard=floor(sqrt(8190/sumc(nzv)^2)); @ Order of AR representation for Durbin's method when W0 is singular @ lend=4; @ Order of lags used for Newey and West method @ @ See MINQUAD.SET for the following globals @ hflag=2; dfpflag=1; sstol=1e-40;@25@ @ See MAXMUM.DOC on MODULE9 of GAUSS for the following globals @ gradtol=1e-5; btol=1e-5; typf=1; typb=1; @instrumental variables@ ziv=ones(t,1)~gret~gcay~gvar~grrel; @initialize parameters to the ols@ bgm[1:5]=(invpd(ziv'*ziv)*(ziv'*ret)); bgm[6:10]=(invpd(ziv'*ziv)*(ziv'*cay)); bgm[11:15]=(invpd(ziv'*ziv)*(ziv'*var)); bgm[16:20]=(invpd(ziv'*ziv)*(ziv'*rrel)); bgm[21]=10; @gam@ proc hu(b); local mu1, a11, a12, a13, a14; local mu2 ,a21 ,a22 ,a23 ,a24; local mu3 ,a31 ,a32, a33, a34; local mu4 ,a41, a42, a43, a44; local gam, mu; local aa; local l11, l12, l13, l14; local m11 , m12, m13, m14; local hmax; local res1, res2, res3, res4 ,res5; @local rho;@ gam=b[21]; res1=ret-ziv*b[1:5]; res2=cay-ziv*b[6:10]; res3=var-ziv*b[11:15]; res4=rrel-ziv*b[16:20]; res5=ret-gam*res1.*res1; retp((res1.*ziv)~(res2.*ziv)~(res3.*ziv)~(res4.*ziv)~(res5.*(ziv))); endp; proc (0)=prntrslt(x,s); ? " --------------- Minimization Results ---------------------- Step size: " s " Value of the objective function: " vof " Minimiser is" x' " -----------------------------------------------------------"; endp; output off; chi=gmmq(gradname,tend,nzv,rwv,nw,rows(bgm),zero,maxitegm); output on; loadm bgm,varb; se=sqrt(diag(varb)); format /rd 7,8; "gamma and t-value" bgm[21]'|(bgm[21]./sqrt(diag(varb[21, 21])))'; output off; *----------------------------------------------------------------* * * * ICAPMHOM.PRG * * * *----------------------------------------------------------------* @file: ICAPMHOM.PRG @ @ GMM of conditional Campbell ICAPM with homoskedastic returns: model II in Table 3@ @ sample period 1953:1 - 2000:4, total 192 observations@ output file=ICAPMHOM.out reset; @ variables@ @RET E11 E12 E21 E22 E31 E32 RREL CAY VAR DEF TERM@ @ret is excess stock market return@ @rrel, cay, and var are forecasting variables@ @e11-e32 are 6 size and book/market ratio portfolios, not used in the article@ @def and term are additional forecasting variables, not used in the article@ load x[]=ff6full.dat; xa=reshape(x,rows(x)/12,12); tt=rows(xa); x=xa[2:tt,.]; ret=x[.,1]; e1=x[.,2]; e2=x[.,3]; e3=x[.,4]; e4=x[.,5]; e5=x[.,6]; e6=x[.,7]; rrel=x[.,8]; cay=x[.,9]; var=x[.,10]; def=x[.,11]; term=x[.,12]; @one-period lag@ x=xa[1:(tt-1),.]; gret=x[.,1]; ge1=x[.,2]; ge2=x[.,3]; ge3=x[.,4]; ge4=x[.,5]; ge5=x[.,6]; ge6=x[.,7]; grrel=x[.,8]; gcay=x[.,9]; gvar=x[.,10]; gdef=x[.,11]; gterm=x[.,12]; rho=0.98; @consumption/wealth@ t=rows(ret); @number of obs used in the paper@ tend=t; bgm=ones(21,1); nw=25; nzv=5|5|5|5|5; @nzv=nz(1)|..|nz(nw); nw by 1 vector For each i, nz(i) is # of elements in zi(t) i=1,..,nw.@ rwv=ones(25,1); @ rwv=rw(1)|..|rw(nw); nw by 1 vector rw(i) is defined so that wi(t) is in I(t+rw(i)) i=1,..,nw @ gradname=&GRAD2; @ Specify the name of proc that calculates the gradient dgT(b)/db. @ const=1/sqrt(tend); @ Scaling Multiplier when W0=eye(L) @ const2=1/sqrt(tend); @ Scaing Multiplier when W0 is not eye(L) @ @we should stick to w0flag=0 and maxitegm=2@ w0flag=0; @ scalar; If w0flag=0, W0=I is used as the initial weighing matrix W0. If w0flag=1, initial bgm is used to calculate initial W0. If w0flag=2, W0 in the memory is used as initial W0. If w0flag=3, W0 and bgm in the memory are used to give the first GMM result. @ maxitegm=5; @Sets maximum # of iteration over weighting matrix, W0. Set w0flag=0 and maxitegm=2 to execute usual 2-Stage GMM. @ zero=1E-2; @ Iteration over W0 continues until the maximum difference of the current and the previous W0 in absolute value becomes less than 'zero', or the # of iteration exceeds maxitegm. @ calwflag=4; @ This variable is used to choose the method to calculate the distance matrics, W0. If calwflag=0, Durbin's method will be used when W0 is singular. If calwflag=1, Newey and West Method will be used when W0 is singular. If calwflag=2, Parzen's lag window will be used when W0 is singular. If calwflag=3, Durbin's method will be used. If calwflag=4, Newey and West Method will be used. If calwflag=5, Parzen's lag window will be used. Durbin's method imposes zero restrictions while Newey and West method dose not. @ ordard=floor(sqrt(8190/sumc(nzv)^2)); @ Order of AR representation for Durbin's method when W0 is singular @ lend=4; @ Order of lags used for Newey and West method @ @ See MINQUAD.SET for the following globals @ hflag=2; dfpflag=1; sstol=1e-40;@25@ @ See MAXMUM.DOC on MODULE9 of GAUSS for the following globals @ gradtol=1e-5; btol=1e-5; typf=1; typb=1; @instrumental variables@ ziv=ones(t,1)~gret~gcay~gvar~grrel; @initialize parameters to the ols@ bgm[1:5]=(invpd(ziv'*ziv)*(ziv'*ret)); bgm[6:10]=(invpd(ziv'*ziv)*(ziv'*cay)); bgm[11:15]=(invpd(ziv'*ziv)*(ziv'*var)); bgm[16:20]=(invpd(ziv'*ziv)*(ziv'*rrel)); bgm[21]=10; @gam@ proc hu(b); local mu1, a11, a12, a13, a14; local mu2 ,a21 ,a22 ,a23 ,a24; local mu3 ,a31 ,a32, a33, a34; local mu4 ,a41, a42, a43, a44; local gam; local aa; local l11, l12, l13, l14; local m11 , m12, m13, m14; local hmax; local res1, res2, res3, res4 ,res5; gam=b[21]; @rho=b[23];@ AA=(b[2:5])'|(b[7:10])'|(b[12:15])'|(b[17:20])'; hmax=rho*AA*inv(eye(4)-rho*AA); @coefficient of revision@ l11=hmax[1,1]; l12=hmax[1,2]; l13=hmax[1,3]; l14=hmax[1,4]; m11=hmax[3,1]; m12=hmax[3,2]; m13=hmax[3,3]; m14=hmax[3,4]; res1=ret-ziv*b[1:5]; res2=cay-ziv*b[6:10]; res3=var-ziv*b[11:15]; res4=rrel-ziv*b[16:20]; @mu in return@ res5=ret-gam*res1.*res1-(gam-1)*(l11*res1.*res1+l12*res1.*res2+l13*res1.*res3+l14*res1.*res4); @res5=ret-gam*var-(gam-1)*(l11*var+l12*res1.*res2+l13*res1.*res3+l14*res1.*res4);@ retp((res1.*ziv)~(res2.*ziv)~(res3.*ziv)~(res4.*ziv)~(res5.*(ziv))); endp; proc (0)=prntrslt(x,s); ? " --------------- Minimization Results ---------------------- Step size: " s " Value of the objective function: " vof " Minimiser is" x' " -----------------------------------------------------------"; endp; output off; chi=gmmq(gradname,tend,nzv,rwv,nw,rows(bgm),zero,maxitegm); output on; loadm bgm,varb; se=sqrt(diag(varb)); format /rd 7,8; @******************functions that calculate the price of risk***********************@ proc pp1(b); @market risk@ local gam; local mu; local AA; @acompany matrix of state variables@ local hmax; local l11, l12, l13, l14; @parameter associated with market risk@ local m11, m12, m13, m14; @parameter associated with other risk, i.e. labor income risk@ gam=b[21]; mu=0; AA=(b[2:5])'|(b[7:10])'|(b[12:15])'|(b[17:20])'; hmax=rho*AA*inv(eye(4)-rho*AA); l11=hmax[1,1]; l12=hmax[1,2]; l13=hmax[1,3]; l14=hmax[1,4]; m11=hmax[1,1]; m12=hmax[1,2]; m13=hmax[1,3]; m14=hmax[1,4]; retp(gam+(gam-1-mu)*l11); endp; @*****************@ proc pp2(b); @market risk@ local gam; local mu; local AA; @acompany matrix of state variables@ local hmax; local l11, l12, l13, l14; @parameter associated with market risk@ local m11, m12, m13, m14; @parameter associated with other risk, i.e. labor income risk@ gam=b[21]; mu=0; AA=(b[2:5])'|(b[7:10])'|(b[12:15])'|(b[17:20])'; hmax=rho*AA*inv(eye(4)-rho*AA); l11=hmax[1,1]; l12=hmax[1,2]; l13=hmax[1,3]; l14=hmax[1,4]; m11=hmax[1,1]; m12=hmax[1,2]; m13=hmax[1,3]; m14=hmax[1,4]; retp((gam-1-mu)*l12); endp; @*******************@ proc pp3(b); @market risk@ local gam; local mu; local AA; @acompany matrix of state variables@ local hmax; local l11, l12, l13, l14; @parameter associated with market risk@ local m11, m12, m13, m14; @parameter associated with other risk, i.e. labor income risk@ gam=b[21]; mu=0; AA=(b[2:5])'|(b[7:10])'|(b[12:15])'|(b[17:20])'; hmax=rho*AA*inv(eye(4)-rho*AA); l11=hmax[1,1]; l12=hmax[1,2]; l13=hmax[1,3]; l14=hmax[1,4]; m11=hmax[1,1]; m12=hmax[1,2]; m13=hmax[1,3]; m14=hmax[1,4]; retp((gam-1-mu)*l13); endp; @*******************@ proc pp4(b); @market risk@ local gam; local mu; local AA; @acompany matrix of state variables@ local hmax; local l11, l12, l13, l14; @parameter associated with market risk@ local m11, m12, m13, m14; @parameter associated with other risk, i.e. labor income risk@ gam=b[21]; mu=0; AA=(b[2:5])'|(b[7:10])'|(b[12:15])'|(b[17:20])'; hmax=rho*AA*inv(eye(4)-rho*AA); l11=hmax[1,1]; l12=hmax[1,2]; l13=hmax[1,3]; l14=hmax[1,4]; m11=hmax[1,1]; m12=hmax[1,2]; m13=hmax[1,3]; m14=hmax[1,4]; retp((gam-1-mu)*l14); endp; @***********************************************************************@ @*********************risk price and delta std***************@ se=sqrt(diag(varb)); p1=pp1(bgm); @price of market risk@ dp1=gradp(&pp1,bgm); @using delta method to calculate std, dp1 is the first difference@ stdp1= sqrt(dp1*varb*dp1'); @standard deviation@ p2=pp2(bgm); @price of market risk@ dp2=gradp(&pp2,bgm); @using delta method to calculate std, dp1 is the first difference@ stdp2= sqrt(dp2*varb*dp2'); @standard deviation@ p3=pp3(bgm); @price of market risk@ dp3=gradp(&pp3,bgm); @using delta method to calculate std, dp1 is the first difference@ stdp3= sqrt(dp3*varb*dp3'); @standard deviation@ p4=pp4(bgm); @price of market risk@ dp4=gradp(&pp4,bgm); @using delta method to calculate std, dp1 is the first difference@ stdp4= sqrt(dp4*varb*dp4'); @standard deviation@ @*************************************************************************@ output on; format /rd 7,8; "risk price and t-value" (p1~p2~p3~p4)|(p1~p2~p3~p4)./(stdp1~stdp2~stdp3~stdp4); "gama and t-value" bgm[21]'|(bgm[21]./sqrt(diag(varb[21, 21])))'; output off; *----------------------------------------------------------------* * * * ICAPMHET.PRG * * * *----------------------------------------------------------------* @file: ICAPMHET.PRG @ @ GMM of conditional Campbell ICAPM with heteroskedastic returns@ @ Model III of Table 3 and Figure 3@ @ sample period 1953:1 - 2000:4, total 192 observations@ output file=ICAPMHET.out reset; @ variables@ @RET E11 E12 E21 E22 E31 E32 RREL CAY VAR DEF TERM@ @ret is excess stock market return@ @rrel, cay, and var are forecasting variables@ @e11-e32 are 6 size and book/market ratio portfolios, not used in the article@ @def and term are additional forecasting variables, not used in the article@ load x[]=ff6full.dat; xa=reshape(x,rows(x)/12,12); tt=rows(xa); x=xa[2:tt,.]; ret=x[.,1]; e1=x[.,2]; e2=x[.,3]; e3=x[.,4]; e4=x[.,5]; e5=x[.,6]; e6=x[.,7]; rrel=x[.,8]; cay=x[.,9]; var=x[.,10]; def=x[.,11]; term=x[.,12]; @one-period lag@ x=xa[1:(tt-1),.]; gret=x[.,1]; ge1=x[.,2]; ge2=x[.,3]; ge3=x[.,4]; ge4=x[.,5]; ge5=x[.,6]; ge6=x[.,7]; grrel=x[.,8]; gcay=x[.,9]; gvar=x[.,10]; gdef=x[.,11]; gterm=x[.,12]; rho=.98; @consumption/wealth@ t=rows(ret); @number of obs used in the paper@ tend=t; bgm=ones(22,1); nw=25; nzv=5|5|5|5|5; @nzv=nz(1)|..|nz(nw); nw by 1 vector For each i, nz(i) is # of elements in zi(t) i=1,..,nw.@ rwv=ones(25,1); @ rwv=rw(1)|..|rw(nw); nw by 1 vector rw(i) is defined so that wi(t) is in I(t+rw(i)) i=1,..,nw @ gradname=&GRAD2; @ Specify the name of proc that calculates the gradient dgT(b)/db. @ const=1/sqrt(tend); @ Scaling Multiplier when W0=eye(L) @ const2=1/sqrt(tend); @ Scaing Multiplier when W0 is not eye(L) @ @we should stick to w0flag=0 and maxitegm=2@ w0flag=1; @ scalar; If w0flag=0, W0=I is used as the initial weighing matrix W0. If w0flag=1, initial bgm is used to calculate initial W0. If w0flag=2, W0 in the memory is used as initial W0. If w0flag=3, W0 and bgm in the memory are used to give the first GMM result. @ maxitegm=100; @Sets maximum # of iteration over weighting matrix, W0. Set w0flag=0 and maxitegm=2 to execute usual 2-Stage GMM. @ zero=1E-2; @ Iteration over W0 continues until the maximum difference of the current and the previous W0 in absolute value becomes less than 'zero', or the # of iteration exceeds maxitegm. @ calwflag=4; @ This variable is used to choose the method to calculate the distance matrics, W0. If calwflag=0, Durbin's method will be used when W0 is singular. If calwflag=1, Newey and West Method will be used when W0 is singular. If calwflag=2, Parzen's lag window will be used when W0 is singular. If calwflag=3, Durbin's method will be used. If calwflag=4, Newey and West Method will be used. If calwflag=5, Parzen's lag window will be used. Durbin's method imposes zero restrictions while Newey and West method dose not. @ ordard=floor(sqrt(8190/sumc(nzv)^2)); @ Order of AR representation for Durbin's method when W0 is singular @ lend=4; @ Order of lags used for Newey and West method @ @ See MINQUAD.SET for the following globals @ hflag=2; dfpflag=1; sstol=1e-40;@25@ @ See MAXMUM.DOC on MODULE9 of GAUSS for the following globals @ gradtol=1e-5; btol=1e-5; typf=1; typb=1; @instrumental variables@ ziv=ones(t,1)~gret~gcay~gvar~grrel; @initialize parameters to the ols@ bgm[1:5]=(invpd(ziv'*ziv)*(ziv'*ret)); bgm[6:10]=(invpd(ziv'*ziv)*(ziv'*cay)); bgm[11:15]=(invpd(ziv'*ziv)*(ziv'*var)); bgm[16:20]=(invpd(ziv'*ziv)*(ziv'*rrel)); bgm[21]=10; @gam@ bgm[22]=-10; proc hu(b); local mu1, a11, a12, a13, a14; local mu2 ,a21 ,a22 ,a23 ,a24; local mu3 ,a31 ,a32, a33, a34; local mu4 ,a41, a42, a43, a44; local gam, mu; local aa; local l11, l12, l13, l14; local m11 , m12, m13, m14; local hmax; local res1, res2, res3, res4 ,res5; @local rho;@ gam=b[21]; mu=b[22]; @rho=b[23];@ AA=(b[2:5])'|(b[7:10])'|(b[12:15])'|(b[17:20])'; hmax=rho*AA*inv(eye(4)-rho*AA); @coefficient of revision@ l11=hmax[1,1]; l12=hmax[1,2]; l13=hmax[1,3]; l14=hmax[1,4]; m11=hmax[3,1]; m12=hmax[3,2]; m13=hmax[3,3]; m14=hmax[3,4]; res1=ret-ziv*b[1:5]; res2=cay-ziv*b[6:10]; res3=var-ziv*b[11:15]; res4=rrel-ziv*b[16:20]; @mu in return@ res5=ret-gam*res1.*res1-(gam-1-mu)*(l11*res1.*res1+l12*res1.*res2+l13*res1.*res3+l14*res1.*res4); @res5=ret-gam*var-(gam-1-mu)*(l11*var+l12*res1.*res2+l13*res1.*res3+l14*res1.*res4);@ @mu in variance@ @res5=ret-gam*res1.*res1-(gam-1)*(l11*res1.*res1+l12*res1.*res2+l13*res1.*res3+l14*res1.*res4) +mu*(m11*res1.*res1+m12*res1.*res2+m13*res1.*res3+m14*res1.*res4) ;@ retp((res1.*ziv)~(res2.*ziv)~(res3.*ziv)~(res4.*ziv)~(res5.*(ziv))); endp; proc (0)=prntrslt(x,s); ? " --------------- Minimization Results ---------------------- Step size: " s " Value of the objective function: " vof " Minimiser is" x' " -----------------------------------------------------------"; endp; output off; chi=gmmq(gradname,tend,nzv,rwv,nw,rows(bgm),zero,maxitegm); output on; loadm bgm,varb; se=sqrt(diag(varb)); format /rd 7,8; @******************functions that calculate the price of risk***********************@ proc pp1(b); @market risk@ local gam; local mu; local AA; @acompany matrix of state variables@ local hmax; local l11, l12, l13, l14; @parameter associated with market risk@ local m11, m12, m13, m14; @parameter associated with other risk, i.e. labor income risk@ gam=b[21]; mu=b[22]; AA=(b[2:5])'|(b[7:10])'|(b[12:15])'|(b[17:20])'; hmax=rho*AA*inv(eye(4)-rho*AA); l11=hmax[1,1]; l12=hmax[1,2]; l13=hmax[1,3]; l14=hmax[1,4]; m11=hmax[1,1]; m12=hmax[1,2]; m13=hmax[1,3]; m14=hmax[1,4]; retp(gam+(gam-1-mu)*l11); endp; @*****************@ proc pp2(b); @market risk@ local gam; local mu; local AA; @acompany matrix of state variables@ local hmax; local l11, l12, l13, l14; @parameter associated with market risk@ local m11, m12, m13, m14; @parameter associated with other risk, i.e. labor income risk@ gam=b[21]; mu=b[22]; AA=(b[2:5])'|(b[7:10])'|(b[12:15])'|(b[17:20])'; hmax=rho*AA*inv(eye(4)-rho*AA); l11=hmax[1,1]; l12=hmax[1,2]; l13=hmax[1,3]; l14=hmax[1,4]; m11=hmax[1,1]; m12=hmax[1,2]; m13=hmax[1,3]; m14=hmax[1,4]; retp((gam-1-mu)*l12); endp; @*******************@ proc pp3(b); @market risk@ local gam; local mu; local AA; @acompany matrix of state variables@ local hmax; local l11, l12, l13, l14; @parameter associated with market risk@ local m11, m12, m13, m14; @parameter associated with other risk, i.e. labor income risk@ gam=b[21]; mu=b[22]; AA=(b[2:5])'|(b[7:10])'|(b[12:15])'|(b[17:20])'; hmax=rho*AA*inv(eye(4)-rho*AA); l11=hmax[1,1]; l12=hmax[1,2]; l13=hmax[1,3]; l14=hmax[1,4]; m11=hmax[1,1]; m12=hmax[1,2]; m13=hmax[1,3]; m14=hmax[1,4]; retp((gam-1-mu)*l13); endp; @*******************@ proc pp4(b); @market risk@ local gam; local mu; local AA; @acompany matrix of state variables@ local hmax; local l11, l12, l13, l14; @parameter associated with market risk@ local m11, m12, m13, m14; @parameter associated with other risk, i.e. labor income risk@ gam=b[21]; mu=b[22]; AA=(b[2:5])'|(b[7:10])'|(b[12:15])'|(b[17:20])'; hmax=rho*AA*inv(eye(4)-rho*AA); l11=hmax[1,1]; l12=hmax[1,2]; l13=hmax[1,3]; l14=hmax[1,4]; m11=hmax[1,1]; m12=hmax[1,2]; m13=hmax[1,3]; m14=hmax[1,4]; retp((gam-1-mu)*l14); endp; @***********************************************************************@ @*********************risk price and delta std***************@ se=sqrt(diag(varb)); p1=pp1(bgm); @price of market risk@ dp1=gradp(&pp1,bgm); @using delta method to calculate std, dp1 is the first difference@ stdp1= sqrt(dp1*varb*dp1'); @standard deviation@ p2=pp2(bgm); @price of market risk@ dp2=gradp(&pp2,bgm); @using delta method to calculate std, dp1 is the first difference@ stdp2= sqrt(dp2*varb*dp2'); @standard deviation@ p3=pp3(bgm); @price of market risk@ dp3=gradp(&pp3,bgm); @using delta method to calculate std, dp1 is the first difference@ stdp3= sqrt(dp3*varb*dp3'); @standard deviation@ p4=pp4(bgm); @price of market risk@ dp4=gradp(&pp4,bgm); @using delta method to calculate std, dp1 is the first difference@ stdp4= sqrt(dp4*varb*dp4'); @standard deviation@ @*************************************************************************@ output on; format /rd 7,8; "risk price and t-value" (p1~p2~p3~p4)|(p1~p2~p3~p4)./(stdp1~stdp2~stdp3~stdp4); "gamma and t-value" bgm[21:22]'|(bgm[21:22]./sqrt(diag(varb[21:22, 21:22])))'; output off; @*************calculate the components of returns******************@ b=bgm; @state variable block@ resa=ret-ziv*b[1:5]; resb=cay-ziv*b[6:10]; resc=var-ziv*b[11:15]; resd=rrel-ziv*b[16:20]; @conditonal returns@ re1=resa; mer=ret; mshock=re1; @factor loadings@ count=1; fdmax=zeros(1,7); decom=zeros(tend,7); do while count<=1; fdmax[count,1]=meanc(mer[.,count]); fdmax[count,2]=.5*meanc(mshock[.,count].*mshock[.,count])+fdmax[count,1]; fdmax[count,3]=p1*meanc(mshock[.,count].*resa); fdmax[count,4]=p2*meanc(mshock[.,count].*resb); fdmax[count,5]=p3*meanc(mshock[.,count].*resc); fdmax[count,6]=p4*meanc(mshock[.,count].*resd); fdmax[count,7]=fdmax[count,2]-fdmax[count,3]-fdmax[count,4]-fdmax[count,5]-fdmax[count,6]; decom[.,1]=ret; decom[.,2]=.5*(mshock[.,count].*mshock[.,count])+decom[.,1]; decom[.,3]=p1*(mshock[.,count].*resa); decom[.,4]=p2*(mshock[.,count].*resb); decom[.,5]=p3*(mshock[.,count].*resc); decom[.,6]=p4*(mshock[.,count].*resd); decom[.,7]=decom[.,2]-decom[.,3]-decom[.,4]-decom[.,5]-decom[.,6]; count=count+1; endo; @decom;@ "stock market return decomposition"; fdmax[2:7]; *----------------------------------------------------------------* * * * ICAPMU.PRG * * * *----------------------------------------------------------------* @file: ICAPMU.PRG @ @ GMM of unrestricted conditional Campbell ICAPM, model IV of Table 3@ @ sample period: 1952:4 - 2000:4, total 193 observations@ output file=ICAPMU.out reset; @ variables@ @RET E11 E12 E21 E22 E31 E32 RREL CAY VAR DEF TERM@ @ret is excess stock market return@ @rrel, cay, and var are forecasting variables@ @e11-e32 are 6 size and book/market ratio portfolios, not used in the article@ @def and term are additional forecasting variables, not used in the article@ load x[]=ff6full.dat; xa=reshape(x,rows(x)/12,12); tt=rows(xa); x=xa[2:tt,.]; ret=x[.,1]; e1=x[.,2]; e2=x[.,3]; e3=x[.,4]; e4=x[.,5]; e5=x[.,6]; e6=x[.,7]; rrel=x[.,8]; cay=x[.,9]; var=x[.,10]; def=x[.,11]; term=x[.,12]; @one-period lag@ x=xa[1:(tt-1),.]; gret=x[.,1]; ge1=x[.,2]; ge2=x[.,3]; ge3=x[.,4]; ge4=x[.,5]; ge5=x[.,6]; ge6=x[.,7]; grrel=x[.,8]; gcay=x[.,9]; gvar=x[.,10]; gdef=x[.,11]; gterm=x[.,12]; rho=0.98; @consumption/wealth@ t=rows(ret); @number of obs used in the paper@ tend=t; bgm=ones(24,1); nw=25; nzv=ones(5,1)*5; @nzv=nz(1)|..|nz(nw); nw by 1 vector For each i, nz(i) is # of elements in zi(t) i=1,..,nw.@ rwv=ones(25,1); @ rwv=rw(1)|..|rw(nw); nw by 1 vector rw(i) is defined so that wi(t) is in I(t+rw(i)) i=1,..,nw @ gradname=&GRAD2; @ Specify the name of proc that calculates the gradient dgT(b)/db. @ const=1/sqrt(tend); @ Scaling Multiplier when W0=eye(L) @ const2=1/sqrt(tend); @ Scaing Multiplier when W0 is not eye(L) @ @we should stick to w0flag=0 and maxitegm=2@ w0flag=0; @ scalar; If w0flag=0, W0=I is used as the initial weighing matrix W0. If w0flag=1, initial bgm is used to calculate initial W0. If w0flag=2, W0 in the memory is used as initial W0. If w0flag=3, W0 and bgm in the memory are used to give the first GMM result. @ maxitegm=100; @Sets maximum # of iteration over weighting matrix, W0. Set w0flag=0 and maxitegm=2 to execute usual 2-Stage GMM. @ zero=1E-2; @ Iteration over W0 continues until the maximum difference of the current and the previous W0 in absolute value becomes less than 'zero', or the # of iteration exceeds maxitegm. @ calwflag=4; @ This variable is used to choose the method to calculate the distance matrics, W0. If calwflag=0, Durbin's method will be used when W0 is singular. If calwflag=1, Newey and West Method will be used when W0 is singular. If calwflag=2, Parzen's lag window will be used when W0 is singular. If calwflag=3, Durbin's method will be used. If calwflag=4, Newey and West Method will be used. If calwflag=5, Parzen's lag window will be used. Durbin's method imposes zero restrictions while Newey and West method dose not. @ ordard=floor(sqrt(8190/sumc(nzv)^2)); @ Order of AR representation for Durbin's method when W0 is singular @ lend=4; @ Order of lags used for Newey and West method @ @ See MINQUAD.SET for the following globals @ hflag=2; dfpflag=1; sstol=1e-40;@25@ @ See MAXMUM.DOC on MODULE9 of GAUSS for the following globals @ gradtol=1e-5; btol=1e-5; typf=1; typb=1; @instrumental variables@ ziv=ones(t,1)~gret~gcay~gvar~grrel; @initialize parameters to the ols@ bgm[1:5]=(invpd(ziv'*ziv)*(ziv'*ret)); bgm[6:10]=(invpd(ziv'*ziv)*(ziv'*cay)); bgm[11:15]=(invpd(ziv'*ziv)*(ziv'*var)); bgm[16:20]=(invpd(ziv'*ziv)*(ziv'*rrel)); bgm[21]=10; @gam@ proc hu(b); local mu1, a11, a12, a13, a14; local mu2 ,a21 ,a22 ,a23 ,a24; local mu3 ,a31 ,a32, a33, a34; local mu4 ,a41, a42, a43, a44; local p1, p2, p3, p4; local res1, res2, res3, res4 ,res5; p1=b[21]; p2=b[22]; p3=b[23]; p4=b[24]; res1=ret-ziv*b[1:5]; res2=cay-ziv*b[6:10]; res3=var-ziv*b[11:15]; res4=rrel-ziv*b[16:20]; @mu in return@ res5=ziv*b[1:5]-p1*res1.*res1-p2*res1.*res2-p3*res1.*res3-p4*res1.*res4; retp((res1.*ziv)~(res2.*ziv)~(res3.*ziv)~(res4.*ziv)~(res5.*ziv)); endp; proc (0)=prntrslt(x,s); ? " --------------- Minimization Results ---------------------- Step size: " s " Value of the objective function: " vof " Minimiser is" x' " -----------------------------------------------------------"; endp; output off; chi=gmmq(gradname,tend,nzv,rwv,nw,rows(bgm),zero,maxitegm); output on; loadm bgm,varb; se=sqrt(diag(varb)); format /rd 7,8; @"gam" bgm[51]~sq[51];@ "param and t-value" bgm[21:24]'|(bgm[21:24]./sqrt(diag(varb[21:24, 21:24])))'; output off;