Learn R Programming

clusteval (version 0.1)

boot_stratified_omit: Creates a list of indices for a stratified nonparametric bootstrap.

Description

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 $k$th 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.

Usage

boot_stratified_omit(y, num_reps = 50)

Arguments

y
a vector that denotes the grouping of each observation. It must be coercible with as.factor.
num_reps
the number of bootstrap replications to use for each group

Value

named list containing indices for each bootstrap replication

Details

The returned list contains $K \times num_reps$ elements.

Examples

Run this code
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)

Run the code above in your browser using DataLab