Skip to contents

This function allows you to simulate samples across various sample sizes when the data (optionally) has repeated measures items.

Usage

simulate_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 simulate 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

Value

samples

The simulated samples for each tested sample size.

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 samples
samples <- simulate_samples(start = 20, stop = 100,
  increase = 5, population = pops,
  replace = TRUE, grouping_items = NULL)

# notice just 20 items
samples[[1]]
#>    item score
#> 1    22     5
#> 2    13     5
#> 3    30     4
#> 4    30     5
#> 5    15     6
#> 6    14     2
#> 7    27     4
#> 8    13     3
#> 9     3     6
#> 10   11     4
#> 11   26     4
#> 12    9     3
#> 13    7     5
#> 14   19     5
#> 15   12     1
#> 16   15     5
#> 17   23     4
#> 18   30     3
#> 19   17     5
#> 20   24     3

samples <- simulate_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     5
#>  2     1     1
#>  3     1     6
#>  4     1     3
#>  5     1     6
#>  6     1     6
#>  7     1     6
#>  8     1     1
#>  9     1     6
#> 10     1     1
#> # ℹ 590 more rows