Website and Source code
The funStatTest
package implements various statistics
for two sample comparison testing regarding functional data introduced
and used in Smida et al 2022 [1].
This package is developed by:
To install the funStatTest
package, you can run:
install.packages("funStatTest")
You can also install the development version of
funStatTest
with the following command:
::install_git("https://plmlab.math.cnrs.fr/gdurif/funStatTest") remotes
See the package vignette and function manuals for more details about the package usage.
The funStatTest
was developed using the fusen
package [2]. See in the dev
sub-directory in the package
sources for more information, in particular:
dev/dev_history.Rmd
describing the development
processdev/flat_package.Rmd
defining the major
package functions (from which the vignette is extracted)dev/flat_internal.Rmd
defining package
internal functionsThe funStatTest
website was generated using the pkgdown
package
[3].
This is a basic example which shows you how to solve a common problem:
library(funStatTest)
We simulate two samples of trajectories diverging by a delta function.
<- simul_data(
simu_data n_point = 100, n_obs1 = 50, n_obs2 = 75, c_val = 10,
delta_shape = "quadratic", distrib = "normal"
)
plot_simu(simu_data)
We extract the matrices of trajectories associated to each sample:
<- simu_data$mat_sample1
MatX <- simu_data$mat_sample2 MatY
And we compute the different statistics for two sample function data comparison presented in Smida et al 2022 [1]:
<- comp_stat(MatX, MatY, stat = c("mo", "med", "wmw", "hkr", "cff"))
res
res#> $mo
#> [1] 0.9436923
#>
#> $med
#> [1] 0.9469112
#>
#> $wmw
#> [1] 0.8940712
#>
#> $hkr
#> [,1]
#> T1 2.548804e+08
#> T2 7.546891e+03
#>
#> $cff
#> [1] 12578.81
We can also compute p-values associated to these statistics:
# small data for the example
<- simul_data(
simu_data n_point = 20, n_obs1 = 4, n_obs2 = 5, c_val = 10,
delta_shape = "constant", distrib = "normal"
)
<- simu_data$mat_sample1
MatX <- simu_data$mat_sample2
MatY
<- permut_pval(
res n_perm = 200, stat = c("mo", "med", "wmw", "hkr", "cff"),
MatX, MatY, verbose = TRUE)
res#> $mo
#> [1] 0.009950249
#>
#> $med
#> [1] 0.009950249
#>
#> $wmw
#> [1] 0.009950249
#>
#> $hkr
#> T1 T2
#> 0.009950249 0.009950249
#>
#> $cff
#> [1] 0.009950249
:warning: computing p-values based on permutations may take some time (for large data or when using a large number of simulations. :warning:
And we can also run a simulation-based power analysis:
# simulate a few small data for the example
<- power_exp(
res n_simu = 20, alpha = 0.05, n_perm = 200,
stat = c("mo", "med", "wmw", "hkr", "cff"),
n_point = 25, n_obs1 = 4, n_obs2 = 5, c_val = 10, delta_shape = "constant",
distrib = "normal", max_iter = 10000, verbose = FALSE
)$power_res
res#> $mo
#> [1] 1
#>
#> $med
#> [1] 1
#>
#> $wmw
#> [1] 1
#>
#> $hkr
#> T1 T2
#> 1 1
#>
#> $cff
#> [1] 1