simpleRake {rake} | R Documentation |
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
.
simpleRake(data, marg, colCol = 1, rowCol = 2, col = 3, forcefactor = FALSE, weight = if("weight" %in% names(data)) "weight" else 1, verbose = FALSE)
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? |
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. |
Toby Dylan Hocking <tdhock@ocf.berkeley.edu>
Sharon L. Lohr. Sampling: Design and Analysis, pp. 269-271. Brooks/Cole, Pacific Grove, CA, 1999.
rake
for creating the initial "rake" class object,
rakeadj
for performing the rake adjustment,
predict.rake
for making estimates with the adjusted weight
values.
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))