Learn R Programming

⚠️There's a newer version (1.0.0) of this package.Take me there.

effectsize

Size does matter

The goal of this package is to provide utilities to work with indices of effect size and standardized parameters, allowing computation and conversion of indices such as Cohen’s d, r, odds-ratios, etc.

Installation

Run the following:

install.packages("devtools")
devtools::install_github("easystats/effectsize")
library("effectsize")

Documentation

Click on the buttons above to access the package documentation and the easystats blog, and check-out these vignettes:

Features

This package is focused on indices of effect size. But there are hundreds of them! Thus, everybody is welcome to contribute by adding support for the interpretation of new indices. If you’re not sure how to code it’s okay, just open an issue to discuss it and we’ll help :)

Effect Size Computation

Basic Indices (Cohen’s d, Hedges’ g, Glass’ delta)

The package provides functions to compute indices of effect size.

cohens_d(iris$Sepal.Length, iris$Sepal.Width)
## [1] 4.21
hedges_g(iris$Sepal.Length, iris$Sepal.Width)
## [1] 4.2
glass_delta(iris$Sepal.Length, iris$Sepal.Width)
## [1] 3.36

ANOVAs (Eta2, Omega2, …)

model <- aov(Sepal.Length ~ Species, data = iris)

omega_squared(model, partial = TRUE)
##   Parameter Omega_Sq_partial
## 1   Species            0.612
## 2 Residuals               NA
eta_squared(model, partial = TRUE)
##   Parameter Eta_Sq_partial
## 1   Species          0.619
## 2 Residuals             NA
epsilon_squared(model)
##   Parameter Epsilon_sq_partial
## 1   Species              0.614
## 2 Residuals                 NA
cohens_f(model)
##   Parameter Cohens_f
## 1   Species     1.27
## 2 Residuals       NA

Regression Models

Importantly, effectsize also provides advanced methods to compute standardized parameters for regression models.

lm(Sepal.Length ~ Species + Sepal.Length, data = iris) %>% 
  standardize_parameters()
ParameterStd_Coefficient
(Intercept)-1.01
Speciesversicolor1.12
Speciesvirginica1.91

Effect Size Interpretation

The package allows for an automated interpretation of different indices.

interpret_r(r = 0.3)
## [1] "large"

Different sets of “rules of thumb” are implemented (guidelines are detailed here) and can be easily changed.

interpret_d(d = 0.45, rules = "cohen1988")
## [1] "small"
interpret_d(d = 0.45, rules = "funder2019")
## [1] "medium"

Effect Size Conversion

The package also provides ways of converting between different effect sizes.

convert_d_to_r(d = 1)
## [1] 0.447

Standardization

Many indices of effect size stem out, or are related, to standardization. Thus, it is expected that effectsize provides functions to standardize data and models.

Data standardization, normalization and rank-transformation

A standardization sets the mean and SD to 0 and 1:

library(parameters)

df <- standardize(iris)
describe_distribution(df$Sepal.Length)
MeanSDMinMaxSkewnessKurtosisnn_Missing
01-1.92.50.3-0.61500

This can be also applied to statistical models:

std_model <- standardize(lm(Sepal.Length ~ Species, data = iris))
coef(std_model)
##       (Intercept) Speciesversicolor  Speciesvirginica 
##             -1.01              1.12              1.91

Alternatively, normalization is similar to standardization in that it is a linear translation of the parameter space (i.e., it does not change the shape of the data distribution). However, it puts the values within a 0 - 1 range, which can be useful in cases where you want to compare or visualise data on the same scale.

df <- normalize(iris)
describe_distribution(df$Sepal.Length)
MeanSDMinMaxSkewnessKurtosisnn_Missing
0.40.2010.3-0.61500

This is a special case of a rescaling function, which can be used to rescale the data to an arbitrary new scale. Let’s change all numeric variables to “percentages”:

df <- change_scale(iris, to = c(0, 100)) 
describe_distribution(df$Sepal.Length)
MeanSDMinMaxSkewnessKurtosisnn_Missing
42.92301000.3-0.61500

For some robust statistics, one might also want to transfom the numeric values into ranks (or signed-ranks), which can be performed using the ranktransform() function.

ranktransform(c(1, 3, -2, 6, 6, 0))
## [1] 3.0 4.0 1.0 5.5 5.5 2.0

Copy Link

Version

Install

install.packages('effectsize')

Monthly Downloads

59,962

Version

0.2.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Dominique Makowski

Last Published

February 25th, 2020

Functions in effectsize (0.2.0)

format_standardize

Transform a standardized vector into character
interpret_odds

(Log) Odds ratio interpretation
standardize

Standardization (Z-scoring)
sd_pooled

Pooled Standard Deviation
interpret_gfi

Interpretation of indices of fit
t_to_d

Convert test statistics (t, z, F) to effect sizes of differences (Cohen's d) or association (partial r)
interpret

Generic function for interpretation
interpret_r

Correlation interpretation
interpret_parameters

Automated Interpretation of Effect Sizes
interpret_d

Standardized difference interpretation
interpret_bf

Bayes Factor (BF) Interpretation
standardize_info

Get Standardization Information
chisq_to_phi

Conversion between Effect sizes for Contingency Tables (Chi2, Phi, Cramer's V...)
interpret_direction

Direction interpretation
interpret_omega_squared

ANOVA effect size interpretation
interpret_r2

Coefficient of determination (R2) interpretation
interpret_p

p-values interpretation
standardize_parameters

Parameters standardization
interpret_ess

Bayesian indices interpretation
normalize

Normalization
rules

Interpretation Grid
ranktransform

(Signed) rank transformation
.factor_to_numeric

Safe transformation from factor/character to numeric
percentage_to_d

General effect size conversion
convert_posteriors_to_r

Convert posterior distributions from a Bayesian model
cohens_f

Effect size for ANOVA
adjust

Adjust data for the effect of other variable(s)
convert_z_to_percentile

Z score to Percentile
cohens_d

Effect size for differences
change_scale

Rescale a numeric variable
F_to_eta2

Convert test statistics (F, t) to indices of partial variance explained (partial Eta / Omega / Epsilon squared)