Fama-MacBeth regression

For questions about EViews Add-ins available from the EViews Add-ins webpage. Note each add-in available on our webpage will have its own individual thread.

Moderators: EViews Gareth, EViews Moderator, EViews Esther

JasonR
Posts: 1
Joined: Sun Oct 18, 2015 3:08 pm

Re: Fama-MacBeth regression

Postby JasonR » Sun Oct 18, 2015 3:23 pm

Hi,

first of all, many thanks for sharing this great add-in. It really helps a lot.

In the manual and in one of the previous posts you mentioned that the add-in 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 Rebecca
EViews Developer
Posts: 113
Joined: Thu Apr 18, 2013 8:37 am

Re: Fama-MacBeth regression

Postby EViews Rebecca » Mon Oct 19, 2015 10:44 am

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 look-ahead bias, EViews has several built-in 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 look-ahead 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.

ecofin
Posts: 182
Joined: Fri May 10, 2013 11:24 am

Re: Fama-MacBeth regression

Postby ecofin » Thu Jan 28, 2016 7:20 am

hi,
1/this part of code in page 4 show just the first step in the spool object, how can show the equation object :equation: of betaeq01,betaeq02....etc and csavg (output for the first and second step in spool and equation object :equation: 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 :roll: 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
fit.png (27.89 KiB) Viewed 22207 times

EViews Rebecca
EViews Developer
Posts: 113
Joined: Thu Apr 18, 2013 8:37 am

Re: Fama-MacBeth regression

Postby EViews Rebecca » Thu Jan 28, 2016 12:37 pm

1) The equation objects for the first step of the Fama-MacBeth 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?

ecofin
Posts: 182
Joined: Fri May 10, 2013 11:24 am

Re: Fama-MacBeth regression

Postby ecofin » Sat Jan 30, 2016 11:47 am

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).
Attachments
graph & spool.png
graph & spool.png (42.52 KiB) Viewed 22179 times

EViews Rebecca
EViews Developer
Posts: 113
Joined: Thu Apr 18, 2013 8:37 am

Re: Fama-MacBeth regression

Postby EViews Rebecca » Mon Feb 01, 2016 4:19 pm

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

ecofin
Posts: 182
Joined: Fri May 10, 2013 11:24 am

Re: Fama-MacBeth regression

Postby ecofin » Wed Feb 03, 2016 6:39 am

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:

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 :roll: .
i hope that you understand me now.
Best Regards.
Attachments
eq_graph.png
eq_graph.png (64.61 KiB) Viewed 22141 times

EViews Rebecca
EViews Developer
Posts: 113
Joined: Thu Apr 18, 2013 8:37 am

Re: Fama-MacBeth regression

Postby EViews Rebecca » Wed Feb 03, 2016 11:33 am

1) Where is avgrets created? Can you locate this?
2) Write out the code to graph one of the plots you want.

ecofin
Posts: 182
Joined: Fri May 10, 2013 11:24 am

Re: Fama-MacBeth regression

Postby ecofin » Wed Feb 03, 2016 12:45 pm

1-do you mean this

Code: Select all

mtos({%subavgretv}, avgrets)
equation {%subcsavg}.ls(cov=hac) avgrets c betag

can you guide me please. :oops:
2-show 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 Rebecca
EViews Developer
Posts: 113
Joined: Thu Apr 18, 2013 8:37 am

Re: Fama-MacBeth regression

Postby EViews Rebecca » Thu Feb 04, 2016 11:21 am

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

ecofin
Posts: 182
Joined: Fri May 10, 2013 11:24 am

Re: Fama-MacBeth regression

Postby ecofin » Tue Feb 09, 2016 12:23 pm

1- :D
2- ok!

tataa
Posts: 3
Joined: Tue Feb 28, 2017 3:12 am

Re: Fama-MacBeth regression

Postby tataa » Wed Mar 01, 2017 8:42 am

Hi,i run a fama macbeth regression in eviews using the add-in (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.

EViews Rebecca
EViews Developer
Posts: 113
Joined: Thu Apr 18, 2013 8:37 am

Re: Fama-MacBeth regression

Postby EViews Rebecca » Wed Mar 01, 2017 11:41 am

Can you post your workfile and what exactly you are doing that is not working?

tataa
Posts: 3
Joined: Tue Feb 28, 2017 3:12 am

Re: Fama-MacBeth regression

Postby tataa » Thu Mar 02, 2017 2:03 am

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 (rm-rf, smb hml) i have no problem and the results for gammas and betas are shown
For the five factor model (rm-rf smb hml rmw cma) it does not work and i have this error message that says “ positive or non-negative argument to function expected in “RESULTS01 APPEND CSAVG”.
Attachments
fama macbeth.docx
(325.78 KiB) Downloaded 465 times

EViews Rebecca
EViews Developer
Posts: 113
Joined: Thu Apr 18, 2013 8:37 am

Re: Fama-MacBeth regression

Postby EViews Rebecca » Thu Mar 02, 2017 6:59 am

You will need to post the EViews workfile itself for me to help you.


Return to “Add-in Support”

Who is online

Users browsing this forum: No registered users and 9 guests