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 |
Léon Bueckins <l.bueckins@zeppelin-university.net> |

To |
statalist@hsphsun2.harvard.edu |

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

Date |
Sat, 30 Oct 2010 01:41:39 +0200 |

Hi, I hope somebody will be so kind to help me to get my approach "translated" to Stata, as I'm facing some difficulties: I have a panel dataset and set it this way via 'xtset group_id date, daily' Hence my data looks like this: date | price | group_name | group_id 01-01-2005 | 34,78 | group A | 1 01-01-2005 | 12,56 | group B | 2 01-01-2005 | 17,21 | group C | 3 01-02-2005 | 67,53 | group A | 1 01-02-2005 | 25,90 | group B | 2 01-02-2005 | 44,78 | group C | 3 … | … | … | … a) Now I want to calculate the daily return for each group across time using: gen return = 100 * (log(price) - log(L.price)) 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. Help is greatly appreciated, so thank you very much for helping me! * * 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**:**st: RE: Difficulties in variable calculation using panel data***From:*"Degas Wright" <dwright@cornerstoneadvice.com>

- Prev by Date:
**st: comparing two linear slopes** - Next by Date:
**st: RE: comparing two linear slopes** - Previous by thread:
**st: comparing two linear slopes** - Next by thread:
**st: RE: Difficulties in variable calculation using panel data** - Index(es):