[Maturing]

Performs one or two sample t-tests or Wilcoxon-Mann-Whitney rank-based tests with expanded options compared to t.test, brunner_munzel, or wilcox.test.

simple_htest(
  x,
  ...,
  paired = FALSE,
  alternative = c("two.sided", "less", "greater", "equivalence", "minimal.effect"),
  mu = NULL,
  alpha = 0.05
)

# S3 method for default
simple_htest(
  x,
  y = NULL,
  test = c("t.test", "wilcox.test", "brunner_munzel"),
  paired = FALSE,
  alternative = c("two.sided", "less", "greater", "equivalence", "minimal.effect"),
  mu = NULL,
  alpha = 0.05,
  ...
)

# S3 method for formula
simple_htest(formula, data, subset, na.action, ...)

Arguments

x

a (non-empty) numeric vector of data values.

...

further arguments to be passed to or from methods.

paired

a logical indicating whether you want a paired t-test.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater", "less", "equivalence" (TOST), or "minimal.effect" (TOST). You can specify just the initial letter.

mu

a number specifying an optional parameter used to form the null hypothesis. See ‘Details’.

alpha

alpha level (default = 0.05)

y

an optional (non-empty) numeric vector of data values.

test

a character string specifying what type of hypothesis test to use. Options are limited to "wilcox.test", "t.test", or "brunner_munzel". You can specify just the initial letter.

formula

a formula of the form lhs ~ rhs where lhs is a numeric variable giving the data values and rhs either 1 for a one-sample or paired test or a factor with two levels giving the corresponding groups. If lhs is of class "Pair" and rhs is 1, a paired test is done.

data

an optional matrix or data frame (or similar: see model.frame) containing the variables in the formula formula. By default the variables are taken from environment(formula).

subset

an optional vector specifying a subset of observations to be used.

na.action

a function which indicates what should happen when the data contain NAs. Defaults to getOption("na.action").

Value

A list with class "htest" containing the following components:

  • statistic: the value of the t-statistic.

  • parameter: the degrees of freedom for the t-statistic.

  • p.value: the p-value for the test.

  • conf.int: a confidence interval for the mean appropriate to the specified alternative hypothesis.

  • estimate: the estimated mean or difference in means depending on whether it was a one-sample test or a two-sample test.

  • null.value: the specified hypothesized value of the mean or mean difference. May be 2 values.

  • stderr: the standard error of the mean (difference), used as denominator in the t-statistic formula.

  • alternative: a character string describing the alternative hypothesis.

  • method: a character string indicating what type of t-test was performed.

  • data.name: a character string giving the name(s) of the data.

Details

The type of test, t-test/Wilcoxon-Mann-Whitney/Brunner-Munzel, can be selected with the "test" argument.

alternative = "greater" is the alternative that x is larger than y (on average). If alternative = "equivalence" then the alternative is that the difference between x and y is between the two null values mu.. If alternative = "minimal.effect" then the alternative is that the difference between x and y is less than the lowest null value or greater than the highest.

For more details on each possible test (brunner_munzel, stats::t.test, or stats::wilcox.test), please read their individual documentation.

See also

Other TOST: boot_log_TOST(), boot_t_TOST(), t_TOST(), tsum_TOST(), wilcox_TOST()

Other htest: as_htest(), htest-helpers

Examples

data(mtcars)
simple_htest(mpg ~ am,
data = mtcars,
alternative = "e",
mu = 3)
#> 
#> 	Welch Two Sample t-test
#> 
#> data:  mpg by am
#> t = -2.2072, df = 18.332, p-value = 0.9799
#> alternative hypothesis: equivalence
#> null values:
#> difference in means difference in means 
#>                  -3                   3 
#> 90 percent confidence interval:
#>  -10.576623  -3.913256
#> sample estimates:
#> mean of x mean of y 
#>  17.14737  24.39231 
#>