[R] survey weights

A Das kerbo2004 at yahoo.com
Sun Sep 4 20:45:46 CEST 2005


That worked. Many thanks, Thomas. 
                              -Bobby

--- Thomas Lumley <tlumley at u.washington.edu> wrote:

> On Sun, 4 Sep 2005, A Das wrote:
> 
> > Just: "missing values in object". That would imply
> the
> > object was created. But then I write "dchina", and
> it
> > says "object dchina not found".
> 
> No, it would not imply the object was created.  If
> it was an error message 
> (rather than a warning) the object would not have
> been created.
> 
> I presume the full message was
>   Error in na.fail.default(object) : missing values
> in object
> 
> If so, it sounds as though you have missing values
> in the id, weights, or 
> strata variable.
>     summary(China[,c("psu","stata","weight0x"])
> will verify this.
> 
> Stata will just have dropped these observations (use
> -svydes- to verify 
> this).  If you want to drop the observations in R
> you need to do this 
> explicitly. Having missing data may be unavoidable,
> but if you have 
> observations in a sample it seems that you should
> know how they were 
> sampled.
> To drop these observations you could use
> 
> obsChina <- subset(China, !is.na(psu) &
> !is.na(strata) & !is.na(weight0x))
> 
> and then use obsChina rather than China in the
> svydesign() function.
> 
>  	-thomas
> 
> 
> 
> >                          -Bobby
> >
> > --- Thomas Lumley <tlumley at u.washington.edu>
> wrote:
> >
> >> On Sun, 4 Sep 2005, A Das wrote:
> >>
> >>> Thanks, Thomas.
> >>>    Yes, that's exactly what happened: the
> warnings
> >>> came first after "data(China)", and then after
> >>> "dchina<-svydesign..." So the design object
> isn't
> >>> being produced? The dataset is very large, and
> the
> >>> weights were already set in Stata before
> >> importing.
> >>> Would either of those cause problems?
> >>
> >> Probably not.  What was the error message from
> >> svydesign()?  That is what
> >> will say what went wrong.
> >>
> >>  	-thomas
> >>
> >
> >
> >
> >
> >
> ____________________________________________________
> > Start your day with Yahoo! - make it your home
> page
> > http://www.yahoo.com/r/hs
> >
> >
> 
> Thomas Lumley			Assoc. Professor, Biostatistics
> tlumley at u.washington.edu	University of Washington,
> Seattle
>




More information about the R-help mailing list