Skip to content

Commit b26d90a

Browse files
committed
replace Mean with Difference
1 parent de3245f commit b26d90a

File tree

6 files changed

+64
-52
lines changed

6 files changed

+64
-52
lines changed

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ export(CDF)
66
export(ChiSquare)
77
export(ContingencyTableTest)
88
export(Correlation)
9+
export(Difference)
910
export(Friedman)
1011
export(JonckheereTerpstra)
1112
export(KSampleTest)
1213
export(KolmogorovSmirnov)
1314
export(KruskalWallis)
14-
export(Mean)
1515
export(MultiCompT)
1616
export(MultipleComparison)
1717
export(OneSampleTest)

R/Difference.R

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#' @title `r Difference$private_fields$.name`
2+
#'
3+
#' @description Performs mean based two sample permutation test on data vectors.
4+
#'
5+
#' @aliases twosample.difference
6+
#'
7+
#' @export
8+
#'
9+
#' @importFrom R6 R6Class
10+
11+
12+
Difference <- R6Class(
13+
classname = "Difference",
14+
inherit = TwoSampleTest,
15+
cloneable = FALSE,
16+
public = list(
17+
#' @description Create a new `Difference` object.
18+
#'
19+
#' @template init_params
20+
#'
21+
#' @return A `Difference` object.
22+
initialize = function(
23+
method = c("mean", "median"),
24+
alternative = c("two_sided", "less", "greater"), n_permu = NULL
25+
) {
26+
private$.method <- match.arg(method)
27+
28+
super$initialize(alternative = match.arg(alternative), n_permu = n_permu)
29+
}
30+
),
31+
private = list(
32+
.name = "Two Sample Test Based on Mean or Median",
33+
34+
.define_statistic = function() {
35+
private$.statistic_func <- switch(private$.method,
36+
mean = function(x, y) mean(x) - mean(y),
37+
median = function(x, y) median(x) - median(y)
38+
)
39+
}
40+
)
41+
)

R/Mean.R

Lines changed: 0 additions & 33 deletions
This file was deleted.

R/pmt.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tests <- list(
99
onesample.quantile = Quantile,
1010
onesample.cdf = CDF,
1111

12-
twosample.mean = Mean,
12+
twosample.difference = Difference,
1313
twosample.wilcoxon = Wilcoxon,
1414
twosample.scoresum = ScoreSum,
1515
twosample.ansari = AnsariBradley,

man/Mean.Rd renamed to man/Difference.Rd

Lines changed: 16 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vignettes/examples.Rmd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ t$ci
7777
## Table 2.1.1
7878

7979
```{r}
80-
# See ?Mean or ?twosample.mean
80+
# See ?Difference or ?twosample.difference
8181
t <- pmt(
82-
"twosample.mean", alternative = "greater"
82+
"twosample.difference", alternative = "greater", method = "mean"
8383
)
8484
8585
# See ?Table2.1.1
@@ -107,9 +107,9 @@ t$p_value
107107
## Example 2.3.1
108108

109109
```{r}
110-
# See ?Mean or ?twosample.mean
110+
# See ?Difference or ?twosample.difference
111111
t <- pmt(
112-
"twosample.mean", alternative = "greater"
112+
"twosample.difference", alternative = "greater", method = "mean"
113113
)
114114
115115
# See ?Table2.3.1
@@ -194,7 +194,7 @@ t$p_value
194194
## Example 2.8.2
195195

196196
```{r}
197-
# See ?RatioMeanDeviance or ?twosample.rmd
197+
# See ?RatioDifferenceDeviance or ?twosample.rmd
198198
t <- pmt(
199199
"twosample.rmd", alternative = "greater"
200200
)

0 commit comments

Comments
 (0)