rake {rake}R Documentation

Create a weight summary Rake for a sample

Description

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.

Usage

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

Arguments

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

Details

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.

Value

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

Author(s)

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

References

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

See Also

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

Examples

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

[Package rake version 1.0 Index]