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]

From |
Richard Herron <richard.c.herron@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: In unbalanced panel, make sure individuals begin in month X and end in month Y |

Date |
Sat, 8 Oct 2011 16:59:35 -0400 |

How can I make sure individuals in a panel begin in one given month and ends in another given month? For example, I want to make sure that every firm in an unbalanced monthly panel begins in April and ends in March. A priori I don't know each firm's first or last month (i.e., unbalanced panel). My end goal is to use -rolling- to perform regressions with a 48-month window and a 12-month step size to get regression coefficients each year. I want to avoid regressing every month and dropping 11 of 12 entries each year, which would be very time-consuming. Thanks! Here is some code: * ----- begin code ----- * generate random starting dates clear set obs 250 egen int id = seq() generate int date_m = 1 + int(12*runiform()) generate int date_y = 1960 + int(50*runiform()) generate int date_ym = ym(date_y, date_m) format date_ym %tm * add random number of observations to each id generate int n_obs = 1 + int(20*12*runiform()) expand n_obs bysort id: replace date_ym = date_ym + _n * generate random variables generate y = rnormal() generate x = rnormal() * I would like to do this rolling regression with a 12 month step-size * and have them go from April through March four years later tsset id date_ym rolling z = (e(rss) / e(N)) /// , window(48) stepsize(12) saving(temp, replace) /// : regress y x * ----- end code ----- * * 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/

**Follow-Ups**:**Re: st: In unbalanced panel, make sure individuals begin in month X and end in month Y***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**st: how to put both coefficient and exponentiated form in a table using estout or similar command** - Next by Date:
**Re: st: how to put both coefficient and exponentiated form in a table using estout or similar command** - Previous by thread:
**st: how to put both coefficient and exponentiated form in a table using estout or similar command** - Next by thread:
**Re: st: In unbalanced panel, make sure individuals begin in month X and end in month Y** - Index(es):