1\name{postStratify}
2\alias{postStratify}
3\alias{postStratify.twophase}
4\alias{postStratify.svyrep.design}
5\alias{postStratify.survey.design}
6%- Also NEED an '\alias' for EACH other topic documented here.
7\title{Post-stratify a survey }
8\description{
9 Post-stratification adjusts the sampling and replicate weights so that
10 the joint distribution of a set of post-stratifying variables matches
11 the known population joint distribution. Use \code{\link{rake}} when
12 the full joint distribution is not available.
13}
14\usage{
15postStratify(design, strata, population, partial = FALSE, ...)
16\method{postStratify}{svyrep.design}(design, strata, population, partial = FALSE, compress=NULL,...)
17\method{postStratify}{survey.design}(design, strata, population, partial = FALSE, ...)
18}
19%- maybe also 'usage' for other objects documented here.
20\arguments{
21  \item{design}{A survey design with replicate weights}
22  \item{strata}{A formula or data frame of post-stratifying variables, which must not contain missing values. }
23  \item{population}{A \code{\link{table}}, \code{\link{xtabs}} or \code{data.frame}
24    with population frequencies }
25  \item{partial}{if \code{TRUE}, ignore population strata not present in
26    the sample}
27  \item{compress}{Attempt to compress the replicate weight matrix? When
28    \code{NULL} will attempt to compress if the original weight matrix
29    was compressed}
30  \item{...}{arguments for future expansion}
31}
32\details{
33  The \code{population} totals can be specified as a table with the
34  strata variables in the margins, or as a data frame where one column
35  lists frequencies and the other columns list the unique combinations
36  of strata variables (the format produced by \code{as.data.frame}
37  acting on a \code{table} object).   A table must have named dimnames
38  to indicate the variable names.
39
40  Compressing the replicate weights will take time and may even
41  increase memory use if there is actually little redundancy in the
42  weight matrix (in particular if the post-stratification variables have
43  many values and cut  across PSUs).
44
45  If a \code{svydesign} object is to be converted to a replication
46  design the post-stratification should be performed after conversion.
47
48
49  The variance estimate for replication designs follows the same
50  procedure as Valliant (1993) described for estimating totals. Rao et
51  al (2002) describe this procedure for estimating functions (and also
52  the GREG or g-calibration procedure, see \code{\link{calibrate}})
53
54}
55
56\note{
57  If the sampling weights are already post-stratified there will be no
58  change in point estimates after \code{postStratify} but the standard
59  error estimates will decrease to correctly reflect the post-stratification.
60}
61
62\value{
63 A new survey design object.
64}
65\references{
66Valliant R (1993) Post-stratification and conditional variance
67estimation. JASA 88: 89-96
68
69Rao JNK, Yung W, Hidiroglou MA (2002)   Estimating equations for the
70analysis of survey data using poststratification information. Sankhya
7164 Series A Part 2, 364-378.
72}
73
74\seealso{
75  \code{\link{rake}}, \code{\link{calibrate}} for other things to do
76  with auxiliary information
77
78  \code{\link{compressWeights}} for information on compressing weights}
79\examples{
80data(api)
81dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
82rclus1<-as.svrepdesign(dclus1)
83
84svymean(~api00, rclus1)
85svytotal(~enroll, rclus1)
86
87# post-stratify on school type
88pop.types <- data.frame(stype=c("E","H","M"), Freq=c(4421,755,1018))
89#or: pop.types <- xtabs(~stype, data=apipop)
90#or: pop.types <- table(stype=apipop$stype)
91
92rclus1p<-postStratify(rclus1, ~stype, pop.types)
93summary(rclus1p)
94svymean(~api00, rclus1p)
95svytotal(~enroll, rclus1p)
96
97
98## and for svydesign objects
99dclus1p<-postStratify(dclus1, ~stype, pop.types)
100summary(dclus1p)
101svymean(~api00, dclus1p)
102svytotal(~enroll, dclus1p)
103}
104\keyword{survey}% at least one, from doc/KEYWORDS
105\keyword{manip}
106