t_test: Compute t-tests

View source: R/ttest.R

t_testR Documentation

Compute t-tests

Description

Computes t-tests for one group variable and specified test variables. If no variables are specified, all numeric (integer or double) variables are used. A Levene's test will automatically determine whether the pooled variance is used to estimate the variance. Otherwise the Welch (or Satterthwaite) approximation to the degrees of freedom is used.

Usage

t_test(
  data,
  group_var,
  ...,
  var.equal = TRUE,
  paired = FALSE,
  pooled_sd = TRUE,
  levels = NULL,
  case_var = NULL,
  mu = NULL
)

Arguments

data

a tibble or a tdcmm model

group_var

group variable (column name) to specify where to split two samples (two-sample t-test) or which variable to compare a one-sample t-test on

...

test variables (column names). Leave empty to compute t-tests for all numeric variables in data. Also leave empty for one-sample t-tests.

var.equal

this parameter is deprecated (previously: 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. Defaults to TRUE).

paired

a logical indicating whether you want a paired t-test. Defaults to FALSE.

pooled_sd

a logical indicating whether to use the pooled standard deviation in the calculation of Cohen's d. Defaults to TRUE.

levels

optional: a vector of length two specifying the two levels of the group variable.

case_var

optional: case-identifying variable (column name). If you set paired = TRUE, specifying a case variable will ensure that data are properly sorted for a dependent t-test.

mu

optional: a number indicating the true value of the mean in the general population (\mu). If set, a one-sample t-test (i.e., a location test) is being calculated. Leave to NULL to calculate two-sample t-test(s).

Value

a tdcmm model

Examples

WoJ %>% t_test(temp_contract, autonomy_selection, autonomy_emphasis)
WoJ %>% t_test(temp_contract)
WoJ %>% t_test(employment, autonomy_selection, autonomy_emphasis,
  levels = c("Full-time", "Freelancer"))
WoJ %>% t_test(autonomy_selection, mu = 3.62)


tidycomm documentation built on June 24, 2024, 5:23 p.m.