OpenSourceAP / CrossSection

Code to accompany our paper Chen and Zimmermann (2020), "Open source cross-sectional asset pricing"
https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3604626
GNU General Public License v2.0
738 stars 218 forks source link

FirmAgeMom missing values and weird code #136

Closed chenandrewy closed 3 months ago

chenandrewy commented 1 year ago

There's weird stuff in FirmAgeMom.do

There seem to be no observations of FirmAgeMom in 2021 July.

Seems to be due to this snippet

replace FirmAgeMom = . if abs(prc) < 5 | tempage < 12
egen temp = fastxtile(tempage), by(time_avail_m) n(5)  // Find bottom age quintile
replace FirmAgeMom =. if temp > 1 & temp !=.

is the & supposed to be |? That looks weird.

Anyway, the bottom quintile of age is very small in 2021, at around 11-12:

image

and that seems to be interacting with the filter above and causing the gap.

chenandrewy commented 1 year ago

Zhang 2006 applies the abs(prc)<5 and tempage < 12 filter before doing any analysis

image

so we should only run the fastxtile on stocks that satisfy those filters. That should address this gap.

tomz23 commented 3 months ago

Fixed in https://github.com/OpenSourceAP/CrossSection/commit/6e8632115395b9c72fb6b587a03c3644b61f9a34. Dropping obs with abs(prc)<5) | tempage <12 and computing quantiles on the remaining stocks leads to more reasonable numbers:

grafik