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: Standard deviation for trailing x months


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Standard deviation for trailing x months
Date   Tue, 29 Nov 2011 15:53:40 +0000

-egen- does not provide much support for this kind of problem. Try
-rolling- with -summarize-.

Nick

On Tue, Nov 29, 2011 at 3:21 PM, Nick K <[email protected]> wrote:

> I have panel data with observations per firm for a number of months. I
> want to calculate the standard deviation of returns over 60 months
> preceding the sample year. For example, to calculate the value for
> 1993 I want to calculate the sd for period between Jan 1988 and Dec
> 1992.
>
> I know how to calculate it for all years for 1 firm:
> bys company date: egen sd=sd(return)
>
> Doing it for subsamples within each firm is harder. I can imagine that
> if I generated a group variable for each "block" (e.g. observations
> between Jan 1988 and Dec 1992 are 1, next block is 2 and so on) I
> could use the above command, but I don't know how to generate these
> groups either.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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