Computes a rank-based Monte Carlo p-value with the standard +1 correction. The helper is intended for comparing a scalar observed statistic with the corresponding statistics from simulated trajectories.
Usage
mc_rank_test(
observed,
simulated,
alternative = c("two.sided", "less", "greater")
)Arguments
- observed
Numeric scalar observed statistic.
- simulated
Numeric vector of simulated statistics.
- alternative
Character. One of
"two.sided","less", or"greater". For"greater", small p-values indicate thatobservedis unusually large relative tosimulated. For"less", small p-values indicate thatobservedis unusually small.
References
North, B. V., Curtis, D., and Sham, P. C. (2002). A note on the calculation of empirical P values from Monte Carlo procedures. American Journal of Human Genetics, 71(2), 439-441. https://doi.org/10.1086/341527
Examples
mc_rank_test(5, c(1, 2, 3, 4), alternative = "greater")
#> $observed
#> [1] 5
#>
#> $simulated
#> [1] 1 2 3 4
#>
#> $rank
#> [1] 5
#>
#> $p_value
#> [1] 0.2
#>
#> $alternative
#> [1] "greater"
#>
#> attr(,"class")
#> [1] "gmov_mc_rank_test" "list"