1
$\begingroup$

The stype argument in boot of R can take 3 values: "i" which is the default, "w" or "f".

What is the concept of "w" and "f"? I really tried to find articles about this stuff, but they are scarce. Can anybody explain them to me and show examples of codes on how to use them for linear regression models (implementing bootstrapping)?

$\endgroup$
2
  • 2
    $\begingroup$ R does not have a native boot function. What package are you referring to? $\endgroup$
    – whuber
    Commented Feb 23, 2023 at 14:56
  • $\begingroup$ The "boot" package $\endgroup$
    – Hussain
    Commented Feb 23, 2023 at 18:04

1 Answer 1

1
$\begingroup$

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)

$\endgroup$
1
  • $\begingroup$ Thanks for the help Doctor Milt $\endgroup$
    – Hussain
    Commented Feb 24, 2023 at 10:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.