ggstatsplot (version 0.0.11)

effsize_t_parametric: Calculating Cohen's d or Hedge's g (for between-/within- or one sample designs).

Description

Calculating Cohen's d or Hedge's g (for between-/within- or one sample designs).

Usage

effsize_t_parametric(formula = NULL, data = NULL, mu = 0,
  paired = FALSE, hedges.correction = TRUE, conf.level = 0.95,
  var.equal = FALSE, noncentral = TRUE, tobject = NULL, ...)

Arguments

formula

This function only accepts the variables in formula format e.g. sleep_rem ~ vore or ~ vore.

data

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

mu

If conducting a single sample test against a mean (Default: 0).

paired

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.

hedges.correction

Logical indicating whether to apply Hedges correction, 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.

noncentral

Logical indicating whether to use non-central t-distributions for computing the confidence intervals (Default: TRUE).

tobject

Object with the t-test specification.

...

Additional arguments.

Details

This function is a rewrite of functionality provided in lsr::cohensD and effsize::cohen.d.

References-

  • Cooper, Harris, Hedges, Larry V., Valentine, Jeffrey C., The Handbook of Research Synthesis and Meta-Analysis, 2009.

  • Cumming, G., Finch, S., A Primer On The Understanding, Use, And Calculation Of Confidence Intervals That Are Based On Central And Noncentral Distributions, Educational and Psychological Measurement, Vol. 61 No. 4, August 2001 532-574.

  • Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.) Hillsdale, NJ: Lawrence Erlbaum Associates.

  • David C. Howell (2010). Confidence Intervals on Effect Size

Examples

Run this code
# NOT RUN {
#---------------- two-sample test ------------------------------------

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

# with defaults
tobj1 <- t.test(
  formula = sleep_rem ~ vore,
  data = msleep_short
)
ggstatsplot:::effsize_t_parametric(
  formula = sleep_rem ~ vore,
  data = msleep_short,
  tobject = tobj1
)

# changing defaults
tobj2 <- t.test(
  formula = sleep_rem ~ vore,
  data = msleep_short,
  mu = 1,
  paired = FALSE,
  conf.level = .99
)
ggstatsplot:::effsize_t_parametric(
  formula = sleep_rem ~ vore,
  data = msleep_short,
  mu = 1, # ignored in this case
  paired = FALSE,
  hedges.correction = TRUE,
  conf.level = .99,
  noncentral = FALSE,
  tobject = tobj2
)

#---------------- one-sample test ------------------------------------

tobj3 <- t.test(
  x = msleep_short$sleep_rem,
  mu = 2,
  conf.level = .90
)
ggstatsplot:::effsize_t_parametric(
  formula = ~sleep_rem,
  data = msleep_short,
  mu = 2,
  hedges.correction = TRUE,
  conf.level = .90,
  noncentral = TRUE,
  tobject = tobj3
)
# }

Run the code above in your browser using DataCamp Workspace