Skip to contents

For a given index function, simulates how the index behaves across a range of sample sizes. By default, standard bivariate Gaussian noise is used, but the user may instead supply a 2-column dataset to sample from.

Usage

ppi_samplesize_effect(
  index_fun,
  sample_sizes = 100,
  n_sim = 100,
  data = NULL,
  csv_file = NULL,
  index_args = list(),
  workers = 1
)

Arguments

index_fun

A function returning a numeric scalar index. It may accept either a 2-column matrix/data frame, or two numeric vectors (x, y).

sample_sizes

Numeric vector (e.g., 100, c(50,100,200), seq(30,200,5)). Default is 100.

n_sim

Integer. Number of simulations per sample size.

data

Optional 2-column data frame, tibble, or matrix to sample from. If NULL, standard bivariate Gaussian noise is used.

csv_file

Optional file path to save results as CSV.

index_args

A named list of additional arguments passed to index_fun.

workers

Integer. Number of parallel workers to use. Default is 1.

Value

A tibble with:

  • sample_size: sample size used for each simulation block

  • percentile95: 95th percentile of the index values over simulations

Examples

if (FALSE) { # \dontrun{
ppi_samplesize_effect(
  cassowaryr::sc_stringy,
  sample_sizes = c(100, 300),
  n_sim = 3,
  index_args = list(binner = "hex"),
  workers = 2
)

ppi_samplesize_effect(
  cassowaryr::sc_skinny,
  sample_sizes = c(100, 300),
  n_sim = 3,
  data = data_gen("polynomial", degree = 2),
  workers = 2
)
} # }