rake                  package:rake                  R Documentation

_C_r_e_a_t_e _a _w_e_i_g_h_t _s_u_m_m_a_r_y _R_a_k_e _f_o_r _a _s_a_m_p_l_e

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

     A 'rake' class object contains sample weights for a sample
     dataset, broken down by the factors of the two categorical
     response variables specified by 'colCol' and 'rowCol'.

     This is the first function in the 'rake', 'rakeadj',
     'predict.rake' Rake analysis series.

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

     rake(data,
          colCol = 1,
          rowCol = 2,
          weight = if("weight" %in% names(data)) "weight" else 1 )

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

    data: data.frame of sample observations.

  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.

  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)'.

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

     'rake' treats the columns of 'data' specified by 'colCol' and
     'rowCol' as factors and constructs a matrix that contains sample
     weights.

     The 'rake' class object has 'format', 'predict', and 'print' S3
     methods.

     Raking is the 2D analog of weighting-class adjustment. See
     References.

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

     Object of class 'rake' that contains sample weights broken down by
     class.

_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:

     'rakeadj' for performing the rake adjustment, 'predict.rake' for
     making estimates with the adjusted weight values, 'simpleRake' for
     performing the entire Raking process.

_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"

     r <- rake( certify, "COLLEGE", "WORKENV" )
     print(r) # Uses print.rake

