[R] Surveys ans missing values

Greg Snow Greg.Snow at intermountainmail.org
Tue Dec 5 17:38:21 CET 2006


Have you tried:

> svymean(~q135, survey, na.rm=TRUE)

 


-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
 

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Jean-Baptiste
Combes
Sent: Tuesday, December 05, 2006 9:20 AM
To: r-help at stat.math.ethz.ch
Subject: [R] Surveys ans missing values

Hello,

I still apologise if the question i ask is naive. I would like to use R
instead of usual softs (SAS, Stata) or at list to do things that the
others do not. As a consequence I am trying to get familiar with R, and
i am astonished because it does not seem to do things that are easy to
do on other softs.

I have got data with missing values (I am working on a questionnaire
filled by students) and with weights and stratification. I learned how
to use the survey package, and I would like to do an average (by using
svymean) of a variable that has some NA.
I first tried :
svymean(~q135,survey) #q135 is the name of the variable and survey is
the name of the survey design but as there is missing values, i get that
:

     mean SE
q135   NA NA

as a consequence I put the observations without missing values in a
vector x
:
x<-na.omit(data$q135)

and I tried to make my average on that vector
svymean(~x,survey)
but I get an error because my weights are constructed on all the sample
and the vector of the weights has 1773 rows (that is the size of the
population) and the variable I want to make an average on has only 1754
rows.

I expect that my explanations are clear enough.

Thanks very much

	[[alternative HTML version deleted]]

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list