rake {rake} | R Documentation |
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.
rake(data, colCol = 1, rowCol = 2, weight = if("weight" %in% names(data)) "weight" else 1 )
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) . |
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.
Object of class rake
that contains sample weights broken down
by class.
Toby Dylan Hocking <tdhock@ocf.berkeley.edu>
Sharon L. Lohr. Sampling: Design and Analysis, pp. 269-271. Brooks/Cole, Pacific Grove, CA, 1999.
rakeadj
for performing the rake adjustment,
predict.rake
for making estimates with the adjusted weight
values,
simpleRake
for performing the entire Raking process.
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