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: "Select If" Statement xtmixed


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: "Select If" Statement xtmixed
Date   Fri, 18 Mar 2011 08:54:16 +0000 (GMT)

--- On Thu, 17/3/11, Saul G. Alamilla wrote:
> I would like to use a "select if" statement in xtmixed
> so that I only utilize clusters (L2 units or groups)
> containing at least 3 observations (or L1 units). 

I am assuming you want not just a minimum of two 
observations, but a minimum of two _valid_ observations.

say you have a dependent variable (y) and two independent
variables (x1 and x2). Than the first step would be to 
create a variable that says whether or not an observation
has all valid values:

gen byte valid = !missing(y, x1, x2)

Than you create a variable that says whether or not a 
cluster contains >2 valid observations:

bys group valid : gen byte touse = _N > 2 if valid == 1

To create these variables I used tricks discussed her:
<http://www.stata.com/support/faqs/data/trueorfalse.html>

after that you use that variable in the if condition (not 
option!) in -xtmixed-:

xtmixed y x1 x2 if touse == 1 || group_id:

-if- conditions (and weights) are placed immediately 
after the variable list, options are placed after the
comma.

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

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