Making text subtitle for the t-test (between-/within-subjects designs).

Making text subtitle for the t-test (between-/within-subjects designs).

subtitle_t_parametric(data, x, y, paired = FALSE, effsize.type = "g",
  effsize.noncentral = TRUE, conf.level = 0.95, var.equal = FALSE,
  k = 2, stat.title = NULL, ...)

A dataframe (or a tibble) from which variables specified are to be taken. A matrix or tables will not be accepted.


The grouping variable from the dataframe data.


The response (a.k.a. outcome or dependent) variable from the dataframe data.


Logical that decides whether the design is repeated measures/within-subjects (in which case one-way Friedman Rank Sum Test will be carried out) or between-subjects (in which case one-way Kruskal<U+2013>Wallis H test will be carried out). The default is FALSE.


Type of effect size needed for parametric tests. The argument can be "biased" (equivalent to "d" for Cohen's d for t-test; "partial_eta" for partial eta-squared for anova) or "unbiased" (equivalent to "g" Hedge's g for t-test; "partial_omega" for partial omega-squared for anova)).


Logical indicating whether to use non-central t-distributions for computing the confidence interval for Cohen's d or Hedge's g (Default: TRUE).


Scalar between 0 and 1. If unspecified, the defaults return 95% lower and upper confidence intervals (0.95).


a logical variable indicating whether to treat the variances in the samples as equal. If TRUE, then a simple F test for the equality of means in a one-way analysis of variance is performed. If FALSE, an approximate method of Welch (1951) is used, which generalizes the commonly known 2-sample Welch test to the case of arbitrarily many samples.


Number of digits after decimal point (should be an integer) (Default: k = 2).


A character describing the test being run, which will be added as a prefix in the subtitle. The default is NULL. An example of a stat.title argument will be something like "Student's t-test: ".


Additional arguments.


Cohen's d is calculated in the traditional fashion as the difference between means or mean minus mu divided by the estimated standardized deviation. By default Hedge's correction is applied (N-3)/(N-2.25) to produce g. For independent samples t-test, there are two possibilities implemented. If the t-test did not make a homogeneity of variance assumption, (the Welch test), the variance term will mirror the Welch test, otherwise a pooled and weighted estimate is used. If a paired samples t-test was requested, then effect size desired is based on the standard deviation of the differences.

The computation of the confidence intervals defaults to a use of non-central Student-t distributions (effsize.noncentral = TRUE); otherwise a central distribution is used.

When computing confidence intervals the variance of the effect size d or g is computed using the conversion formula reported in Cooper et al. (2009)

  • ((n1+n2)/(n1*n2) + .5*d^2/df) * ((n1+n2)/df) (independent samples)

  • sqrt(((1 / n) + (d^2 / n)) * 2 * (1 - r)) (paired case)

See Also


  • subtitle_t_parametric
# creating a smaller dataset
msleep_short <- dplyr::filter(
  .data = ggplot2::msleep,
  vore %in% c("carni", "herbi")

# with defaults
  data = msleep_short,
  x = vore,
  y = sleep_rem

# changing defaults
  data = msleep_short,
  x = vore,
  y = sleep_rem,
  var.equal = TRUE,
  k = 2,
  effsize.type = "d"
# }
Documentation reproduced from package ggstatsplot, version 0.0.12, License: GPL-3 | file LICENSE

Community examples

Looks like there are no examples yet.