[R] Subpopulations in Complex Surveys

Spencer Graves spencer.graves at pdf.com
Mon Feb 24 03:42:02 CET 2003


I'm not familiar with the survey systems, any array or data.frame can be 
subsetted using a logical vector.

For example, let Data = data.frame(sex = ..., age =, ..., ...).  Then,

	Sel.fem50 <- (Data$sex=="Female") & (Data$age> 50)
	fem50Answers <- FUN(... data=Data[Sel.fem50,])

If you want to do this to many subgoups, consider "split", "by", 
"lapply", "sapply", "tapply", "aggregate", etc.  See Venables and 
Ripley, Modern Applied Statistics with S, 4th ed.

Hope this helps.
Spencer Graves

TyagiAnupam at aol.com wrote:
> In a message dated 2/23/03 1:19:39 PM Eastern Standard Time, 
> tlumley at u.washington.edu writes:
> 
> 
>>On Wed, 19 Feb 2003 TyagiAnupam at aol.com wrote:
>>
>>
>>>Hi,
>>>is there a way to analyze subpopulations (e.g. women over 50, those who
>>>answered "yes" to a particular question) in a survey using Survey 
>>
>>package?
>>
>>>Other packages (e.g. Stata, SUDAAN) do this with a subpopulation option 
>>
>>to
>>
>>>identify the subpopulation for which the analysis shoud be done. I did 
>>
>>not
>>
>>>see this option in the Survey package. Is there another way to do this?
>>>
>>
>>Not directly.
>>
>>This only really matters for svymean. For the regression models it's just
>>a convenience as you can specify a model that has an interaction with the
>>subpopulation indicator to get estimates and standard errors in the
>>subpopulation.
>>
>>For svymean you can use a regression model too:
>>Instead of a hypothetical   svymean(~x, design=d, subpop=race==2)  do
>>   svyglm(x~I(race==2)+0, design=d)
>>
>>I need to work out if there's a general way to handle subpopulations or
>>whether it needs to be coded on a case by case basis.
>>
>>
>>    -thomas
>>
> 
> 
> Thanks a lot for the answer.  Is there a way to get quantiles and 
> cross-tabulations in subpopulations? If I think of proportion as mean of 
> binary indicator (y: "got milk?"=1), can I use the solution above for 
> proportions in subpopulations?
> svyglm(y~I(race==2)+0, design=d)
> If I create a binary indicator for a subpopulation (men over 50), can I use 
> it with svytable?
> svytable( ~y+z,design=d)
> --anupam.
> 
> *********************************************************
> Prediction is very difficult, especially about the future. 
>                   -- Niels Bohr
> *********************************************************
> 
> 	[[alternate HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list