Bookmark and Share

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]

Re: st: How to generate lags where each variable to be lagged has multiple values in the previous time periods


From   Stuart Buck <[email protected]>
To   [email protected]
Subject   Re: st: How to generate lags where each variable to be lagged has multiple values in the previous time periods
Date   Tue, 30 Apr 2013 15:54:50 -0500

Thanks, the dataset somehow did have a few duplicates. With those
eliminated, the following code worked and allowed me to create lags
and double-lags for the test score variables.

sort campus year grade
gen id = year - grade
egen panelid = group (campus id), label
tsset panelid year

On Mon, Apr 29, 2013 at 5:08 PM, Nick Cox <[email protected]> wrote:
> See the FAQ
>
> http://www.stata.com/support/faqs/data-management/repeated-time-values/index.html
>
> or try
>
> isid school grade year
> duplicates list school grade year
>
> (Your variable names, naturally.)
> Nick
> [email protected]
>
>
> On 29 April 2013 22:51, Stuart Buck <[email protected]> wrote:
>> This looks good, except that for any of the tsset commands, I get the
>> error code 451: "repeated time values within panel."
>>
>> On Mon, Apr 29, 2013 at 4:05 PM, Nick Cox <[email protected]> wrote:
>>> Treating each school separately is just a twist on this:
>>>
>>> gen cohort = year - grade
>>> egen id = group(school cohort), label
>>> tsset id year
>>>
>>>
>>> Nick
>>> [email protected]
>>>
>>>
>>> On 29 April 2013 20:32, Nick Cox <[email protected]> wrote:
>>>> Focus on any cohort, say the cohort that was grade 8 in 2011, grade 7
>>>> in 2010 and so forth. Evidently, the difference (year - grade) is
>>>> constant, and therefore an identifier, for that cohort. Thus after
>>>>
>>>> gen id = year - grade
>>>>
>>>> either
>>>>
>>>> tsset id year
>>>>
>>>> or
>>>>
>>>> tsset id grade
>>>>
>>>> defines a panel dataset with an identifier and a time variable and
>>>> time series operators can then be applied.
>>>>
>>>> Nick
>>>> [email protected]
>>>>
>>>> On 29 April 2013 19:46, Stuart Buck <[email protected]> wrote:
>>>>
>>>>> Passage rates for all Texas schools for 2008, 2009, 2010, and 2011 --
>>>>> this is important -- by grade. So each row in the dataset is School,
>>>>> Year, Grade, and then scores (plus other demographic variables, etc.).
>>>>>
>>>>> In other words, the dataset looks like this:
>>>>>
>>>>> Year     SchoolID     Grade     TestScore
>>>>> 2011    1                  6               ***
>>>>> 2011     1                 7               ***
>>>>> 2011     1                 8               ***
>>>>>
>>>>> And so on and so forth -- multiple grades in each school in each year.
>>>>>
>>>>> Here's what I want:
>>>>>
>>>>> To be able to regress any given school's performance in Grade X in
>>>>> Year T on, among other things, how that same school did with the same
>>>>> cohort of kids in the previous grade (Grade X-1) in the previous year
>>>>> (Year T-1). I.e., if a middle school's Grade 8 passage rate in 2011 is
>>>>> the outcome, I'd like to be able to control for that same school's
>>>>> Grade 7 passage rate in 2010, thus giving a somewhat crude measure of
>>>>> how much that group of kids progressed since the previous year.
>>>>>
>>>>> How would I generate an all-purpose lagged TestScore variable for all
>>>>> the schools in the dataset, lagging by both year and grade at once?
>>>>> All the Stata instructional material I see on lagged variables just
>>>>> lags based on time, not on both time and some other variable too
>>>>> (grade).
>>> *
>>> *   For searches and help try:
>>> *   http://www.stata.com/help.cgi?search
>>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>>> *   http://www.ats.ucla.edu/stat/stata/
>>
>>
>>
>> --
>> Stuart Buck
>> http://about.me/stuartbuck
>> 479-200-2750 (cell)
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>> *   http://www.ats.ucla.edu/stat/stata/
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/



-- 
Stuart Buck
http://about.me/stuartbuck
479-200-2750 (cell)
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index