tTest {MDMA}R Documentation

t Test

Description

perform t tests with the possibility of inputting group statistics.

[Stable]

Usage

tTest(
  x,
  y = NULL,
  sdx = NULL,
  sdy = NULL,
  nx = length(na.omit(x)),
  ny = length(na.omit(y)),
  alternative = c("two.sided", "greater", "less"),
  mu = 0,
  paired = FALSE,
  rxy = NULL,
  var.equal = FALSE,
  conf.level = 0.95
)

Arguments

x

a numeric vector. Can be of length 1 for a group mean.

y

a numeric vector. Should be NULL for a one-sample t-test.

sdx

standard deviation for x, when this reflects a group mean.

sdy

standard deviation for y, when this reflects a group mean.

nx

sample size for x, when this reflects a group mean.

ny

sample size for y, when this reflects a group mean.

alternative

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

mu

a number indicating the true value of the mean (or difference in means) if you are performing an independent samples t-test).

paired

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

rxy

correlation between two paired samples.

var.equal

a logical variable indicating whether to treat the two variances as being equal. If TRUE then the pooled variance is used to estimate the variance otherwise the Welch (or Satterthwaite) approximation to the degrees of freedom is used.

conf.level

level of the confidence interval.

Value

tTest performs a t-test (independent samples, paired samples, one sample) just like base-R t.test, but with the extended possibility to enter group statistics instead of raw data.

Author(s)

Mathijs Deen

Examples

library(MASS)
set.seed(1)
ds <- mvrnorm(n=50, mu = c(50,55),
              Sigma = matrix(c(100,0,0,81),
                             ncol = 2),
              empirical = TRUE) |>
  data.frame() |>
  setNames(c("x1","x2"))
t.test(ds$x1, ds$x2)
tTest(x   = ds$x1,
      y   = 55,
      sdy = 9,
      ny  = 50)

[Package MDMA version 1.1.0 Index]