FamaMacBeth regression
Moderators: EViews Gareth, EViews Moderator, EViews Esther
Re: FamaMacBeth regression
Hi,
first of all, many thanks for sharing this great addin. It really helps a lot.
In the manual and in one of the previous posts you mentioned that the addin won't work if a series contains NAs. However, when applying Fama Macbeth at asset/individual equity level some assets do not consistently yield returns over the entire sample period. Is there any way to handle that issue besides excluding the entire series/individual equity?
Thanks
first of all, many thanks for sharing this great addin. It really helps a lot.
In the manual and in one of the previous posts you mentioned that the addin won't work if a series contains NAs. However, when applying Fama Macbeth at asset/individual equity level some assets do not consistently yield returns over the entire sample period. Is there any way to handle that issue besides excluding the entire series/individual equity?
Thanks

 EViews Developer
 Posts: 94
 Joined: Thu Apr 18, 2013 8:37 am
Re: FamaMacBeth regression
There are many ways to interpolate or extrapolate your data, depending on your situation.
If you only care about filling in your missing data and are not concerned with lookahead bias, EViews has several builtin interpolation/frequency conversion routines:
http://www.eviews.com/help/helpintro.ht ... .8.html%23
http://www.eviews.com/help/helpintro.ht ... 0.020.html
If you are concerned with lookahead bias, then a very simple solution is to extrapolate the last known data point. For example: 20 NA NA 23 becomes 20 20 20 23. This can be dangerous, however, if there is a long stretch of missing returns, so look at your data first before doing any interpolation and especially extrapolation.
If you only care about filling in your missing data and are not concerned with lookahead bias, EViews has several builtin interpolation/frequency conversion routines:
http://www.eviews.com/help/helpintro.ht ... .8.html%23
http://www.eviews.com/help/helpintro.ht ... 0.020.html
If you are concerned with lookahead bias, then a very simple solution is to extrapolate the last known data point. For example: 20 NA NA 23 becomes 20 20 20 23. This can be dangerous, however, if there is a long stretch of missing returns, so look at your data first before doing any interpolation and especially extrapolation.
Re: FamaMacBeth regression
hi,
1/this part of code in page 4 show just the first step in the spool object, how can show the equation object of betaeq01,betaeq02....etc and csavg (output for the first and second step in spool and equation object too), i have just to make analyse of residual.
to understand me i would like to show in the work file:
equation object for the first step
beta_summary (the spool)
equation object for the second step
result (the spool)
i have deleted some lines but i get many errors can you help me please
2/ this code in page 8 show all pr* with rmkt in one graph, how can make all this in the separate graphs with spool object?.
Kind Regards.
1/this part of code in page 4 show just the first step in the spool object, how can show the equation object of betaeq01,betaeq02....etc and csavg (output for the first and second step in spool and equation object too), i have just to make analyse of residual.
Code: Select all
' calculate betas from ts regressions of portfolio/asset returns on market returns
%subbeta_summary = @getnextname("beta_summary")
spool {%subbeta_summary}
matrix(!num_p, !num_f) {%subbhat}
for !i=1 to !num_p
equation {%subbetaeq}.ls {%subrets}(!i) c {%subfacs}
for !j=1 to !num_f
{%subbhat}(!i, !j) = @coefs(!j + 1)
next
{%subbeta_summary}.append {%subbetaeq}
close {%subbetaeq}
next
delete {%subbetaeq}
to understand me i would like to show in the work file:
equation object for the first step
beta_summary (the spool)
equation object for the second step
result (the spool)
i have deleted some lines but i get many errors can you help me please
2/ this code in page 8 show all pr* with rmkt in one graph, how can make all this in the separate graphs with spool object?.
Code: Select all
group g1 rmkt pr*
g1.scat linefit
Kind Regards.
 Attachments

 fit.png (27.89 KiB) Viewed 6261 times

 EViews Developer
 Posts: 94
 Joined: Thu Apr 18, 2013 8:37 am
Re: FamaMacBeth regression
1) The equation objects for the first step of the FamaMacBeth regression are stored in the beta_summary spool object. The second step of the regression does not use the equation object (see the 'fmb()' function).
2) What exactly are you trying to plot?
2) What exactly are you trying to plot?
Re: FamaMacBeth regression
1 got it, but how can get series avgrets;
2 run all graphs pr* on rmkt with regression line one at a time by simple code (pr11 with rmkt, pr12 with rmkt,....etc), and all this in the spool object (each graph appear separately in the spool).
2 run all graphs pr* on rmkt with regression line one at a time by simple code (pr11 with rmkt, pr12 with rmkt,....etc), and all this in the spool object (each graph appear separately in the spool).
 Attachments

 graph & spool.png (42.52 KiB) Viewed 6233 times

 EViews Developer
 Posts: 94
 Joined: Thu Apr 18, 2013 8:37 am
Re: FamaMacBeth regression
1) comment out the line in the program that deletes avgrets
2) put your graph command into a loop, and add the graphs to the spool one at a time
2) put your graph command into a loop, and add the graphs to the spool one at a time
Re: FamaMacBeth regression
1 no idea, can you guide me please;
2 i explain, i write a short code that generate regression one at a time, but with all graph pr* rmkt no idea:
i would like to make all regression equation and graph pr* on rmkt one at a time with a linefit, and put regression equation and his graph in the spool (each equation and his graph linefit), can you help me for this code .
i hope that you understand me now.
Best Regards.
2 i explain, i write a short code that generate regression one at a time, but with all graph pr* rmkt no idea:
Code: Select all
group g1 rmkt pr*
for !i=1 to 1
%iname=g1.@seriesname(!i)
for !j=!i+1 to g1.@count
%jname=g1.@seriesname(!j)
equation eq_{%iname}_{%jname}.ls {%jname} c {%iname}
graph {%iname}_{%jname}.scat {%linefit}
{%spool}.display
next
next
i would like to make all regression equation and graph pr* on rmkt one at a time with a linefit, and put regression equation and his graph in the spool (each equation and his graph linefit), can you help me for this code .
i hope that you understand me now.
Best Regards.
 Attachments

 eq_graph.png (64.61 KiB) Viewed 6195 times

 EViews Developer
 Posts: 94
 Joined: Thu Apr 18, 2013 8:37 am
Re: FamaMacBeth regression
1) Where is avgrets created? Can you locate this?
2) Write out the code to graph one of the plots you want.
2) Write out the code to graph one of the plots you want.
Re: FamaMacBeth regression
1do you mean this
can you guide me please.
2show all graph one at a time. pr11 & rmkt, pr12 & rmkt,...end so on (generate all graph by code).
group g1 rmkt pr11
g1.scat linefit
group g2 rmkt pr12
g2.scat linefit
..............etc
it take long time to do all this, are there a general code to do all this.
Code: Select all
mtos({%subavgretv}, avgrets)
equation {%subcsavg}.ls(cov=hac) avgrets c betag
can you guide me please.
2show all graph one at a time. pr11 & rmkt, pr12 & rmkt,...end so on (generate all graph by code).
group g1 rmkt pr11
g1.scat linefit
group g2 rmkt pr12
g2.scat linefit
..............etc
it take long time to do all this, are there a general code to do all this.

 EViews Developer
 Posts: 94
 Joined: Thu Apr 18, 2013 8:37 am
Re: FamaMacBeth regression
1) So avgrets is created from another variable. Where does this variable get deleted?
2) Read the For loop section in http://www.eviews.com/help/helpintro.ht ... 74.08.html
2) Read the For loop section in http://www.eviews.com/help/helpintro.ht ... 74.08.html
Re: FamaMacBeth regression
Hi,i run a fama macbeth regression in eviews using the addin (fama and
french (1993, 2015) models), it works for the three factor model or any
other combination of four factor model but it does not work for the five
factor model and i have an error message that says positive or non negative
argument function expected; can you please help me resolve this problem,
thanks a lot.
french (1993, 2015) models), it works for the three factor model or any
other combination of four factor model but it does not work for the five
factor model and i have an error message that says positive or non negative
argument function expected; can you please help me resolve this problem,
thanks a lot.

 EViews Developer
 Posts: 94
 Joined: Thu Apr 18, 2013 8:37 am
Re: FamaMacBeth regression
Can you post your workfile and what exactly you are doing that is not working?
Re: FamaMacBeth regression
This is how i did, first to import data i have delated the NA
With the add in Fama macbeth, i put the list of portfolios in the first row and the list of factors in the second one
For the 3 factor model (rmrf, smb hml) i have no problem and the results for gammas and betas are shown
For the five factor model (rmrf smb hml rmw cma) it does not work and i have this error message that says “ positive or nonnegative argument to function expected in “RESULTS01 APPEND CSAVG”.
With the add in Fama macbeth, i put the list of portfolios in the first row and the list of factors in the second one
For the 3 factor model (rmrf, smb hml) i have no problem and the results for gammas and betas are shown
For the five factor model (rmrf smb hml rmw cma) it does not work and i have this error message that says “ positive or nonnegative argument to function expected in “RESULTS01 APPEND CSAVG”.
 Attachments

 fama macbeth.docx
 (325.78 KiB) Downloaded 66 times

 EViews Developer
 Posts: 94
 Joined: Thu Apr 18, 2013 8:37 am
Re: FamaMacBeth regression
You will need to post the EViews workfile itself for me to help you.
Who is online
Users browsing this forum: Baidu [Spider] and 7 guests