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 |
Christopher Baum <kit.baum@bc.edu> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: Difficulties in variable calculation using panel data |

Date |
Sat, 30 Oct 2010 11:24:38 -0400 |

On Oct 30, 2010, at 2:33 AM, Leon wrote: > When doing this, I face two problems: > > I. Weekends are treated as gaps, thus no return for Monday is computed, but Stata should rather use Fridays' value to compute it. May I skip the 'daily' option in the xtset command? > > II. The results are wrong when I proof them randomly by hand. I guess Stata mixes up the groups. How can I tell Stata to look at the timeseries for each group separately? > > b) Second, I want to compute another variable using the following formula but don't know how to tell it Stata: > dev = 1/N * sum( abs(return_i, t - return_m,t) ) > > N = total number of groups within panel (can be substituted by [ `=_N' ], right?) > return_i,t = return of group i at time point t > return_m,t = average return across all groups at time point t > > c) finally I try to run a regression on dev > > xtreg dev return … > > But in the regression I want Stata to (theoretically) do one regression per t and compute the average values over all regressions, so I need just the cross-sectional and not the timeseries information in the data. // with regard to maintaining both a conventional calendar (e.g., to identify weekends) // and a time-series calendar (1..T), see: // http://www.stata-journal.com/article.html?article=dm0028 clear all webuse grunfeld, clear g fakeret = log(invest / L.invest) // create a variable containing annual average abs deviation from time mean egen mufake = mean(fakeret), by(year) g absdev = abs(fakeret - mufake) egen muabsdev = mean(absdev), by(year) tabstat muabsdev, by(company) stat(mean sd) tabstat muabsdev, by(year) stat(mean sd) // the remainder of your posting is problematic. To run a regression for each t of dev on return, // note that dev (musabsdev as above) is a constant for each t. So how can you run such a regression? // to run a firm-specific regression and save the coefficients, use the -rolling- prefix. Kit Baum | Boston College Economics & DIW Berlin | http://ideas.repec.org/e/pba1.html An Introduction to Stata Programming | http://www.stata-press.com/books/isp.html An Introduction to Modern Econometrics Using Stata | http://www.stata-press.com/books/imeus.html * * 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/

- Prev by Date:
**Re: st: gaps in the Hodrick-Prescott filter** - Next by Date:
**st: outreg after fairlie decomposition** - Previous by thread:
**Re: st: RE: Difficulties in variable calculation using panel data** - Next by thread:
**st: gaps in the Hodrick-Prescott filter** - Index(es):