ppi_scale: Simulate and Compare Index Scale on Structured vs Noisy Data

View source: R/index_scale.R

ppi_scaleR Documentation

Simulate and Compare Index Scale on Structured vs Noisy Data

Description

Performs simulations to compute a projection pursuit index on structured (sampled) data and on random noise, allowing a comparison of index scale across contexts.

Usage

ppi_scale(
  data,
  index_fun,
  noise_fun = NULL,
  n_sim = 100,
  n_obs = 500,
  index_args = list(),
  seed = NULL,
  workers = 1
)

Arguments

data

A data frame or tibble with at least two numeric columns.

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

noise_fun

Optional function for generating noise data. It should take n_obs as input and return a 2-column matrix or data frame. By default, standard bivariate Gaussian noise is used.

n_sim

Integer. Number of simulations. Default is 100.

n_obs

Integer. Number of observations per simulation. Default is 500.

index_args

A named list of additional arguments passed to index_fun.

seed

Optional integer seed for reproducibility.

workers

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

Value

A tibble with columns:

  • simulation: simulation number

  • var_i, var_j: variable names

  • var_pair: pair name as a string

  • sigma: "structure" for structured data, "noise" for noisy data

  • index: index value returned by index_fun

Examples

ppi_scale(
  data_gen("polynomial", degree = 3),
  cassowaryr::sc_stringy,
  n_sim = 2,
  index_args = list(binner = "hex"),
  workers = 2
)

ppi_scale(
  data_gen("polynomial", degree = 3),
  scag_index("stringy"),
  n_sim = 2
)


spinebil documentation built on Oct. 28, 2026, 5:10 p.m.