Bookmark and Share

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]

Re: st: unique IDs in xtmixed


From   rgutierrez@stata.com (Roberto G. Gutierrez, StataCorp)
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: unique IDs in xtmixed
Date   Fri, 20 May 2011 13:22:13 -0500

Teya Rutherford <teyarutherford@gmail.com> 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 -MINDSH==1- 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.

--Bobby
rgutierrez@stata.com
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index