Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

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 <coffeemug.nick@gmail.com> 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/

**References**:**st: Standard deviation for trailing x months***From:*Nick K <coffeemug.nick@gmail.com>

- Prev by Date:
**st: friedman test** - Next by Date:
**Re: st: friedman test** - Previous by thread:
**st: Standard deviation for trailing x months** - Next by thread:
**re:Re: st: Standard deviation for trailing x months** - Index(es):