### Compute Odds Ratio Examples Source: https://github.com/easystats/effectsize/blob/main/_autodocs/api-reference/contingency-table-effect-sizes.md Examples demonstrating how to compute odds ratios from contingency tables, vectors, and chi-squared test objects. ```r library(effectsize) # From contingency table data("RCT_table") oddsratio(RCT_table) # Two-sided vs one-sided CI oddsratio(RCT_table, alternative = "greater") # Log odds ratio oddsratio(RCT_table, log = TRUE) # From vectors x <- c(a = 8, b = 14) # group 1: 8 successes, 14 failures y <- c(a = 11, b = 13) # group 2: 11 successes, 13 failures table <- rbind(x, y) oddsratio(table) # From chi-squared test chi_test <- chisq.test(RCT_table) oddsratio(chi_test) ``` -------------------------------- ### Install effectsize from CRAN Source: https://github.com/easystats/effectsize/blob/main/README.md Run this command to install the stable release of the effectsize package from CRAN. ```r install.packages("effectsize") ``` -------------------------------- ### Install effectsize from R-universe Source: https://github.com/easystats/effectsize/blob/main/README.md Install the latest development version of the effectsize package from R-universe. ```r install.packages("effectsize", repos = "https://easystats.r-universe.dev/") ``` -------------------------------- ### Setup Environment for Effect Size Calculations Source: https://github.com/easystats/effectsize/blob/main/vignettes/from_test_statistics.Rmd Initializes the knitr environment and loads the effectsize package for subsequent calculations. ```r library(knitr) library(effectsize) knitr::opts_chunk$set(comment = ">") options(digits = 2) options(knitr.kable.NA = "") set.seed(747) .eval_if_requireNamespace <- function(...) { pkgs <- c(...) knitr::opts_chunk$get("eval") && all(sapply(pkgs, requireNamespace, quietly = TRUE)) } ``` -------------------------------- ### Format Standardized Vectors Source: https://github.com/easystats/effectsize/blob/main/man/format_standardize.Rd Examples demonstrating basic usage and customization of the format_standardize function. ```R format_standardize(c(-1, 0, 1)) ``` ```R format_standardize(c(-1, 0, 1, 2), reference = rnorm(1000)) ``` ```R format_standardize(c(-1, 0, 1, 2), reference = rnorm(1000), robust = TRUE) ``` ```R format_standardize(standardize(mtcars$wt), digits = 1) ``` ```R format_standardize(standardize(mtcars$wt, robust = TRUE), digits = 1) ``` -------------------------------- ### Glass's Delta Usage Examples Source: https://github.com/easystats/effectsize/blob/main/_autodocs/api-reference/standardized-differences.md Examples for calculating Glass's delta with independent samples and interpreting the results. ```r # Two independent samples (required) glass_delta(mpg ~ am, data = mtcars) # With alternative CI glass_delta(mpg ~ am, data = mtcars, alternative = "greater") # Interpretation interpret_glass_delta(-1.10, rules = "gignac2016") ``` -------------------------------- ### Hedges' g Usage Examples Source: https://github.com/easystats/effectsize/blob/main/_autodocs/api-reference/standardized-differences.md Examples for calculating Hedges' g with independent and paired samples, and interpreting the results. ```r # Two independent samples hedges_g(mpg ~ am, data = mtcars) # Paired samples hedges_g(Pair(extra[group == 1], extra[group == 2]) ~ 1, data = sleep, verbose = FALSE) # Interpretation interpret_hedges_g(-1.48, rules = "sawilowsky2009") ``` -------------------------------- ### Interpret Odds Ratio Examples Source: https://github.com/easystats/effectsize/blob/main/man/interpret_oddsratio.Rd Examples demonstrating the interpretation of single and multiple odds ratio values. ```R interpret_oddsratio(1) interpret_oddsratio(c(5, 2)) ``` -------------------------------- ### Calculate p_superiority examples Source: https://github.com/easystats/effectsize/blob/main/_autodocs/api-reference/common-language-effect-sizes.md Demonstrates usage with independent samples, formulas, one-sample comparisons, and paired data. ```r library(effectsize) # Two independent samples p_superiority(mtcars$mpg[mtcars$am == 0], mtcars$mpg[mtcars$am == 1]) # Using formula p_superiority(mpg ~ am, data = mtcars) # One sample (vs. reference) p_superiority(mtcars$wt, mu = 3) # Paired samples x <- c(1.83, 0.50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.30) y <- c(0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29) p_superiority(x, y, paired = TRUE) ``` -------------------------------- ### Interpret ROPE percentages Source: https://github.com/easystats/effectsize/blob/main/man/interpret_rope.Rd Examples demonstrating how to interpret ROPE values for standard and full ROPE scenarios. ```R interpret_rope(0, ci = 0.9) interpret_rope(c(0.005, 0.99), ci = 1) ``` -------------------------------- ### Load Food Classification Data Source: https://github.com/easystats/effectsize/blob/main/papers/Phi Fei Fo Fum (2023) Mathematics/OLD/paper.Rmd Loads the example dataset used for demonstrating association coefficients. ```r data("food_class") food_class ``` -------------------------------- ### Interpret Direction Examples Source: https://github.com/easystats/effectsize/blob/main/man/interpret_direction.Rd Demonstrates how to interpret single numeric values and vectors of values using interpret_direction. ```R interpret_direction(.02) interpret_direction(c(.5, -.02)) interpret_direction(0) ``` -------------------------------- ### Interpret Eta Squared Values Source: https://github.com/easystats/effectsize/blob/main/man/interpret_omega_squared.Rd Examples demonstrating how to interpret eta squared values using default and custom rulesets. ```R interpret_eta_squared(.02) interpret_eta_squared(c(.5, .02), rules = "cohen1992") ``` -------------------------------- ### Manual aggregation for repeated measures Source: https://github.com/easystats/effectsize/blob/main/man/repeated_measures_d.Rd Example of manual data aggregation using tapply before passing to the function. ```R rouder2016_wide <- tapply(rouder2016[["rt"]], rouder2016[1:2], mean) repeated_measures_d(rouder2016_wide[, 1], rouder2016_wide[, 2]) ``` -------------------------------- ### Calculate Pooled Indices Source: https://github.com/easystats/effectsize/blob/main/man/sd_pooled.Rd Examples demonstrating the use of pooled deviation functions with formula and vector inputs. ```R sd_pooled(mpg ~ am, data = mtcars) mad_pooled(mtcars$mpg, factor(mtcars$am)) cov_pooled(mpg + hp + cyl ~ am, data = mtcars) ``` -------------------------------- ### Setup knitr options for power analysis Source: https://github.com/easystats/effectsize/blob/main/vignettes/statistical_power.Rmd Configures global knitr settings for the vignette, including conditional evaluation based on the availability of the pwr package. ```r knitr::opts_chunk$set( collapse = TRUE, comment = "#>", warning = FALSE, message = FALSE, eval = requireNamespace("pwr", quietly = TRUE) ) options(digits = 4L, knitr.kable.NA = "") set.seed(123) ``` -------------------------------- ### Interpret Bayes Factor values Source: https://github.com/easystats/effectsize/blob/main/man/interpret_bf.Rd Examples demonstrating the interpretation of single and multiple Bayes Factor values. ```R interpret_bf(1) interpret_bf(c(5, 2, 0.01)) ``` -------------------------------- ### Compute eta squared from Bayesian model Source: https://github.com/easystats/effectsize/blob/main/_autodocs/api-reference/anova-effect-sizes.md Example demonstrating fitting a Bayesian model with rstanarm and calculating the posterior eta squared. ```r library(rstanarm) library(bayestestR) # Fit Bayesian model fit_bayes <- rstanarm::stan_glm( mpg ~ factor(cyl) * wt + qsec, data = mtcars, family = gaussian(), refresh = 0 ) # Compute eta squared from PPD es <- eta_squared_posterior(fit_bayes, verbose = FALSE) # Summarize posterior bayestestR::describe_posterior(es, test = NULL) ``` -------------------------------- ### Interpret Probability of Direction values Source: https://github.com/easystats/effectsize/blob/main/man/interpret_pd.Rd Examples demonstrating how to interpret single and multiple probability of direction values using default and custom rule sets. ```R interpret_pd(.98) interpret_pd(c(.96, .99), rules = "makowski2019") ``` -------------------------------- ### Interpret Correlation Coefficients Source: https://github.com/easystats/effectsize/blob/main/man/interpret_r.Rd Examples of interpreting correlation coefficients using default and custom rule sets. ```R interpret_r(.015) interpret_r(c(.5, -.02)) interpret_r(.3, rules = "lovakov2021") ``` -------------------------------- ### Interpret ICC values Source: https://github.com/easystats/effectsize/blob/main/man/interpret_icc.Rd Examples demonstrating how to interpret single and multiple ICC values using the default Koo (2016) rules. ```R interpret_icc(0.6) interpret_icc(c(0.4, 0.8)) ``` -------------------------------- ### Get Standardized Coefficients with `standardize_parameters()` Source: https://github.com/easystats/effectsize/blob/main/papers/effectsize (2020) JOSS/paper.md Use `standardize_parameters()` to obtain a table of standardized coefficients from a model. The default standardization method is 'refit'. ```r model <- lm(mpg ~ cyl * am, data = mtcars) standardize_parameters(model) #> Parameter | Coefficient (std.) | 95% CI #> ------------------------------------------------- #> (Intercept) | -0.10 | [-0.30, 0.11] #> cyl | -0.74 | [-0.95, -0.53] #> am | 0.17 | [-0.04, 0.39] #> cyl:am | -0.19 | [-0.41, 0.02] #> #> # Standardization method: refit ``` -------------------------------- ### Handling Helpful Warnings in R Source: https://github.com/easystats/effectsize/blob/main/_autodocs/errors.md Examples of common warnings triggered by missing data or incorrect function usage, which can be suppressed using verbose = FALSE. ```r # Missing values in data cohens_d(c(1, 2, NA, 4), c(5, NA, 7, 8), verbose = TRUE) # Warning: Removed X missing values # Paired samples reminder cohens_d(x, y, paired = FALSE) # Note: Consider repeated_measures_d() for more options ``` -------------------------------- ### Load required packages Source: https://github.com/easystats/effectsize/blob/main/vignettes/statistical_power.Rmd Initialize the environment by loading the pwr and effectsize packages. ```r library(pwr) library(effectsize) ``` -------------------------------- ### Load effectsize package Source: https://github.com/easystats/effectsize/blob/main/README.Rmd Initializes the package and configures options for symbol display. ```R library(effectsize) options(es.use_symbols = TRUE) # get nice symbols when printing! (On Windows, requires R >= 4.2.0) ``` -------------------------------- ### View Available Rule Sets Source: https://github.com/easystats/effectsize/blob/main/_autodocs/configuration.md Access help documentation to list all available rule sets for a specific function. ```r ?interpret_cohens_d # Lists all available rule sets ``` -------------------------------- ### Load effectsize library Source: https://github.com/easystats/effectsize/blob/main/vignettes/effectsize_API.Rmd Initializes the package for use in the R session. ```r library(effectsize) ``` -------------------------------- ### Prepare Data and Model Source: https://github.com/easystats/effectsize/blob/main/vignettes/anovaES.Rmd Load the dataset and fit a linear model to demonstrate ANOVA-like effect size calculations. ```r data(obk.long, package = "afex") # modify the data slightly for the demonstration: obk.long <- obk.long[1:240 %% 3 == 0, ] obk.long$id <- seq_len(nrow(obk.long)) m <- lm(value ~ treatment, data = obk.long) parameters::model_parameters(m) ``` -------------------------------- ### Calculate Rank Biserial Correlation Source: https://github.com/easystats/effectsize/blob/main/man/rank_biserial.Rd Example usage of rank_biserial with the mtcars dataset. ```R data(mtcars) mtcars$am <- factor(mtcars$am) mtcars$cyl <- factor(mtcars$cyl) ``` -------------------------------- ### Load and Display Music_preferences2 Source: https://github.com/easystats/effectsize/blob/main/man/Music_preferences2.Rd Load the dataset into the R environment and display its contents. ```R data("Music_preferences2") Music_preferences2 ``` -------------------------------- ### Load and display Music_preferences dataset Source: https://github.com/easystats/effectsize/blob/main/man/Music_preferences.Rd Load the dataset into the R environment and print the contingency table to the console. ```r data("Music_preferences") Music_preferences ``` -------------------------------- ### Handling Deprecation Warnings in R Source: https://github.com/easystats/effectsize/blob/main/_autodocs/errors.md Example of a deprecation warning indicating that a function is outdated and should be replaced. ```r # Example (fictitious): old_function(x) # Warning: old_function() is deprecated as of effectsize 1.0.0 # Use new_function() instead ``` -------------------------------- ### Load and Inspect hardlyworking Dataset Source: https://github.com/easystats/effectsize/blob/main/man/hardlyworking.Rd Load the dataset into the R environment and display the first five rows to verify the structure. ```r data("hardlyworking") head(hardlyworking, n = 5) ``` -------------------------------- ### Load and inspect the preferences2025 dataset Source: https://github.com/easystats/effectsize/blob/main/man/preferences2025.Rd Load the dataset into the R environment and display the first five rows. ```r data("preferences2025") head(preferences2025, n = 5) ``` -------------------------------- ### Standardize Model Parameters Source: https://github.com/easystats/effectsize/blob/main/vignettes/effectsize.Rmd Demonstrates standardizing coefficients for linear models using datawizard and parameters packages. ```r model <- lm(mpg ~ cyl * am, data = mtcars ) datawizard::standardize(model) parameters::standardize_parameters(model) ``` -------------------------------- ### Calculate Fei (פ) Effect Size Source: https://github.com/easystats/effectsize/blob/main/papers/Phi Fei Fo Fum (2023) Mathematics/OLD/paper.tex Examples of calculating the Fei effect size for various categorical distributions. ```R O - c(90, 10) p_E - c(0.35, 0.65) fei(O, p = p_E) ``` ```R O - c(10, 20, 80, 5) p_E - c(.25, .25, .25, .25) fei(O, p = p_E) ``` ```R O - c(90, 10) p_E - c(0.5, 0.5) fei(O, p = p_E) ``` -------------------------------- ### Load and Inspect the Screening Test Dataset Source: https://github.com/easystats/effectsize/blob/main/man/screening_test.Rd Load the dataset into the R environment and display the first five rows to verify the structure. ```R data("screening_test") head(screening_test, n = 5) ``` -------------------------------- ### Calculate Cohen's d with mtcars Source: https://github.com/easystats/effectsize/blob/main/man/cohens_d.Rd Example demonstrating the preparation of data for effect size calculation using the mtcars dataset. ```R data(mtcars) mtcars$am <- factor(mtcars$am) ``` -------------------------------- ### Register custom method Source: https://github.com/easystats/effectsize/blob/main/vignettes/effectsize_API.Rmd Ensure the custom method is accessible in the global environment. ```r # This is for: https://github.com/easystats/easystats/issues/348 .anova_es.superMODEL <<- .anova_es.superMODEL ``` -------------------------------- ### Interpret Goodness of Fit Indices Source: https://github.com/easystats/effectsize/blob/main/man/interpret_gfi.Rd Examples of interpreting various fit indices by passing a vector of values to the respective functions. ```R interpret_gfi(c(.5, .99)) interpret_agfi(c(.5, .99)) interpret_nfi(c(.5, .99)) interpret_nnfi(c(.5, .99)) interpret_cfi(c(.5, .99)) interpret_rmsea(c(.07, .04)) interpret_srmr(c(.5, .99)) interpret_rfi(c(.5, .99)) interpret_ifi(c(.5, .99)) interpret_pnfi(c(.5, .99)) ``` -------------------------------- ### Calculate Ratio of Means Source: https://github.com/easystats/effectsize/blob/main/man/means_ratio.Rd Basic usage of means_ratio with two numeric vectors, including examples of adjusted and log-transformed outputs. ```R x <- c(1.83, 0.50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.30) y <- c(0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29) means_ratio(x, y) means_ratio(x, y, adjust = FALSE) means_ratio(x, y, log = TRUE) ``` -------------------------------- ### Package Directory Structure Source: https://github.com/easystats/effectsize/blob/main/_autodocs/INDEX.md Visual representation of the R package file hierarchy. ```text effectsize/ ├── R/ (63 source files) │ ├── cohens_d.R (standardized differences) │ ├── eta_squared-main.R (ANOVA effect sizes) │ ├── xtab_diff.R (contingency tables: OR, RR, etc.) │ ├── xtab_corr.R (contingency tables: Cramér's V, etc.) │ ├── rank_diff.R (rank-based effect sizes) │ ├── convert_*.R (20+ conversion functions) │ ├── interpret*.R (25+ interpretation functions) │ ├── effectsize.R (generic function) │ ├── effectsize.htest.R (S3 method for htest) │ ├── effectsize.BFBayesFactor.R (Bayesian support) │ └── [utilities, printing, formatting files] ├── DESCRIPTION (package metadata) ├── NAMESPACE (exports: 240+ functions) └── man/ (roxygen2 documentation) ``` -------------------------------- ### Interpret R-squared values in R Source: https://github.com/easystats/effectsize/blob/main/man/interpret_r2.Rd Examples of interpreting single and multiple R-squared values using the default Cohen (1988) rules. ```R interpret_r2(.02) interpret_r2(c(.5, .02)) ``` -------------------------------- ### Interpret p-values with default and custom rules Source: https://github.com/easystats/effectsize/blob/main/man/interpret_p.Rd Demonstrates basic usage with default settings and the 'rss' rule set. ```R interpret_p(c(.5, .02, 0.001)) ``` ```R interpret_p(c(.5, .02, 0.001), rules = "rss") ``` -------------------------------- ### Loading and Displaying the food_class Dataset Source: https://github.com/easystats/effectsize/blob/main/man/food_class.Rd Load the dataset into the R environment and display its contents. ```r data("food_class") food_class #> Soy Milk Meat #> Vegan 47 0 0 #> Not-Vegan 0 12 21 ``` -------------------------------- ### Interpret Cohen's d values Source: https://github.com/easystats/effectsize/blob/main/man/interpret_cohens_d.Rd Examples of interpreting single and multiple Cohen's d values using default and custom rule sets. ```R interpret_cohens_d(.02) interpret_cohens_d(c(.5, .02)) interpret_cohens_d(.3, rules = "lovakov2021") ``` -------------------------------- ### Handle Unsupported Model Classes Source: https://github.com/easystats/effectsize/blob/main/_autodocs/errors.md Verify model compatibility using insight::supported_models(). ```r weird_model <- list(coef = 1) eta_squared(weird_model) # Error: Model type not supported. See supported_models() for list. ``` -------------------------------- ### Compare Fei and Cohen's w Source: https://github.com/easystats/effectsize/blob/main/papers/Phi Fei Fo Fum (2023) Mathematics/OLD/paper.Rmd Compares the output of Fei and Cohen's w for a uniform 2-cell distribution. ```R O <- c(90, 10) p_E <- c(0.5, 0.5) fei(O, p = p_E) cohens_w(O, p = p_E) ``` -------------------------------- ### Interpret Pearson's r Source: https://github.com/easystats/effectsize/blob/main/README.md Use interpret_r to get a qualitative interpretation of a Pearson's r correlation coefficient based on predefined rules of thumb. ```r interpret_r(r = 0.3) ``` -------------------------------- ### Load effectsize and set options Source: https://github.com/easystats/effectsize/blob/main/README.md Load the effectsize package and set an option to display nice symbols when printing results. This requires R version 4.2.0 or later on Windows. ```r library(effectsize) options(es.use_symbols = TRUE) # get nice symbols when printing! (On Windows, requires R >= 4.2.0) ``` -------------------------------- ### Define and use interpretation rules Source: https://github.com/easystats/effectsize/blob/main/_autodocs/api-reference/interpretation-functions.md Demonstrates creating custom rule sets with rules() and applying them to numeric values or data frames using interpret(). ```r library(effectsize) # Create custom rules my_rules <- rules( c(0.2, 0.5, 0.8), labels = c("negligible", "small", "medium", "large"), name = "My Effect Size Rules" ) # Interpret values interpret(0.3, rules = my_rules) interpret(c(0.1, 0.35, 0.6, 0.9), rules = my_rules) # Or using named vector d_rules <- rules( c("small" = 0.2, "medium" = 0.5, "large" = 0.8) ) interpret(0.4, rules = d_rules) # With data frame cohens_d_result <- cohens_d(mpg ~ am, data = mtcars) interpret(cohens_d_result, rules = "cohen1988") ``` -------------------------------- ### Calculate Overlap and U3 for Numeric Vectors Source: https://github.com/easystats/effectsize/blob/main/man/p_superiority.Rd Examples of calculating probability of overlap and Cohen's U3 for two numeric vectors, demonstrating how directionality affects the result. ```R x <- c(1.83, 0.5, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.3) y <- c(0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29) p_overlap(x, y) p_overlap(y, x) # direction of effect does not matter cohens_u3(x, y) cohens_u3(y, x) # direction of effect does matter ``` -------------------------------- ### Calculate Effect Sizes for Grouped Data Source: https://github.com/easystats/effectsize/blob/main/man/p_superiority.Rd Examples of calculating Cohen's U2, probability of superiority, and Wilcoxon-Mann-Whitney odds using formula notation with the mtcars dataset. ```R cohens_u2(mpg ~ am, data = mtcars) p_superiority(mpg ~ am, data = mtcars, parametric = FALSE) wmw_odds(mpg ~ am, data = mtcars) ``` -------------------------------- ### Handle Incompatible CI and Alternative Source: https://github.com/easystats/effectsize/blob/main/_autodocs/errors.md Different alternative hypotheses result in different CI bounds. ```r # While not strictly wrong, extreme CIs may be generated cohens_d(x, y, ci = 0.95, alternative = "less") ``` -------------------------------- ### Standardize parameters and posteriors in R Source: https://github.com/easystats/effectsize/blob/main/_autodocs/api-reference/other-effect-sizes.md Shows how to extract standardized parameters from linear models and standardize Bayesian posterior distributions. ```r # Standardized parameters from linear model model <- lm(mpg ~ hp + wt + cyl, data = mtcars) standardize_parameters(model) # From Bayesian model library(rstanarm) fit_bayes <- stan_glm(mpg ~ hp + wt, data = mtcars, refresh = 0) standardize_posteriors(fit_bayes) ``` -------------------------------- ### Interpret using named rule sets and transformations Source: https://github.com/easystats/effectsize/blob/main/man/interpret.Rd Shows how to pass rules directly as named vectors or apply transformations like absolute value during interpretation. ```R interpret(c(0.35, 0.15), c("small" = 0.2, "large" = 0.4), name = "Cohen's Rules") interpret(c(0.35, 0.15), rules(c(0.2, 0.4), c("small", "medium", "large"))) bigness <- rules(c(1, 10), c("small", "medium", "big")) interpret(abs(-5), bigness) interpret(-5, bigness, transform = abs) ``` -------------------------------- ### Print and Format Effect Size Objects Source: https://github.com/easystats/effectsize/blob/main/_autodocs/types.md Use print and format methods to display results, optionally including additional metrics like CLES or formatting for markdown. ```r d <- cohens_d(x, y) print(d) # Default print method print(d, append_CLES = TRUE) # Add common language effect sizes format(d) # Format for markdown ``` -------------------------------- ### Calculate Partial Eta-Squared from F-statistics Source: https://github.com/easystats/effectsize/blob/main/vignettes/from_test_statistics.Rmd Demonstrates fitting an ANOVA model with afex and comparing the results with manual conversion using F_to_eta2. ```r library(afex) data(md_12.1) aov_fit <- aov_car( rt ~ angle * noise + Error(id / (angle * noise)), data = md_12.1, anova_table = list(correction = "none", es = "pes") ) aov_fit ``` ```r library(effectsize) options(es.use_symbols = TRUE) # get nice symbols when printing! (On Windows, requires R >= 4.2.0) F_to_eta2( f = c(40.72, 33.77, 45.31), df = c(2, 1, 2), df_error = c(18, 9, 18) ) ``` -------------------------------- ### Compare with Cohen's d for one sample Source: https://github.com/easystats/effectsize/blob/main/man/repeated_measures_d.Rd Demonstrates the equivalence between d_z and Cohen's d for one sample of individual differences. ```R cohens_d(chocolate - poop ~ 1, data = preferences2025) ``` -------------------------------- ### Perform Equivalence Testing on Effect Size Tables Source: https://github.com/easystats/effectsize/blob/main/man/equivalence_test.effectsize_table.Rd Demonstrates performing equivalence tests on various effect size objects like eta_squared, oddsratio, and Cohen's d, including optional plotting using the see package. ```R data("hardlyworking") model <- aov(salary ~ age + factor(n_comps) * cut(seniority, 3), data = hardlyworking) es <- eta_squared(model, ci = 0.9, alternative = "two.sided") equivalence_test(es, range = c(0, 0.15)) # TOST data("RCT_table") OR <- oddsratio(RCT_table, alternative = "greater") equivalence_test(OR, range = c(0, 1)) ds <- t_to_d( t = c(0.45, -0.65, 7, -2.2, 2.25), df_error = c(675, 525, 2000, 900, 1875), ci = 0.9, alternative = "two.sided" # TOST ) # Can also plot if (require(see)) plot(equivalence_test(ds, range = 0.2)) if (require(see)) plot(equivalence_test(ds, range = 0.2, rule = "cet")) if (require(see)) plot(equivalence_test(ds, range = 0.2, rule = "bayes")) ``` -------------------------------- ### Load Smoking_FASD dataset Source: https://github.com/easystats/effectsize/blob/main/man/chisq_to_phi.Rd Load the Smoking_FASD dataset for further analysis. ```R data("Smoking_FASD") ``` -------------------------------- ### Interpret a Structural Equation Model Source: https://github.com/easystats/effectsize/blob/main/man/interpret_gfi.Rd Demonstrates how to fit a SEM model using lavaan and interpret the results. ```R structure <- " ind60 =~ x1 + x2 + x3 dem60 =~ y1 + y2 + y3 dem60 ~ ind60 " model <- lavaan::sem(structure, data = lavaan::PoliticalDemocracy) interpret(model) ``` -------------------------------- ### Configuring Environment Variables Source: https://github.com/easystats/effectsize/blob/main/_autodocs/configuration.md Environment variables used by related packages to control parallel processing and warning displays. ```bash # datawizard settings DATAWIZARD_PARALLEL=TRUE # insight settings INSIGHT_SHOW_WARNINGS=FALSE ``` -------------------------------- ### Converting between probability metrics Source: https://github.com/easystats/effectsize/blob/main/man/oddsratio_to_probs.Rd Demonstrates the conversion between different effect size metrics and probabilities using baseline risk p0. ```R p0 <- 0.4 p1 <- 0.7 (OR <- probs_to_odds(p1) / probs_to_odds(p0)) (RR <- p1 / p0) (ARR <- p1 - p0) (NNT <- arr_to_nnt(ARR)) riskratio_to_probs(RR, p0 = p0) oddsratio_to_probs(OR, p0 = p0) all.equal(nnt_to_probs(NNT, p0 = p0, odds = TRUE), probs_to_odds(p1)) arr_to_probs(-ARR, p0 = p1) nnt_to_probs(-NNT, p0 = p1) ``` -------------------------------- ### Load and Display RCT_table Source: https://github.com/easystats/effectsize/blob/main/man/RCT_table.Rd Load the dataset into the R environment and display its contents. ```r data("RCT_table") RCT_table ``` -------------------------------- ### Calculate Cohen's w for Custom Distributions Source: https://github.com/easystats/effectsize/blob/main/papers/Phi Fei Fo Fum (2023) Mathematics/OLD/paper.Rmd Demonstrates Cohen's w calculation for non-uniform and multinomial distributions where the value may exceed 1. ```R O <- c(90, 10) p_E <- c(0.35, 0.65) cohens_w(O, p = p_E) O <- c(10, 20, 80, 5) p_E <- c(.25, .25, .25, .25) cohens_w(O, p = p_E) ``` -------------------------------- ### Use effectsize_table methods Source: https://github.com/easystats/effectsize/blob/main/_autodocs/types.md Demonstrates calculating Cohen's d and applying standard methods like print, interpret, and plot. ```r library(effectsize) d <- cohens_d(mpg ~ am, data = mtcars) class(d) # [1] "effectsize_difference" "effectsize_table" "see_effectsize_table" "data.frame" print(d) interpret(d) plot(d) # with see package ``` -------------------------------- ### rules(values, labels = NULL, name = NULL, right = TRUE) Source: https://github.com/easystats/effectsize/blob/main/man/rules.Rd Creates a container for interpretation rules of thumb, defining categories based on reference values. ```APIDOC ## rules(values, labels = NULL, name = NULL, right = TRUE) ### Description Creates a container for interpretation rules of thumb. This object is typically used in conjunction with the interpret function to categorize statistical values. ### Parameters - **values** (vector) - Required - Vector of reference values (edges defining categories or critical values). - **labels** (vector) - Optional - Labels associated with each category. If NULL, the function attempts to infer them from the values vector. - **name** (string) - Optional - A name for the set of rules to be displayed during printing. - **right** (logical) - Optional - For threshold-type rules, indicates if thresholds are included in the interval to the right (lower values) or left (higher values). Defaults to TRUE. ### Example ```r rules(c(0.2, 0.5, 0.8), c("small", "medium", "large")) rules(c("small" = 0.2, "medium" = 0.5), name = "Cohen's Rules") ``` ``` -------------------------------- ### print.effectsize_table Source: https://github.com/easystats/effectsize/blob/main/man/print.effectsize_table.Rd Prints an effectsize_table object to the console. ```APIDOC ## print(x, digits = 2, use_symbols = getOption("es.use_symbols", FALSE), ...) ### Description Prints the effectsize_table object with specified formatting. ### Parameters - **x** (effectsize_table) - Required - The object to print. - **digits** (numeric/string) - Optional - Number of digits for rounding or significant figures. - **use_symbols** (boolean) - Optional - Whether to use proper symbols instead of transliterated names. ``` -------------------------------- ### Load and inspect the rouder2016 dataset Source: https://github.com/easystats/effectsize/blob/main/man/rouder2016.Rd Load the dataset into the R environment and display the first 5 rows to verify the structure. ```r data("rouder2016") head(rouder2016, n = 5) ``` -------------------------------- ### Define a custom model class Source: https://github.com/easystats/effectsize/blob/main/vignettes/effectsize_API.Rmd Create a simple linear model and assign it a custom class name. ```r mod <- lm(mpg ~ factor(cyl) + am, mtcars) class(mod) <- "superMODEL" ``` -------------------------------- ### Compute eta squared for ANOVA models Source: https://github.com/easystats/effectsize/blob/main/_autodocs/api-reference/anova-effect-sizes.md Demonstrates calculating partial, non-partial, and generalized eta squared, along with interpretation using Cohen's rules. ```r library(effectsize) data(mtcars) mtcars$am_f <- factor(mtcars$am) mtcars$cyl_f <- factor(mtcars$cyl) # Fit ANOVA model model <- aov(mpg ~ am_f * cyl_f, data = mtcars) # Partial eta squared (default) eta2 <- eta_squared(model) print(eta2) # Non-partial eta squared eta_squared(model, partial = FALSE) # With generalized eta squared eta_squared(model, generalized = "cyl_f") # Interpretation interpret(eta2, rules = "cohen1992") interpret_eta_squared(0.10, rules = "cohen1992") ``` -------------------------------- ### display(x, ...) and standardize_info(model, ...) Source: https://github.com/easystats/effectsize/blob/main/_autodocs/api-reference/other-effect-sizes.md Utility functions for formatting results and retrieving standardization information from models. ```APIDOC ## display(x, ...) ## standardize_info(model, ...) ### Description Utility functions to display effect size results or extract standardization information from statistical models. ### Parameters - **x / model** (object) - Required - The result object or model to process - **...** (any) - Optional - Additional arguments ### Return Value Formatted display or information data frame. ``` -------------------------------- ### Setting Reproducible Options Source: https://github.com/easystats/effectsize/blob/main/_autodocs/configuration.md Explicitly setting global options to ensure consistent output across environments. ```r # Set all options explicitly for reproducibility options( es.use_symbols = TRUE, datawizard.verbose = FALSE, insight.print_name = TRUE ) # Use standard rule sets, document in methods d <- cohens_d(x, y, ci = 0.95) interpret(d, rules = "cohen1988") # Named rule set in methods section ``` -------------------------------- ### Compute Effect Sizes for 2-by-2 Tables Source: https://github.com/easystats/effectsize/blob/main/man/oddsratio.Rd Demonstrates calculating odds ratios, risk ratios, Cohen's h, absolute risk reduction, and number needed to treat using a contingency table. ```R data("RCT_table") RCT_table # note groups are COLUMNS oddsratio(RCT_table) oddsratio(RCT_table, alternative = "greater") riskratio(RCT_table) cohens_h(RCT_table) arr(RCT_table) nnt(RCT_table) ``` -------------------------------- ### Compare with Cohen's d for independent groups Source: https://github.com/easystats/effectsize/blob/main/man/repeated_measures_d.Rd Demonstrates the equivalence between d and Cohen's d for two independent groups. ```R cohens_d(rt ~ cond, data = rouder2016, ci = NULL) ``` -------------------------------- ### Standardize GLM Parameters Source: https://github.com/easystats/effectsize/blob/main/vignettes/effectsize.Rmd Shows how to produce standardized parameters for generalized linear models with exponentiation. ```r model <- glm(am ~ cyl + hp, family = "binomial", data = mtcars ) parameters::standardize_parameters(model, exponentiate = TRUE) ``` -------------------------------- ### Calculate risk ratio with different base-rate Source: https://github.com/easystats/effectsize/blob/main/vignettes/convert_p_OR_RR.Rmd Demonstrates how the base-rate risk significantly impacts the calculated risk ratio. ```r oddsratio_to_riskratio(OR, 0.04) ``` -------------------------------- ### Compare Mahalanobis D and Cohen's D Source: https://github.com/easystats/effectsize/blob/main/man/mahalanobis_d.Rd Demonstrates that Mahalanobis D reduces to Cohen's D when only a single variate is provided. ```R mahalanobis_d(hp ~ am, data = mtcars) cohens_d(hp ~ am, data = mtcars) ``` -------------------------------- ### Visualize effect size results Source: https://github.com/easystats/effectsize/blob/main/_autodocs/README.md Plot effect size results using the see package. ```r library(see) result <- eta_squared(model) plot(result) ``` -------------------------------- ### Interpret VIF values in R Source: https://github.com/easystats/effectsize/blob/main/man/interpret_vif.Rd Demonstrates how to pass a vector of VIF values to the interpret_vif function for classification. ```R interpret_vif(c(1.4, 30.4)) ``` -------------------------------- ### Optimize Large Datasets Source: https://github.com/easystats/effectsize/blob/main/_autodocs/configuration.md Strategies for large datasets including skipping CI, using fast approximations, and data subsetting. ```r # For very large datasets, consider: # 1. Compute effect sizes only (skip CI) result <- cohens_d(x, y, ci = FALSE) # 2. Use approximation methods where available result <- F_to_d(f_stat, df, df_error) # Fast approximation # 3. Subset data before computation subset_result <- cohens_d(x[1:10000], y[1:10000]) ``` -------------------------------- ### Load and inspect Smoking_FASD dataset Source: https://github.com/easystats/effectsize/blob/main/man/Smoking_FASD.Rd Use the data function to load the dataset into the R environment and display its contents. ```R data("Smoking_FASD") Smoking_FASD ``` -------------------------------- ### Standardize Model Parameters with `standardize()` Source: https://github.com/easystats/effectsize/blob/main/papers/effectsize (2020) JOSS/paper.md Use `standardize()` to refit a linear model with standardized data, allowing for comparison of coefficients. ```r model <- lm(mpg ~ cyl * am, data = mtcars) standardize(model) #> #> Call: #> lm(formula = mpg ~ cyl * am, data = data_std) #> #> Coefficients: #> (Intercept) cyl am cyl:am #> -0.0977 -0.7426 0.1739 -0.1930 ``` -------------------------------- ### oddsratio() Source: https://github.com/easystats/effectsize/blob/main/_autodocs/api-reference/contingency-table-effect-sizes.md Compute odds ratio for 2×2 contingency tables. ```APIDOC ## oddsratio(x, y = NULL, ci = 0.95, alternative = "two.sided", log = FALSE, ...) ### Description Compute odds ratio for 2×2 contingency tables. This function accepts contingency tables, data frames, or output from statistical tests like chisq.test() or fisher.test(). ### Parameters - **x** (matrix, data.frame, htest, or crosstab) - Required - A 2×2 contingency table, or output from chisq.test() / fisher.test() - **y** (numeric or factor) - Optional - Second variable if x is a vector/factor (creates contingency table) - **ci** (numeric) - Optional - Confidence interval level. Set FALSE or NA to skip CI. Default: 0.95 - **alternative** (character) - Optional - CI direction: "two.sided", "greater", or "less". Default: "two.sided" - **log** (logical) - Optional - If TRUE, returns log(odds ratio) instead of odds ratio. Default: FALSE - **...** (any) - Optional - Additional arguments ### Return Value A data frame with class effectsize_table and see_effectsize_table containing: - **Odds_ratio or log_Odds_ratio** (numeric) - The odds ratio (or log odds ratio) - **CI** (numeric) - CI level (if computed) - **CI_low** (numeric) - Lower CI bound - **CI_high** (numeric) - Upper CI bound ### Request Example library(effectsize) # From contingency table data("RCT_table") oddsratio(RCT_table) # Log odds ratio oddsratio(RCT_table, log = TRUE) ``` -------------------------------- ### Configure pseudo-R² in parameter standardization Source: https://github.com/easystats/effectsize/blob/main/_autodocs/configuration.md Toggle the inclusion of pseudo-R² statistics when standardizing model parameters. ```r # Include pseudo-R² statistics standardize_parameters(model, include_pseudo_r2 = TRUE) # Exclude pseudo-R² (faster) standardize_parameters(model, include_pseudo_r2 = FALSE) ``` -------------------------------- ### Configuring confidence intervals Source: https://github.com/easystats/effectsize/blob/main/_autodocs/README.md Shows how to adjust or disable confidence intervals using the ci parameter in effect size functions. ```r # 95% CI (default) cohens_d(x, y, ci = 0.95) # 90% CI cohens_d(x, y, ci = 0.90) # No CI (faster) cohens_d(x, y, ci = FALSE) ``` -------------------------------- ### print_html.effectsize_table Source: https://github.com/easystats/effectsize/blob/main/man/print.effectsize_table.Rd Prints an effectsize_table object in HTML format. ```APIDOC ## print_html(x, digits = 2, use_symbols = getOption("es.use_symbols", FALSE), ...) ### Description Formats and prints the effectsize_table as an HTML table. ### Parameters - **x** (effectsize_table) - Required - The object to print. - **digits** (numeric/string) - Optional - Number of digits for rounding. - **use_symbols** (boolean) - Optional - Whether to use proper symbols. ``` -------------------------------- ### Standardize variables and model coefficients in R Source: https://github.com/easystats/effectsize/blob/main/_autodocs/api-reference/other-effect-sizes.md Demonstrates standardizing a data frame and refitting a linear model with standardized predictors. ```r # Standardize variables df <- mtcars df_std <- standardize(df) # Refit model with standardized predictors model <- lm(mpg ~ hp + wt, data = mtcars) model_std <- standardize(model) coef(model_std) # Post-hoc standardization of coefficients model_posthoc <- standardize(model, method = "posthoc") ``` -------------------------------- ### print_md.effectsize_table Source: https://github.com/easystats/effectsize/blob/main/man/print.effectsize_table.Rd Prints an effectsize_table object in markdown format. ```APIDOC ## print_md(x, digits = 2, use_symbols = getOption("es.use_symbols", FALSE), ...) ### Description Formats and prints the effectsize_table as a markdown table. ### Parameters - **x** (effectsize_table) - Required - The object to print. - **digits** (numeric/string) - Optional - Number of digits for rounding. - **use_symbols** (boolean) - Optional - Whether to use proper symbols. ```