An extension for stats::t.test with added boni and tidy and/or pretty output. Before a t-test is performed, car::leveneTest is consulted as to wether heteroskedasticity is present (using the default center = "mean" method for a more robust test), and sets var.equal accordingly. Afterwards, the effect size is calculated and pwr::pwr.t.test or pwr::pwr.t2n.test are used to calculate the test's power accordingly. The result is either returned as a broom::tidy data.frame or prettified using various pixiedust::sprinkle shenanigans.

tadaa_t.test(data, response, group, direction = "two.sided", paired = FALSE,
  var.equal = NULL, conf.level = 0.95, print = c("df", "console", "html",
  "markdown"))

Arguments

data

A data.frame.

response

The response variable (dependent).

group

The group variable, usually a factor.

direction

Test direction, like alternative in t.test.

paired

If TRUE, a paired test is performed, defaults to FALSE.

var.equal

If set, passed to stats::t.test to decide whether to use a Welch-correction. Default is NULL to automatically determine heteroskedasticity.

conf.level

Confidence level used for power and CI, default is 0.95.

print

Print method, default df: A regular data.frame. Otherwise passed to pixiedust::sprinkle_print_method for fancyness.

Value

A data.frame by default, otherwise dust object, depending on print.

Note

The cutoff for the interal Levene's test to decided whether or not to perform a Welch-corrected t-test is set to 0.05 by default. To override the internal tests and decide whether to use a Welch test, set var.equal as you would with stats::t.test.

See also

Other Tadaa-functions: tadaa_aov, tadaa_chisq, tadaa_kruskal, tadaa_levene, tadaa_nom, tadaa_normtest, tadaa_one_sample, tadaa_ord, tadaa_pairwise_gh, tadaa_pairwise_tukey, tadaa_pairwise_t, tadaa_wilcoxon

Examples

set.seed(42) df <- data.frame(x = runif(100), y = sample(c("A", "B"), 100, TRUE)) tadaa_t.test(df, x, y)
#> estimate estimate1 estimate2 statistic se parameter #> 1 -0.051246403 0.49578076 0.54702716 -0.84122271 0.060918948 98 #> conf.low conf.high p.value d power method #> 1 -0.17213807 0.069645267 0.40227115 -0.16946915 0.13249042 Two Sample t-test #> alternative #> 1 two.sided
df <- data.frame(x = runif(100), y = c(rep("A", 50), rep("B", 50))) tadaa_t.test(df, x, y, paired = TRUE)
#> estimate estimate1 estimate2 statistic se parameter conf.low #> 1 0.032568319 0.4570563 0.42448798 0.48526852 0.067114015 49 -0.10230234 #> conf.high p.value d power method alternative #> 1 0.16743898 0.62964856 0.068627332 0.076315664 Paired t-test two.sided
tadaa_t.test(ngo, deutsch, geschl, print = "console")
#> Table 3: **Two Sample t-test** with alternative hypothesis: $\mu_1 \neq \mu_2$ #> #> Diff $\\mu_1$ Männlich $\\mu_2$ Weiblich t SE df $CI_{95\\%}$ #> 1 -1.03 7.09 8.12 -4.11 0.25 248 (-1.53 - -0.54) #> p Cohen\\'s d Power #> 1 < 0.001 -0.52 0.98 #> #>