Description Usage Arguments Details Value Examples
This function creates a list of indices for a stratified
nonparametric bootstrap. Corresponding to our Cluster
Omission Stability statistic implemented in
clustomit
, we omit each group in turn and
perform a stratified bootstrap without the group. We
denote the number of groups as num_clusters
, which
is equal to nlevels(factor(y))
. Specifically,
suppose that we omit the kth group. That is, we
ignore all of the observations corresponding to group
k. Then, we sample with replacement from each of
the remaining groups (i.e., every group except for group
k), yielding a set of bootstrap indices.
1 | boot_stratified_omit(y, num_reps = 50)
|
y |
a vector that denotes the grouping of each
observation. It must be coercible with |
num_reps |
the number of bootstrap replications to use for each group |
The returned list contains K \times num_reps elements.
named list containing indices for each bootstrap replication
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | set.seed(42)
# We use 4 clusters, each with up to 10 observations. The sample sizes are
# randomly chosen.
num_clusters <- 4
sample_sizes <- sample(10, num_clusters, replace = TRUE)
# Create the cluster labels, y.
y <- unlist(sapply(seq_len(num_clusters), function(k) {
rep(k, sample_sizes[k])
}))
# Use 20 reps per group.
boot_stratified_omit(y, num_reps = 20)
# Use the default number of reps per group.
boot_stratified_omit(y)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.