postStratify {survey} | R Documentation |
Post-stratification adjusts the sampling and replicate weights so that the joint distribution of a set of post-stratifying variables matches the known population joint distribution. The advantage of post-stratification is that sampling frames need not be available for the strata.
postStratify(design, strata, population, partial = FALSE)
design |
A survey design with replicate weights |
strata |
A formula or data frame of post-stratifying variables |
population |
A table , xtabs or data.frame
with population frequencies |
partial |
if TRUE , ignore population strata not present in
the sample |
The population
totals can be specified as a table with the
strata variables in the margins, or as a data frame where one column
lists frequencies and the other columns list the unique combinations
of strata variables (the format produced by as.data.frame
acting on a table
object).
A table must have named dimnames to indicate the variable names.
A new survey design object.
as.svrepdesign
, svrepdesign
, rake
data(api) dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc) rclus1<-as.svrepdesign(dclus1) svrepmean(~api00, rclus1) svreptotal(~enroll, rclus1) # post-stratify on school type pop.types <- data.frame(stype=c("E","H","M"), Freq=c(4421,755,1018)) #or: pop.types <- xtabs(~stype, data=apipop) #or: pop.types <- table(stype=apipop$stype) rclus1p<-postStratify(rclus1, ~stype, pop.types) summary(rclus1p) svrepmean(~api00, rclus1p) svreptotal(~enroll, rclus1p)