Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: bysort group: gen time = _n


From   "Clive Nicholas" <[email protected]>
To   [email protected]
Subject   st: bysort group: gen time = _n
Date   Fri, 21 Nov 2003 19:53:50 -0000 (GMT)

Scott,

Unfortunately, -bysort group: gen time = _n- didn't do the trick, as I
suspected it mightn't. That's the variable that, when generated, produces
the "repeated time values within panel r(451);" error. :( I should have
been a bit clearer on that earlier!

C.

> ----- Original Message -----
> From: "Clive Nicholas" <[email protected]>
> To: <[email protected]>
> Sent: Thursday, November 20, 2003 9:05 PM
> Subject: st: -tsset- and -xtpcse-
>
>
>> Statapeeps,
>>
>> I wondered if any -xtperts- could help with this. :-) My cross-sectional
>> dataset has n=3452, with n=6 per group (except for one group where n=7).
>>
>> After successfully fitting several cross-sectional FGLS regressions
>> (both
>> for fixed and random effects), I thought I'd try and run an -xtpcse-
>> regression, since even the most controlled FGLS model tested 'positive'
>> for serial correlation.
>>
>> Unfortunately, Stata refused, because:
>>
>> no time periods are common to all panels, cannot estimate disturbance
>> covariance matrix using casewise inclusion
>> r(459);
>>
>> Indeed it wasn't (as it was generated by [g time = _n], but that's
>> because
>> I can't use a time variable for -tsset- because Stata says:
>>
>> repeated time values within panel
>> r(451);
>>
>> Naturally, a panel variable has also been included in my -tsset-. Since
>> it's necessary for Stata to recognise that my dataset is a time-series
>> dataset before running -xtpcse-(otherwise: "time variable not set, use
>> -tsset varname ...- r(111);"), what's the solution? (I didn't pick up
>> anything in -help- that answers my question!)
>>
>> Yours,
>> CLIVE NICHOLAS,
>
>
> try:
> bysort group: gen time = _n
> This will generate a time variable for each group.  -xtreg, fe or re- do
> not
> explicitly use the time variable so your incorrectly created time variable
> to
> show up before.
>
> Hope this helps,
> Scott
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>


Yours,
CLIVE NICHOLAS,
Politics Building,
School of Geography, Politics and Sociology,
University of Newcastle-upon-Tyne,
Newcastle-upon-Tyne,
NE1 7RU,
United Kingdom.
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index