Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Regression with panel data: How to display and store the estimated coefficients?

    Dear all,

    I need to examine the effect between stock return R and change of exchange rate FX over a rolling 3 year-window for my thesis, also known as β1i in the following regression:

    Rit = β0i + β1i*FXt + β2i*RMRFt + β3i*SMBt + β4i*HMLt + εit

    I’m working with monthly panel datasets with a time range from 2005-2014, each dataset contains data of 3 years and the same sample of firms i (e.g. dataset 1 from 2005-2007, dataset 2 from 2006-2008, etc.).

    After I declared my data to be panel data, I have entered the following command for a GLS random-effects regression (of course separately for each dataset):

    xtreg R FX RMRF SMB HML, re

    Now I've been struggling on how to retrieve the estimates for coefficient β1i, which I need for further calculation and regression (2SLS). Is there a way to display and store the estimated coefficients for each firm?

    I’m grateful for any advice, if you need more information please let me know. Thank you!


    Kind regards,

    Meiqi

  • #2
    There must be an id for each firm, assuming that the variable is named as id, then you might use foreach loop such that
    Code:
    levelsof id, local(firmid)
    
    foreach i of local firmid{
    
         xtreg R FX RMRF SMB HML, re if id==`i'
    
         outreg2 using regression_results.xls, append ctitle(firm`i')
    }
    You can use other methods to extract coefficient values instead of using outreg2, see http://www.stata.com/statalist/archi.../msg00892.html
    Regards
    --------------------------------------------------
    Attaullah Shah, PhD.
    Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
    FinTechProfessor.com
    https://asdocx.com
    Check out my asdoc program, which sends outputs to MS Word.
    For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

    Comment


    • #3
      It works out, thank you very much for your instruction!

      Best regards,
      Meiqi

      Comment

      Working...
      X