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

Description Usage Arguments Details Value Examples

View source: R/helper-boot.r

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 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.

Usage

1
  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

Details

The returned list contains K \times num_reps elements.

Value

named list containing indices for each bootstrap replication

Examples

 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)

clusteval documentation built on May 29, 2017, 11:45 p.m.