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: unique IDs in xtmixed


From   Joerg Luedicke <[email protected]>
To   [email protected]
Subject   Re: st: unique IDs in xtmixed
Date   Fri, 20 May 2011 18:13:30 -0400

On Fri, May 20, 2011 at 2:22 PM, Roberto G. Gutierrez, StataCorp
<[email protected]> wrote:
> Teya Rutherford <[email protected]> asks:
>
>> I have encountered a strange thing in my analysis.  I am working with
>> long data that has between one and three years of information per
>> student.  I created an analysis sample to limit my analysis to those
>> students without missing data on certain variables and who are present
>> during our years of interest (years 2 & 3) for at least one year. When I
>> codebook ID within this sample I get about 28K unique IDs. I've
>> confirmed this number by using sum with this sample by year.
>
>> When I run xtmixed (code below) it says that there are 30236 unique
>> students (based on the same ID variable) contributing between 1 & 3
>> years to the data. The if statement appears to work, because it keeps
>> the numbers consistent between my conditional and unconditional models
>> (before adding the statement it was not consistent). I've never before
>> *gained* observations from codebook to analysis and I'm extremely
>> puzzled. Can anyone help?
>
>> Code for unconditional model:
>> xtmixed SSMATH c_grade || MINDSH: c_grade || ssid: c_grade if
>> atleastoneyear == 1 & analysissample == 1, mle var cov(un)
>
>> -----------------------------------------------------------
>>                 |   No. of       Observations per Group
>>  Group Variable |   Groups    Minimum    Average    Maximum
>> ----------------+------------------------------------------
>>         MINDSH  |       52        433     1093.7       1985
>>         ssid    |    30236          1        1.9          3
>> -----------------------------------------------------------
>
> What Teya is observing is that -xtmixed- treats model levels as nested
> despite how the group IDs are coded.  While -ssid- may have 28K unique
> values when considered in isolation, in an -xtmixed- model where -ssid-
> is nested within -MINDSH-, it can have more unique values.  That is
> because an -ssid- coding of 12 (say) within v is treated as
> distinct from and -ssid- coding of 12 within -MINDSH==2-, or any other
> value of -MINDSH-.
>
> It's just the nature of the nesting.
>

One might add that if a Level 1 unit happens to be a member of more
than one Level 2 units, then the data is not strictly nested. In the
above example, if -ssid- unit 12 is nested in -MINDSH==1- _and_
-MINDSH==2- the strictly hierarchical model could be the wrong
approach and some kind of crossed random effects approach or multiple
membership model would be more appropriate, I think. I would suggest
proceeding with caution here.

J.

*
*   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/


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