Learn R Programming

detect (version 0.3-0)

hbootindex: Hierarchical bootstrap indices

Description

Generates hierarchical bootstrap indices.

Usage

hbootindex(groups, strata, B = 199)

Arguments

groups
group membership vector.
strata
strata, optional.
B
number of bootstrap iterations.

Value

  • A list with bootstrapped indices, list length is B + 1. The first element has 1:length(groups) samples without replacement (random subsets can be selected without further reshuffling). Other elements contain indices according to rules described in Details section (these are also randomly reshuffled to facilitate the creation of random subsets). Length of resampled vectors are of different lengths when group sizes are unequal (due to group level resampling).

Details

Resampling with replacement is done at two levels. The first level is the group ID level: group IDs (unique values in groups) are resampled with replacement. The second level is observations within resampled group ID levels: observations within these levels are resampled with replacement. Values of groups within levels (unique values) of strata are resampled independently of other strata levels.

Examples

Run this code
## equal group sizes
groups <- rep(1:4, each=5)
strata <- rep(1:2, each=10)
hbootindex(groups, strata, 3)

## unequal group sizes
groups <- groups[-c(5,9,10,11)]
strata <- strata[-c(5,9,10,11)]
hbootindex(groups, strata, 3)

Run the code above in your browser using DataLab