Bootstrap Sample from a Population Grouped by Items
bootstrap_samples.Rd
This function allows you to bootstrap samples across various sample sizes when the data (optionally) has repeated measures items.
Usage
bootstrap_samples(
start = 20,
stop = 100,
increase = 5,
population,
replace = TRUE,
nsim = 100,
grouping_items = NULL
)
Arguments
- start
Sample size for the smallest potential sample
- stop
Sample size for the largest potential sample
- increase
Number to increase the sample size with for each potential sample
- population
The population data set or the pilot dataset
- replace
A TRUE/FALSE value to bootstrap with replacement
- nsim
The number of simulations/samples you want to return
- grouping_items
The names of columns to group your data by for the simulation, usually this column is the item column
Examples
# step 1 create data like what I think I'll get or use your own
pops <- simulate_population(mu = 4, mu_sigma = .2, sigma = 2,
sigma_sigma = .2, number_items = 30, number_scores = 20,
smallest_sigma = .02, min_score = 1, max_score = 7, digits = 0)
# step 3 simulate bootstrapped samples
samples <- bootstrap_samples(start = 20, stop = 100,
increase = 5, population = pops,
replace = TRUE, grouping_items = NULL)
# notice just 20 items
samples[[1]]
#> item score
#> 1 15 2
#> 2 27 3
#> 3 7 5
#> 4 19 4
#> 5 13 1
#> 6 11 2
#> 7 7 2
#> 8 4 6
#> 9 30 3
#> 10 29 7
#> 11 1 4
#> 12 24 5
#> 13 12 5
#> 14 14 1
#> 15 23 2
#> 16 15 3
#> 17 1 1
#> 18 7 2
#> 19 16 3
#> 20 30 3
samples <- bootstrap_samples(start = 20, stop = 100,
increase = 5, population = pops,
replace = TRUE, grouping_items = "item")
# notice 20 rows per item
samples[[1]]
#> # A tibble: 600 × 2
#> # Groups: item [30]
#> item score
#> <int> <dbl>
#> 1 1 2
#> 2 1 2
#> 3 1 6
#> 4 1 2
#> 5 1 3
#> 6 1 2
#> 7 1 1
#> 8 1 2
#> 9 1 1
#> 10 1 5
#> # ℹ 590 more rows