simpleRake               package:rake               R Documentation

_P_e_r_f_o_r_m _a _c_o_m_p_l_e_t_e _R_a_k_i_n_g

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

     'simpleRake' is provided as a wrapper function for the most common
     method of Rake analysis. It calls 'rake' and 'rakeadj', then
     returns the result of 'predict.rake'.

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

     simpleRake(data, marg,
                colCol = 1, rowCol = 2,
                col = 3, forcefactor = FALSE,
                weight = if("weight" %in% names(data)) "weight" else 1,
                verbose = FALSE)

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

    data: data.frame of sample observations.

    marg: the population marginal total weights. This may be specified
          in any of the following ways:

          numeric: vector of marginal total weights, matched to the
          values in 'rake' by name.

          data.frame: column "weight" must contain the weights, matched
          by names specified in column "name".

          character: filename of an appropriate table that will be read
          as a 'data.frame'.

  colCol: column of 'data' whose data will be put in the columns of the
          rake object.

  rowCol: column of 'data' whose data will be put in the rows of the
          rake object.

     col: column of 'data' from which re-weighted data will be gathered
          and returned.

forcefactor: logical: should 'data[,col]' be treated as a factor, even
          if it is numeric data?

  weight: weights of sample observations, specified as either the
          column name of 'data' that contains the weights, or a numeric
          vector of weights that will be replicated to be as long as
          'nrow(data)'.

 verbose: logical: Should the number of iterations for the rake
          adjustment to converge be printed?

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

     List with entries: 

    data: the original data of interest.

  weight: the adjusted weights from 'rake', formatted as a vector that
          corresponds to a column of 'data'.

data.est: the data of interest after re-weighting.

_A_u_t_h_o_r(_s):

     Toby Dylan Hocking <tdhock@ocf.berkeley.edu>

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

     Sharon L. Lohr. Sampling: Design and Analysis, pp. 269-271.
     Brooks/Cole, Pacific Grove, CA, 1999.

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

     'rake' for creating the initial "rake" class object, 'rakeadj' for
     performing the rake adjustment, 'predict.rake' for making
     estimates with the adjusted weight values.

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

     data(certify)

     # Merge some classes since we have limited population data
     # We define classes of COLLEGE as P or not P = N
     certify$COLLEGE[   certify$COLLEGE  !=    "P"      ] <- "N"
     # We define classes of WORKENV to be I, A, or else = O
     certify$WORKENV[ ! certify$WORKENV %in% c("I","A") ] <- "O"

     rakeresult <- simpleRake(certify, statpoptotal, "WORKENV", "COLLEGE",
     "WOULDYOU", TRUE)

     data <- rakeresult$data
     pred <- rakeresult$data.est
     print(rbind(data,pred))

