You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: R/two-sample-diagram-test.R
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -59,6 +59,8 @@
59
59
#' the null distribution (if `keep_null_distribution` is set to `TRUE`) and
60
60
#' the list of sampled permutations (if `keep_permutations` is set to `TRUE`).
61
61
#'
62
+
#' @references Lovato, I., Pini, A., Stamm, A., & Vantini, S. (2020). Model-free two-sample test for network-valued data. Computational Statistics & Data Analysis, 144, 106896.
63
+
#'
62
64
#' @export
63
65
#' @examples
64
66
#' two_sample_diagram_test(trefoils1[1:5], trefoils2[1:5], B = 100L)
function to perform a two-sample test on these persistence diagrams. For
64
-
example, to test whether the first 5 persistence diagrams from the first set are
65
-
significantly different from the first 5 persistence diagrams from the second
66
-
set, you can run:
67
+
function to perform a two-sample test on these persistence diagrams in the space of diagrams themselves. For
68
+
example, to test whether the persistence diagrams from `trefoils1` are
69
+
significantly different from the persistence diagrams from `trefoils2`, you can run:
70
+
71
+
```{r}
72
+
two_sample_diagram_test(trefoils1, trefoils2, B = 100L)
73
+
```
74
+
75
+
To test whether the persistence diagrams from `trefoils1` are
76
+
significantly different from the persistence diagrams from `archspirals`, you can run:
67
77
68
78
```{r}
69
-
two_sample_diagram_test(trefoils1[1:5], trefoils2[1:5], B = 100L)
79
+
two_sample_diagram_test(trefoils1, archspirals, B = 100L)
70
80
```
71
81
72
-
To test whether the first 5 persistence diagrams from the first set are
73
-
significantly different from the first 5 persistence diagrams from the third
74
-
set, you can run:
82
+
Optionnally, the `two_sample_diagram_test()` function can also output the distribution of the test statistic under the null hypothesis as estimated by the permutation scheme. To do that, you can use the optional argument `keep_null_distribution = TRUE`. It is also possible to ask for the permutations themselves to be saved as part of the output. To do that, you can use the optional argument `keep_permutations = TRUE`.
83
+
84
+
Test in the space of diagrams themselves is performed using test statistics that only rely on distances between sampled diagrams. By default, two such statistics that mimic Student's t-statistic and Fisher's F-statistic are used as proposed in Lovato, I., Pini, A., Stamm, A., & Vantini, S. (2020), *Model-free two-sample test for network-valued data*. Computational Statistics & Data Analysis, **144**, 106896.
85
+
86
+
### Test in functional spaces
87
+
88
+
You can use the [`two_sample_functional_test()`](https://tdaverse.github.io/inphr/reference/two_sample_functional_test.html) function to perform a two-sample test on these persistence diagrams in functional spaces using one of five functional representations of persistence diagrams, namely: (i) Betti, (ii) Euler characteristic, (iii) normalized life, (iv) silhouette and (v) entropy curves. Computation of these functional representations is powered by the [{TDAvec}](https://cran.r-project.org/package=TDAvec) package. For
89
+
example, to test whether the persistence diagrams from `trefoils1` are
90
+
significantly different from the persistence diagrams from `archspirals`, you can use the Betti curve representation and run:
91
+
92
+
```{r, eval = FALSE}
93
+
out <- two_sample_functional_test(
94
+
trefoils1,
95
+
archspirals,
96
+
representation = "betti",
97
+
B = 100L
98
+
)
99
+
```
100
+
101
+
```{r, include = FALSE}
102
+
out <- two_sample_functional_test(
103
+
trefoils1,
104
+
archspirals,
105
+
representation = "betti",
106
+
B = 100L
107
+
)
108
+
```
109
+
110
+
The output is a length-4 list. The first two elements are `xfd` and `yfd` which are numeric matrices storing evaluations of the functional representation of the diagrams on a grid stored as the third element `scale_seq`. You can therefore have a look at the functional data that the function produced using something like:
111
+
112
+
```{r}
113
+
matplot(
114
+
out$scale_seq[-1],
115
+
t(rbind(out$xfd, out$yfd)),
116
+
type = "l",
117
+
col = c(rep(1, length(trefoils1)), rep(2, length(archspirals)))
118
+
)
119
+
```
120
+
121
+
In the case of testing in functional spaces, {inphr} uses the interval-wise testing (IWT) procedure powered by the [{fdatest}](https://cran.r-project.org/package=fdatest) package which has been proposed in Pini, A., & Vantini, S. (2017), *Interval-wise testing for functional data*. Journal of Nonparametric Statistics, **29**(2), 407-424.
122
+
123
+
The output indicates on which portions of the scale sequence does the difference between the two samples occur, providing strong control of the familywise error rate:
75
124
76
125
```{r}
77
-
two_sample_diagram_test(trefoils1[1:5], archspirals[1:5], B = 100L)
0 commit comments