Dear all,

How do I properly run a Fama-Macbeth regression with a cross-sectional invariant variable?

Apologize for attaching screenshot instead of proper tables — still have to learn how to do it.

I have a panel of 53 firms (id) with 18 years of daily observations (253,287 in total)of
  • Return (ret),
  • Five Fama and French (2015) factors (rmrf, smb, hml, rmw, cma)
  • Social media sentiment variable (sentiment, invariant across firms)
What do I do:
Code:
* generating firmnumbers *
encode id, gen(idd)
drop id
rename idd id

* sorting as panel *
xtset id date

* generating beta variables *
gen beta_rmrf=.
gen beta_smb=.
gen beta_hml=.
gen beta_rmw=.
gen beta_cma=.
gen beta_sentiment=.

* loop to calculate beta *
forvalues i=1/53{
quietly reg ret rmrf smb hml rmw cma sentiment if id==`i'
replace beta_rmrf=_b[rmrf] if id==`i'
replace beta_smb=_b[smb] if id==`i'
replace beta_hml=_b[hml] if id==`i'
replace beta_rmw=_b[rmw] if id==`i'
replace beta_cma=_b[cma] if id==`i'
replace beta_fear=_b[fear] if id==`i'
replace beta_sent=_b[sentiment] if id==`i'
}
* Fama Mac Beth Regression *
tfmb ret beta_rmrf beta_smb beta_hml beta_rmw beta_cma beta_sent
Here are 24 first rows of my data:
Array


Here is the summary of my variables (apologize for the screenshot):
Array I realized that something is not right about my approach when I tried to run a Fama-Macbeth (1973) regression using areg commandwith fmb option, and it simply omitted my sentiment variable.

Thank you!