[R] weighting (survey) data

Thomas Lumley tlumley at u.washington.edu
Sat Jan 16 04:04:16 CET 2010


On Sat, 16 Jan 2010, Vera wrote:

> Thanks for your help so far, everyone.
>
> Thomas: I haven't looked very deep into the survey package yet, so I
> don't know if what I'm looking for is actually missing or if I just
> haven't found it yet.
> What is "missing", from my point of view at the moment, is some kind
> of global weighting function that allows me to set a weight and then
> just perform different kinds of analyses without thinking about it any
> more.

There isn't anything like this, because it isn't possible. Some analyses can't sensibly be done with sampling weights; for others you can get point estimates but it is hard to get standard errors.


> I'll try to describe what I want to do:
> I'll be working with the European Social Survey datasets (for my MA
> thesis). The data have to be weighted before doing any kind of
> analyses because the sample sizes in the different countries aren't
> proportional to total population sizes.
> Analyses I probably will do include: contingency tables, measures of
> association (Cramer's V), factor analysis, linear regression.
> I've used SPSS so far and thus haven't ever had to look very deep into
> what 'weighting' means, exactly.

The survey package has weighted contingency tables (with tests) and linear regression.   If you don't need tests, xtabs() in base R will also do weighted contingency tables.

The factanal() and princomp() functions can take as input a weighted version of the covariance matrix, and this can be produced by cov.wt() or by svyvar() in the survey package.

        -thomas




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



More information about the R-help mailing list