50% off: Unlimited data and AI learning.
State of Data and AI Literacy Report 2025

effectsize (version 0.4.0)

effectsize: Effect Size

Description

This function tries to return the best effect-size measure for the provided input model. See details.

Usage

effectsize(model, ...)

Arguments

model

An object of class htest, or a statistical model. See details.

...

Arguments passed to or from other methods. See details.

Details

  • For an object of class htest:

    • A t-test returns Cohen's d via t_to_d().

    • A correlation test returns r. See t_to_r().

    • A Chi-squared test returns Cramer's V via cramers_v().

    • A One-way ANOVA test returns Eta squared via F_to_eta2(), but can be changes via an es argument.

  • For an object of class BFBayesFactor, using bayestestR::describe_posterior(),

    • A t-test returns Cohen's d.

    • A correlation test returns r..

    • A contingency table test returns Cramer's V.

  • Objects of class anova, aov, or aovlist are passed to eta_squared().

  • Other objects are passed to standardize_parameters().

For statistical models it is recommended to directly use the listed functions, for the full range of options they provide.

Examples

Run this code
# NOT RUN {
contingency_table <- as.table(rbind(c(762, 327, 468), c(484, 239, 477), c(484, 239, 477)))
Xsq <- chisq.test(contingency_table)
effectsize(Xsq)

Ts <- t.test(1:10, y = c(7:20))
effectsize(Ts)

Aov <- oneway.test(extra ~ group, data = sleep)
effectsize(Aov)

if (require(BayesFactor)) {
  bf1 <- ttestBF(mtcars$mpg[mtcars$am == 1], mtcars$mpg[mtcars$am == 0])
  effectsize(bf1, test = NULL)

  bf2 <- correlationBF(iris$Sepal.Length, iris$Sepal.Width)
  effectsize(bf2, test = NULL)

  data(raceDolls)
  bf3 <- contingencyTableBF(raceDolls, sampleType = "poisson", fixedMargin = "cols")
  effectsize(bf3, test = NULL)
}

fit <- lm(mpg ~ factor(cyl) * wt + hp, data = mtcars)
effectsize(fit)

anova_table <- anova(fit)
effectsize(anova_table)

# }

Run the code above in your browser using DataLab