| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: calculating return of stocks - problem with weekends
sacrificial lamb
Tobias said, given his firm-level daily stock price data,
. sort nummer daily
. tsset nummer daily
gen redite = f/l.f-1
The problems are the weekends. For example at the 26.12.2005 STATA
doesn’t
calculate the return.
Tobias should create a dummy variable avail (allowing for prices to
be either zero or missing on non-market days)
gen avail = f>0 & f<.
bysort nummer daily: gen tradingday=_n if avail
That should create a sequential day variable for only market days
that counts the market days.
tsset tradingday nummer
g return = log(f/L.f)
That should work on the market days available for each firm.
If you want to revert the data to the prior organization with
weekends and holidays interspersed, just use
tsset nummer daily
The essence of the trick here (which we could describe as
'Drukkering' the time series) is laid out in Stata Tip 40, "Taking
care of business" (insert appropriate MP3 file),
http://econpapers.repec.org/article/tsjstataj/
v_3a7_3ay_3a2007_3ai_3a1_3ap_3a137-139.htm
Kit Baum, Boston College Economics and DIW Berlin
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/