Skip to contents

This function calculates p-value for multiple lineups by using function calc_p_value().

Usage

calc_p_value_multi(
  dat,
  lineup_id,
  detect,
  n_sel,
  alpha,
  n_plot = 20,
  n_sim = 50000,
  dist = "dirichlet",
  cache_env = NULL,
  method = "linear_approx",
  replace_0 = TRUE
)

Arguments

dat

Data.frame/Tibble. A data.frame or a tibble.

lineup_id

Column of ids of lineup.

detect

Column of whether the lineup is detected by the subject.

n_sel

Column of the number of selections.

alpha

Column of the parameter values used by the Dirichlet distribution.

n_plot

Integer. Number of plots.

n_sim

Integer. Number of simulation draws.

dist

Character. Name of the distribution used for the attractiveness simulation. One of "uniform" and "dirichlet".

cache_env

Environment. A provided environment for caching.

method

Character. Method of p-value calculation. "linear_approx" for linear approximation and "simulate" for simulation.

replace_0

Boolean. Whether to treat evaluations with number of selections equal to 0 as selecting all the plots.

Value

A tibble with one column for lineup id and one column for the p-value.

Details

It is encouraged to provide a cache environment to boost up the performance. The cache environment will remember the result corresponding to the combinations of n_eval and n_sim. replace_0 can be turned on to set evaluations with 0 selections to be false detection with 20 selections.

There are two attractiveness distribution available, one is uniform distribution, another is Dirichlet distribution. Uniform distribution ensures the marginal distribution of the probability of every plot being selected is uniform. When \(\alpha = 1\), Dirichlet distribution ensures the probability of every plot being selected is evenly distributed in a standard \(M - 1\) simplex.

Examples

dat <- data.frame(unique_lineup_id = c(1,1,2),
                  detect_or_not = c(TRUE, FALSE, TRUE),
                  num_selection = c(1,1,2))
calc_p_value_multi(dat, unique_lineup_id, detect_or_not, num_selection)
#> # A tibble: 2 × 2
#>   unique_lineup_id p_value
#>              <dbl>   <dbl>
#> 1                1  0.0952
#> 2                2  0.525