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

effectsize(model, ...)

# S3 method for BFBayesFactor
effectsize(model, type = NULL, verbose = TRUE, ...)

# S3 method for aov
effectsize(model, type = NULL, ...)

# S3 method for htest
effectsize(model, type = NULL, verbose = TRUE, ...)

Arguments

model

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

...

Arguments passed to or from other methods. See details.

type

The effect size of interest. See details.

verbose

Toggle warnings and messages on or off.

Value

A data frame with the effect size (depending on input) and and its CIs (CI_low and CI_high).

Details

  • For an object of class htest, data is extracted via insight::get_data(), and passed to the relevant function according to:

    • A t-test depending on type: "cohens_d" (default), "hedges_g".

    • A correlation test returns r.

    • A Chi-squared tests of independence or goodness-of-fit, depending on type: "cramers_v" (default), "phi" or "cohens_w", "cohens_h", "oddsratio", or "riskratio".

    • A One-way ANOVA test, depending on type: "eta" (default), "omega" or "epsilon" -squared, "f", or "f2".

    • A McNemar test returns Cohen's g.

    • A Fisher's Exact test (in the 2x2 case) returns Odds ratio.

    • A Wilcoxon test returns rank biserial correlation.

    • A Kruskal-Wallis test returns rank Epsilon squared.

    • A Friedman test returns Kendall's W.

  • 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, depending on type: "cramers_v" (default), "phi" or "cohens_w", "cohens_h", "oddsratio", or "riskratio".

  • Objects of class anova, aov, or aovlist, depending on type: "eta" (default), "omega" or "epsilon" -squared, "f", or "f2".

  • 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.

See also

Other effect size indices: cohens_d(), eta_squared(), phi(), rank_biserial(), standardize_parameters()

Examples


## Hypothesis Testing
## ------------------
contingency_table <- as.table(rbind(c(762, 327, 468), c(484, 239, 477), c(484, 239, 477)))
Xsq <- chisq.test(contingency_table)
effectsize(Xsq)
#> Cramer's V |       95% CI
#> -------------------------
#> 0.07       | [0.05, 0.09]
effectsize(Xsq, type = "phi")
#> Phi  |       95% CI
#> -------------------
#> 0.10 | [0.07, 0.13]

Ts <- t.test(1:10, y = c(7:20))
effectsize(Ts)
#> Cohen's d |         95% CI
#> --------------------------
#> -2.19     | [-3.19, -1.16]
#> 
#> - Estimated using un-pooled SD.

Aov <- oneway.test(extra ~ group, data = sleep, var.equal = TRUE)
effectsize(Aov)
#> Eta2 |       90% CI
#> -------------------
#> 0.16 | [0.00, 0.41]
effectsize(Aov, type = "omega")
#> Omega2 |       90% CI
#> ---------------------
#> 0.11   | [0.00, 0.36]


## Bayesian Hypothesis Testing
## ---------------------------
# \donttest{
if (require(BayesFactor)) {
  bf1 <- ttestBF(mtcars$mpg[mtcars$am == 1], mtcars$mpg[mtcars$am == 0])
  effectsize(bf1, test = NULL)

  bf2 <- correlationBF(attitude$rating, attitude$complaints)
  effectsize(bf2, test = NULL)

  data(raceDolls)
  bf3 <- contingencyTableBF(raceDolls, sampleType = "poisson", fixedMargin = "cols")
  effectsize(bf3, test = NULL)
  effectsize(bf3, type = "oddsratio", test = NULL)
}
#> Loading required package: BayesFactor
#> Loading required package: coda
#> ************
#> Welcome to BayesFactor 0.9.12-4.2. If you have questions, please contact Richard Morey (richarddmorey@gmail.com).
#> 
#> Type BFManual() to open the manual.
#> ************
#> Summary of Posterior Distribution
#> 
#> Parameter  | Median |       95% CI
#> ----------------------------------
#> Odds_ratio |   2.02 | [0.89, 3.52]
# }

## Models and Anova Tables
## -----------------------
fit <- lm(mpg ~ factor(cyl) * wt + hp, data = mtcars)
effectsize(fit)
#> # Standardization method: refit
#> 
#> Parameter       | Coefficient (std.) |         95% CI
#> -----------------------------------------------------
#> (Intercept)     |           1.14e-03 | [-0.53,  0.53]
#> factor(cyl)6    |              -0.20 | [-0.79,  0.38]
#> factor(cyl)8    |              -0.32 | [-1.06,  0.42]
#> wt              |              -0.90 | [-1.33, -0.46]
#> hp              |              -0.25 | [-0.52,  0.01]
#> factor(cyl)6:wt |               0.37 | [-0.63,  1.36]
#> factor(cyl)8:wt |               0.54 | [ 0.03,  1.06]

anova_table <- anova(fit)
effectsize(anova_table)
#> # Effect Size for ANOVA (Type I)
#> 
#> Parameter      | Eta2 (partial) |       90% CI
#> ----------------------------------------------
#> factor(cyl)    |           0.86 | [0.76, 0.91]
#> wt             |           0.47 | [0.22, 0.64]
#> hp             |           0.14 | [0.00, 0.36]
#> factor(cyl):wt |           0.16 | [0.00, 0.35]
effectsize(anova_table, type = "epsilon")
#> # Effect Size for ANOVA (Type I)
#> 
#> Parameter      | Epsilon2 (partial) |       90% CI
#> --------------------------------------------------
#> factor(cyl)    |               0.85 | [0.74, 0.90]
#> wt             |               0.44 | [0.20, 0.62]
#> hp             |               0.11 | [0.00, 0.32]
#> factor(cyl):wt |               0.09 | [0.00, 0.27]