Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Creating Standard Deviation variable for daily panel data (stock returns)


From   "C. Evans" <[email protected]>
To   [email protected]
Subject   st: Creating Standard Deviation variable for daily panel data (stock returns)
Date   03 Jul 2013 17:37:34 +0100

Dear Satalist

I've been using the command egen sdreturn3 = sd(return), by(date) to try and create a new variable that takes the standard deviation of return for that month or even that day. This gives me the same sd for every id at that date (which I don't want)

my panel looks like this

id    date     returns
1   01Jan1964    0.1
1   02Jan1964    0.12
1   03Jan1964    0.05
2   01Jan1964    0.3
2 02Jan1964 0.25 2 03Jan1964 0.1
3   01Jan1964    -0.1
3   02Jan1964    -0.2
3   03Jan1964    -0.3

Hopefully the format has turned out OK. The values are just there for an example.

Also, does it matter when I use xtset, id date, daily that I am using business data and thereore the weekends are not included in my dataset

Thanks a lot in advance,
Chris Evans
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index