Skip to contents

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, n_sim = 100, n_obs = 500, seed = NULL)

Arguments

data

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

index_fun

A function that takes two numeric vectors (x, y) and returns a numeric scalar index.

n_sim

Integer. Number of simulations. Default is 100.

n_obs

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

seed

Optional integer seed for reproducibility.

Value

A tibble with columns:

  • simulation: simulation number

  • var_i, var_j: variable names

  • var_pair: pair name as a string

  • sigma: 0 for structured data, 1 for noisy data

  • index: index value returned by index_fun

Examples

ppi_scale(data_gen("polynomial", degree = 3), scag_index("stringy"), n_sim = 10)
#> # A tibble: 60 × 6
#>    simulation var_i var_j var_pair sigma index
#>         <int> <chr> <chr> <chr>    <dbl> <dbl>
#>  1          1 1     2     1-2          0 1    
#>  2          1 1     2     1-2          1 0.708
#>  3          1 1     3     1-3          0 1    
#>  4          1 1     3     1-3          1 0.743
#>  5          1 2     3     2-3          0 0.996
#>  6          1 2     3     2-3          1 0.743
#>  7          2 1     2     1-2          0 1    
#>  8          2 1     2     1-2          1 0.687
#>  9          2 1     3     1-3          0 1    
#> 10          2 1     3     1-3          1 0.720
#> # ℹ 50 more rows