Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • xtmixed: how do you exclude groups with number of observations below a threshold?

    I'm working with a dataset in which students are nested in schools; my two-level model reflects this nesting.

    After I estimate the fixed and random coefficients using xtmixed, I run the command estat group. I see that the minimum number of observations per group is 3. (I know, you can see this information from the xtmixed results too.) I would like my estimates to reflect the exclusion of any group with fewer than 15 observations. In other words, I would like to identify (and possibly just drop) any group containing fewer than 15 observations, and then run my xtmixed statement.

    Is there a way to identify the groups with fewer than 15 observations? That's basically the one issue I'm having. I'm not sure how Stata is doing this.

    A possibly related question: Is Stata including an observation in a group if the observation is non-missing on all of the predictor variables included in my model?
    Last edited by Elc Estrera; 20 May 2015, 07:02. Reason: I added tags -- I didn't know these existed.

  • #2
    I think I figured it out. For future reference:

    You have to recall that Stata only includes an observation in a regression if it's nonmissing on every predictor variable. I dropped any observation from my dataset that was missing on a predictor variable.

    I then used _n to count up the number of observations in each group (school in this case). I used the max function from egen to identify any group that had fewer than 15 observations (students in this case). I dropped these from my dataset.

    Comment


    • #3
      What you have done will do what you wanted. But be careful what you wish for. What if the effects you are trying to estimate are themselves dependent on the size of the group? Then you will have selected a highly biased sample. At a minimum, you will have to caveat any conclusions you draw that they only apply to groups with at least 15 members.

      Comment

      Working...
      X