postStratify             package:survey             R Documentation

_P_o_s_t-_s_t_r_a_t_i_f_y _a _s_u_r_v_e_y

_D_e_s_c_r_i_p_t_i_o_n:

     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.

_U_s_a_g_e:

     postStratify(design, strata, population, partial = FALSE, ...)
     ## S3 method for class 'svyrep.design':
     postStratify(design, strata, population, partial = FALSE, compress=NULL,...)
     ## S3 method for class 'survey.design':
     postStratify(design, strata, population, partial = FALSE, ...)

_A_r_g_u_m_e_n_t_s:

  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

compress: Attempt to compress the replicate weight matrix? When 'NULL'
          will attempt to compress if the original weight matrix was
          compressed

     ...: arguments for future expansion

_D_e_t_a_i_l_s:

     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.

     Compressing the replicate weights will take time and may even
     increase memory use if there is actually little redundancy in the
     weight matrix (in particular if the post-stratification variables
     have many values and cut  across PSUs).

     The method for 'survey.design' objects should be used only in
     fairly large samples as the resulting standard errors use a simple
     first-order approximation.

_V_a_l_u_e:

     A new survey design object.

_R_e_f_e_r_e_n_c_e_s:

_S_e_e _A_l_s_o:

     'as.svrepdesign', 'svrepdesign', 'rake', 'compressWeights'

_E_x_a_m_p_l_e_s:

     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)

     ## and for svydesign objects
     dclus1p<-postStratify(dclus1, ~stype, pop.types)
     summary(dclus1p)
     svymean(~api00, dclus1p)
     svytotal(~enroll, dclus1p)

