[R] Post stratification weights in survey package in R

Thomas Lumley tlumley at uw.edu
Mon May 14 18:39:30 CEST 2012


On Sun, May 13, 2012 at 7:10 PM, Ruijie <breakaway8 at gmail.com> wrote:
> Hi all,
>
> I have data collected from a survey administered on a subset of the
> population. I also have the population proportions of variables such as
> gender, race and housing type. I would like to combine the weights from
> each separate cross tab (of gender, race and housing type) such that the
> weighted proportions of my survey data matches that of the population.
>
> I have tried the following:
>
> library(survey)
>
>
> gender.population <-
> read.table("http://dl.dropbox.com/u/822467/Gender.csv", header = TRUE,
> sep = ",")
>
> housing.population <-
> read.table("http://dl.dropbox.com/u/822467/Housing.csv", header =
> TRUE, sep = ",")
>
> race.population <-
> read.table("http://dl.dropbox.com/u/822467/Race.csv", header = TRUE,
> sep = ",")
>
> survey.sample <-
> read.table("http://dl.dropbox.com/u/822467/survey.sample.csv", header
> = TRUE, sep = ",")
>
> survey.object.sample <- svydesign(id = ~1, data = survey.sample)
>
> survey.object.sample.weighted <- rake(survey.object.sample,
> list(~gender, ~housing, ~race), list(gender.population,
> housing.population, race.population))
>
> str(survey.object.sample.weighted$postStrata)
>
> I see from survey.object.sample.weighted$postStrata that weights have been
> assigned separately for each of the variable. My question is: Is it
> possible to get 1 weight for each subject instead of 3 weights as shown in
> the package?

There *is* only one weight for each subject.

You are misinterpreting the internal structures of the package: if you
want to see the weights, use the weights() function.

The components of $postStrata are used in standard error computations.

   -thomas

-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland



More information about the R-help mailing list