statsExpressions (version 0.3.1)

expr_t_parametric: Making expression containing t-test results

Description

Making expression containing t-test results

Usage

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

Arguments

data

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

x

The grouping variable from the dataframe data.

y

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

paired

Logical that decides whether the experimental design is repeated measures/within-subjects or between-subjects. The default is FALSE.

effsize.type

Type of effect size needed for parametric tests. The argument can be "biased" ("d" for Cohen's d) or "unbiased" ("g" Hedge's g for t-test). The default is "g".

effsize.noncentral

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

conf.level

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

var.equal

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.

k

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

stat.title

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 (currently ignored).

Value

Expression containing details from results of a two-sample test and effect size plus confidence intervals.

Details

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)

References

For more details, see- https://indrajeetpatil.github.io/statsExpressions/articles/stats_details.html

Examples

Run this code
# NOT RUN {
# for reproducibility
set.seed(123)
# }
# NOT RUN {
# creating a smaller dataset
msleep_short <- dplyr::filter(
  .data = ggplot2::msleep,
  vore %in% c("carni", "herbi")
)

# with defaults
statsExpressions::expr_t_parametric(
  data = msleep_short,
  x = vore,
  y = sleep_rem
)

# changing defaults
statsExpressions::expr_t_parametric(
  data = msleep_short,
  x = vore,
  y = sleep_rem,
  var.equal = TRUE,
  k = 2,
  effsize.type = "d"
)
# }

Run the code above in your browser using DataCamp Workspace