Skip to content
Snippets Groups Projects
Commit 88a6a3a0 authored by Ghislain Durif's avatar Ghislain Durif
Browse files

WIP: pvalues computation by permutation

parent 7501ff33
No related branches found
No related tags found
No related merge requests found
......@@ -269,7 +269,9 @@ str(simu_data)
#'
#' @param simu list, output of [funStatTest::simul_data()]
#'
#' @seealso [funStatTest::simulate_data()]
#' @return the ggplot2 graph of simulated tajectories.
#'
#' @seealso [funStatTest::simul_data()]
#'
#' @inherit authorship author
#'
......@@ -380,6 +382,8 @@ The $MO$ median statistic [1] is implemented in the `stat_mo()` function.
#' [<DOI:10.1080/10485252.2022.2064997>](https://dx.doi.org/10.1080/10485252.2022.2064997)
#' [<hal-03658578>](https://hal.science/hal-03658578)
#'
#' @seealso [funStatTest::permut_pval()]
#'
#' @export
#'
#' @examples
......@@ -473,6 +477,8 @@ The $MED$ median statistic [1] is implemented in the `stat_med()` function.
#' [<DOI:10.1080/10485252.2022.2064997>](https://dx.doi.org/10.1080/10485252.2022.2064997)
#' [<hal-03658578>](https://hal.science/hal-03658578)
#'
#' @seealso [funStatTest::permut_pval()]
#'
#' @export
#'
#' @examples
......@@ -572,6 +578,9 @@ The Wilcoxon-Mann-Whitney statistic [2] (noted $WMW$ in [1]) is implemented in t
#' 34:2, 520-553,
#' [<DOI:10.1080/10485252.2022.2064997>](https://dx.doi.org/10.1080/10485252.2022.2064997)
#' [<hal-03658578>](https://hal.science/hal-03658578)
#'
#' @seealso [funStatTest::permut_pval()]
#'
#' @export
#'
#' @examples
......@@ -660,6 +669,8 @@ The Horváth-Kokoszka-Reeder statistics [3] (noted $HKR1$ and $HKR2$ in [1]) are
#' [<DOI:10.1080/10485252.2022.2064997>](https://dx.doi.org/10.1080/10485252.2022.2064997)
#' [<hal-03658578>](https://hal.science/hal-03658578)
#'
#' @seealso [funStatTest::permut_pval()]
#'
#' @export
#'
#' @examples
......@@ -783,6 +794,8 @@ The Cuevas-Febrero-Fraiman statistic [4] (noted $CFF$ in [1]) ais implemented in
#' [<DOI:10.1080/10485252.2022.2064997>](https://dx.doi.org/10.1080/10485252.2022.2064997)
#' [<hal-03658578>](https://hal.science/hal-03658578)
#'
#' @seealso [funStatTest::permut_pval()]
#'
#' @export
#'
#' @examples
......@@ -821,8 +834,65 @@ MatY <- simu_data$mat_sample2
stat_cff(MatX, MatY)
```
## Permutation-based computation of p-values
```{r function-permut_pval}
#' Permutation-based computation of p-values
#'
#' @filename pvalues.R
#'
#' @description Computation of the p-values associated to any statistics
#' described in the package with the permutation methods. See Smida et al
#' (2022) for more details.
#'
#' @param MatX numeric matrix of dimension `n_point x n` containing `n`
#' trajectories (in columns) of size `n_point` (in rows).
#' @param MatY numeric matrix of dimension `n_point x m` containing `m`
#' trajectories (in columns) of size `n_point` (in rows).
#' @param stat character string or vector of character string, name of the
#' statistics for which the p-values will be computed, among `"mo"`, `"med"`,
#' `"wmw"`, `"hkr"`, `"cff"`.
#' @param n_perm interger, number of permutation to compute the p-values.
#'
#' @return numeric value corresponding to the WMW statistic value
#'
#' @inherit authorship author
#'
#' @references
#' Zaineb Smida, Lionel Cucala, Ali Gannoun & Ghislain Durif (2022)
#' A median test for functional data, Journal of Nonparametric Statistics,
#' 34:2, 520-553,
#' [<DOI:10.1080/10485252.2022.2064997>](https://dx.doi.org/10.1080/10485252.2022.2064997)
#' [<hal-03658578>](https://hal.science/hal-03658578)
#'
#' @seealso [funStatTest::stat_mo()], [funStatTest::stat_med()],
#' [funStatTest::stat_wmw()], [funStatTest::stat_hkr()],
#' [funStatTest::stat_cff()]
#'
#' @export
#'
#' @examples
permut_pval <- function(MatX, MatY, n_perm = 100, stat = c("mo", "med")) {
assert_count(n_perm, positive = TRUE)
assert_choice(stat, c("mo", "med", "wmw", "hkr", "cff"))
}
```
```{r tests-permut_pval}
test_that("permut_pval", {
expect_true(TRUE)
})
```
```{r examples-permut_pval}
simu_data <- simul_data(
n_point = 100, n_obs1 = 50, n_obs2 = 75, c_val = 10,
delta_shape = "constant", distrib = "normal"
)
MatX <- simu_data$mat_sample1
MatY <- simu_data$mat_sample2
```
## References
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment