[R] Survey proportions... Can I use population as denominator?

Thomas Lumley tlumley at u.washington.edu
Wed May 24 22:37:52 CEST 2006


On Tue, 23 May 2006, David L. Van Brunt, Ph.D. wrote:

> Just giving the survey package a spin...
>
> I'm accustomed to stata, and it seems very similar in many respects. One
> thing is throwing me, however.
>
> I've gotten my data in, and specified the design. Looks like the weighting
> is right (based on published population estimates from these data), but now
> I'd like to check my "marginal means" for proportions against those that
> have been published.

No, actually you get means with svymean().

Proportions for factor levels come by svymean() with a factor variable, 
eg:
> data(api)
> dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
> svymean(~stype,dclus1)
            mean     SE
stypeE 0.786885 0.0463
stypeH 0.076503 0.0268
stypeM 0.136612 0.0296
> svymean(~sch.wide,dclus1)
                mean     SE
sch.wideNo  0.12568 0.0204
sch.wideYes 0.87432 0.0204

 	-thomas

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle



More information about the R-help mailing list