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: RE: generating annualized standard deviation of returns from monthly data.
From
Kieran McCaul <[email protected]>
To
"[email protected]" <[email protected]>
Subject
RE: st: RE: generating annualized standard deviation of returns from monthly data.
Date
Thu, 27 Feb 2014 17:15:44 +0800
...
Yes,
bysort firm year: egen sd=sd(return)
will work as well.
The -collapse- should work because it will drop any missing return values.
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Marko L
Sent: Thursday, 27 February 2014 3:25 PM
To: [email protected]
Subject: Re: st: RE: generating annualized standard deviation of returns from monthly data.
Ikechukwu M. <[email protected]>:
Perhaps, you want to sort out by year as well:
bysort firm year: egen sd_return=sd(return)
2014-02-27 6:53 GMT+01:00 Ikechukwu M. <[email protected]>:
> Thanks Kieran for your response. I tried that and it gives me all
> zeros. I think it has to do with how stata treats missing values in
> the collapse command. I had seen an earlier post by Nick regarding
> this.
>
> I used bys firm : egen sd=sd(return) and I get values but they are not
> partitioned by year. It gives me one SD for all the datapoints for the
> firm.
>
> thanks
>
> On Wed, Feb 26, 2014 at 11:23 PM, Kieran McCaul
> <[email protected]> wrote:
>> ...
>>
>> Like this?
>>
>> clear *
>>
>> input firm str7 date return
>> 1 "Jan2000" 0.875
>> 1 "Feb2000" 1.2
>> 1 "Mar2000" 0.9
>> 1 "Jan2001" 0.35
>> 1 "Feb2001" 0.98
>> 2 "Jan2000" 1.4
>> 2 "Feb2000" .76
>> 2 "Mar2000" 1.34
>> end
>>
>> gen year = substr(date, 4,.)
>>
>> preserve
>>
>> collapse (sd) sd_return=return, by(firm year)
>> tempfile ttt
>> save `ttt', replace
>>
>> restore
>>
>> merge m:1 firm year using `ttt'
>> list
>> bysort firm year: summ return
>>
>>
>>
>>
>>
>> -----Original Message-----
>> From: [email protected] [mailto:[email protected]] On Behalf Of Ikechukwu M.
>> Sent: Thursday, 27 February 2014 9:33 AM
>> To: [email protected]
>> Subject: st: generating annualized standard deviation of returns from monthly data.
>>
>> I am trying to compute standard deviation of returns for a panel data set and I am having a little difficulty.
>>
>> My data looks like this
>>
>> Firm date return
>> 1 Jan2000 0.875
>> 1 Feb2000 1.2
>> 1 Mar2000 0.9
>> 1 Jan2001 0.35
>> 1 Feb2001 0.98
>> 2 Jan2000 1.4
>> 2 Feb2000 .76
>> 2 Mar2000 1.34
>>
>>
>> I would like to compute the annualized standard deviation of returns for each firm and return one number for each firm in each year.
>>
>> Any help is greatly appreciated.
>> Thank you very much.
>>
>> IK
>> *
>> * 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/
*
* 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/