What is the concept of "w" and "f"?
A simple call to boot::boot
is
boot(data, statistic, R, stype)
[Note: I'm assuming that sim = "ordinary"
, the default.]
This will take a data set (data
), generate the desired number of bootstrap replicates (R
), and compute some sample statistic (statistic
) for each one.
The function statistic
requires two arguments; the first is the original data (data
), whereas the second argument tells it which rows/elements of the original data appear in a particular bootstrap sample. You can do this in three different ways, which correspond to the three possible arguments for stype
.
Suppose that you just want to compute the sample mean of each bootstrap replicate. You can specify this in three different ways:
Indices (stype = "i"
) are the indices of the elements that appear in this sample, so your statistic
would be
mean_i <- function(data, indices) mean(data[indices])
Frequencies (stype = "f"
): are the raw frequencies of each element in this sample, so your statistic
would be
mean_f <- function(data, frequencies) sum(data * frequencies) / sum(frequencies)
Weights (stype = "w"
): are the relative frequencies (weights) of each element in this sample, so your statistic
would be
mean_weights <- function(data, weights) sum(data * weights)
R
does not have a nativeboot
function. What package are you referring to? $\endgroup$