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]

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


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Creating Standard Deviation variable for daily panel data (stock returns)
Date   Wed, 3 Jul 2013 18:16:30 +0100

OK. -by(id month)- should be what you want.
Nick
[email protected]


On 3 July 2013 18:13, C. Evans <[email protected]> wrote:
> Dear Nick
>
> I would like standard deviation values of returns calculated for each id
> each month. So I would have a value of 0.2 everyday in one month for id=1
> and then the 2nd month a different standard deviation. I should see a
> different SD each month and for each different Id - probably.
>
> I'm not very good at explaining
>
> Thanks,
> Chris
>
>
> On Jul 3 2013, Nick Cox wrote:
>
>> I missed in this a statement of what you _do_ want. If you have a
>> block of values for which you calculate the SD, it's necessarily the
>> same result for all observations contributing.
>>
>> But  Stata won't take account of missing values it does not have.
>>
>> Nick
>> [email protected]
>>
>> On 3 July 2013 17:37, C. Evans <[email protected]> wrote:
>>
>>> 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
>>
>> *
>>
>> *   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/
>>
> *
> *   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/
*
*   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