sta_t: Student's t-Test or Welch-Test

Description Usage Arguments Examples

View source: R/sta_t.R

Description

Performs one and two sample t-tests or Welch-tests on vectors of data.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
sta_t(
  data = NULL,
  formula = NULL,
  x = NULL,
  y = NULL,
  alternative = "two.sided",
  mu = 0,
  paired = FALSE,
  var.equal = FALSE,
  conf.level = 0.95,
  obj = TRUE,
  na.action = getOption("na.action"),
  ...
)

Arguments

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).

formula

a formula of the form lhs ~ rhs where lhs is a numeric variable giving the data values and rhs a factor with two levels giving the corresponding groups.

x

numeric vectors of data values, or fitted linear model objects (inheriting from class "lm").

y

numeric vectors of data values, or fitted linear model objects (inheriting from class "lm").

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 a two sample test).

paired

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

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

confidence level for the returned confidence interval.

obj

a logical whether the test object of stats::t.test() should be returned.

na.action

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

...

further arguments to be passed to or from methods.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
library(magrittr)
data(big_five, package = "inductive")

big_five %>% 
  sta_t(Extraversion ~ Gender)

big_five %>% 
  sta_t(x = Extraversion, y = Neuroticism, var.equal = TRUE)

big_five %>% 
  sta_t(x = Neuroticism, y = Extraversion)

big_five %>% 
  sta_t(Extraversion ~ Neuroticism)

sta_t(big_five, Extraversion ~ Gender)

## End(Not run)

j3ypi/inductive documentation built on Feb. 7, 2020, 12:37 p.m.