From 7614c387357d0a876b72ab7e24b70052cd298662 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Sat, 10 Sep 2022 19:03:00 +0300 Subject: [PATCH 01/14] initial rename --- NAMESPACE | 2 ++ NEWS.md | 5 ++++- R/convert_stat_chisq.R | 18 ++++++++-------- R/effectsize.R | 2 +- R/effectsize.htest.R | 9 ++++---- R/interpret.R | 1 + R/is_effectsize_name.R | 2 +- R/xtab.R | 37 ++++++++++++++++---------------- R/zzz_deprecated.R | 18 ++++++++++++++++ man/chisq_to_phi.Rd | 27 ++++++++--------------- man/effectsize.Rd | 2 +- man/effectsize_deprecated.Rd | 8 +++++++ man/phi.Rd | 35 +++++++++++++++--------------- tests/testthat/test-effectsize.R | 4 ++-- tests/testthat/test-xtab.R | 14 ++++++------ vignettes/simple_htests.Rmd | 4 ++-- 16 files changed, 105 insertions(+), 83 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 2f38db059..342627d5a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -53,6 +53,7 @@ export(F_to_omega2) export(F_to_r) export(chisq_to_cohens_w) export(chisq_to_cramers_v) +export(chisq_to_fei) export(chisq_to_normalized) export(chisq_to_pearsons_c) export(chisq_to_phi) @@ -93,6 +94,7 @@ export(eta_squared) export(eta_squared_posterior) export(f2_to_eta2) export(f_to_eta2) +export(fei) export(format_standardize) export(get_effectsize_label) export(get_effectsize_name) diff --git a/NEWS.md b/NEWS.md index 064e34ba7..3e6c941d3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,9 @@ - # effectsize 0.7.0.9999 +## Breaking Changes + +- `normalized_chi()` has been renamed `fei()`. + ## Bug fixes - Effect sizes for goodness-of-fit now work when passing a `p` that is a table. diff --git a/R/convert_stat_chisq.R b/R/convert_stat_chisq.R index e56605236..9a9a07a68 100644 --- a/R/convert_stat_chisq.R +++ b/R/convert_stat_chisq.R @@ -1,8 +1,8 @@ #' Conversion Chi-Squared to Phi or Cramer's V #' #' Convert between Chi square (\eqn{\chi^2}), Cramer's V, phi (\eqn{\phi}), -#' Cohen's *w*, normalized Chi (\eqn{\chi}) and Pearson's *C* for contingency -#' tables or goodness of fit. +#' Cohen's *w*, Fei (\eqn{פ}) and Pearson's *C* for contingency tables or +#' goodness of fit. #' #' @param chisq The Chi-squared statistic. #' @param n Total sample size. @@ -21,13 +21,13 @@ #' #' @details These functions use the following formulae: #' \cr -#' \deqn{\phi = \sqrt{\chi^2 / n}}{phi = sqrt(\chi^2 / n)} +#' \deqn{\phi = w = \sqrt{\chi^2 / n}}{phi = w = sqrt(\chi^2 / n)} #' \cr -#' \deqn{Cramer's V = \phi / \sqrt{min(nrow,ncol)-1}}{Cramer's V = \phi / sqrt(min(nrow,ncol)-1)} +#' \deqn{\text{Cramer's }V = \phi / \sqrt{min(nrow,ncol)-1}}{Cramer's V = \phi / sqrt(min(nrow,ncol)-1)} #' \cr -#' \deqn{Pearson's C = \sqrt{\chi^2 / (\chi^2 + n)}}{Pearson's C = sqrt(\chi^2 / (\chi^2 + n))} +#' \deqn{\text{Pearson's }C = \sqrt{\chi^2 / (\chi^2 + n)}}{Pearson's C = sqrt(\chi^2 / (\chi^2 + n))} #' \cr -#' \deqn{\chi_{Normalized} = w \times \sqrt{\frac{q}{1-q}}}{Chi (Normalized) = w * sqrt(q/(1-q))} +#' \deqn{פ = w \times \sqrt{\frac{q}{1-q}}}{Fei = w * sqrt(q/(1-q))} #' Where `q` is the smallest of the expected probabilities. #' \cr\cr #' For adjusted versions of *phi* and *V*, see Bergsma, 2013. @@ -65,7 +65,7 @@ #' #> data: Smoking_ASD #' #> X-squared = 7.8521, df = 2, p-value = 0.01972 #' -#' chisq_to_normalized( +#' chisq_to_fei( #' 7.8521, #' n = sum(Smoking_ASD), #' nrow = 1, @@ -229,7 +229,7 @@ chisq_to_cramers_v <- function(chisq, n, nrow, ncol, ci = 0.95, alternative = "g #' @rdname chisq_to_phi #' @export #' @param p Vector of expected values. See [stats::chisq.test()]. -chisq_to_normalized <- function(chisq, n, nrow, ncol, p, +chisq_to_fei <- function(chisq, n, nrow, ncol, p, ci = 0.95, alternative = "greater", ...) { if (is.numeric(ci) || (!missing(nrow) && !missing(ncol))) { # This means that the user passed ncol/nrow @@ -255,7 +255,7 @@ chisq_to_normalized <- function(chisq, n, nrow, ncol, p, N <- n * (1 - q) / q res <- chisq_to_phi(chisq, N, nrow, ncol, ci = ci, alternative = alternative, adjust = FALSE, dont_stop = TRUE) - colnames(res)[1] <- "normalized_chi" + colnames(res)[1] <- "Fei" if ("CI" %in% colnames(res)) { if ((alternative <- attr(res, "alternative")) == "less") { diff --git a/R/effectsize.R b/R/effectsize.R index 9067412bc..ff09bd9d9 100644 --- a/R/effectsize.R +++ b/R/effectsize.R @@ -13,7 +13,7 @@ #' - 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"`, or `"cles"`. #' - A **Chi-squared tests of independence**, depending on `type`: `"cramers_v"` (default), `"phi"`, `"cohens_w"`, `"pearsons_c"`, `"cohens_h"`, `"oddsratio"`, or `"riskratio"`. -#' - A **Chi-squared tests of goodness-of-fit**, depending on `type`: `"normalized_chi"` (default) `"cohens_w"`, `"pearsons_c"` +#' - A **Chi-squared tests of goodness-of-fit**, depending on `type`: `"fei"` (default) `"cohens_w"`, `"pearsons_c"` #' - 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 **Wilcoxon test** depending on `type`: returns "`rank_biserial`" correlation (default) or `"cles"`. diff --git a/R/effectsize.htest.R b/R/effectsize.htest.R index a9baaf5f8..6cf02623d 100644 --- a/R/effectsize.htest.R +++ b/R/effectsize.htest.R @@ -114,14 +114,14 @@ effectsize.htest <- function(model, type = NULL, verbose = TRUE, ...) { if (is.null(type)) { if (nr == 1 || nc == 1) { - type <- "normalized_chi" + type <- "fei" } else { type <- "cramers_v" } } - if (grepl("(c|v|w|phi)$", tolower(type)) || tolower(type) %in% c("normalized_chi", "chi")) { - if (tolower(type) %in% c("normalized_chi", "chi")) { + if (grepl("(c|v|w|phi|fei)$", tolower(type))) { + if (tolower(type) == "fei") { p <- Exp } else { p <- NULL @@ -136,7 +136,8 @@ effectsize.htest <- function(model, type = NULL, verbose = TRUE, ...) { c = , pearsons_c = chisq_to_pearsons_c, chi = , - normalized_chi = chisq_to_normalized + normalized_chi = , + fei = chisq_to_fei ) out <- f( diff --git a/R/interpret.R b/R/interpret.R index 7c6e68356..4fb013eea 100644 --- a/R/interpret.R +++ b/R/interpret.R @@ -172,6 +172,7 @@ interpret.effectsize_table <- function(x, rules, ...) { Cramers_v = , Cramers_v_adjusted = , normalized_chi = , + fei = , Cohens_w = , phi = , phi_adjusted = interpret_cramers_v(value, rules = rules), diff --git a/R/is_effectsize_name.R b/R/is_effectsize_name.R index ec353d654..bf548a24f 100644 --- a/R/is_effectsize_name.R +++ b/R/is_effectsize_name.R @@ -55,7 +55,7 @@ es_info <- matrix( "phi_adjusted", "Phi (adj.)", "onetail", 0, 1, 0, "Pearsons_c", "Pearson's C", "onetail", 0, 1, 0, "Cohens_w", "Cohen's w", "onetail", 0, Inf, 0, - "normalized_chi", "Norm. Chi", "onetail", 0, 1, 0, + "Fei", "Fei", "onetail", 0, 1, 0, "Cohens_g", "Cohen's g", "onetail", -0.5, 0.5, 0, "Cohens_h", "Cohen's h", "twotail", -pi, pi, 0, "Odds_ratio", "Odds ratio", "twotail", 0, Inf, 1, diff --git a/R/xtab.R b/R/xtab.R index ac8c4d211..33cba6292 100644 --- a/R/xtab.R +++ b/R/xtab.R @@ -1,9 +1,8 @@ #' Effect size for contingency tables #' -#' Compute Cramer's *V*, phi (\eqn{\phi}), Cohen's *w*, normalized Chi -#' (\eqn{\chi}), Pearson's contingency coefficient, Odds ratios, Risk ratios, -#' Cohen's *h* and Cohen's *g* for contingency tables or goodness-of-fit. See -#' details. +#' Compute Cramer's *V*, phi (\eqn{\phi}), Cohen's *w*, Fei (\eqn{פ}), Pearson's +#' contingency coefficient, Odds ratios, Risk ratios, Cohen's *h* and Cohen's +#' *g* for contingency tables or goodness-of-fit. See details. #' #' @inheritParams stats::chisq.test #' @param ci Confidence Interval (CI) level @@ -30,17 +29,17 @@ #' can also be used, but since it is not bounded at 1 (can be larger) its #' interpretation is more difficult. #' \cr \cr -#' For goodness-of-fit in 1D tables Cohen's *W*, normalized Chi (\eqn{\chi}) or -#' Pearson's *C* can be used. Cohen's *w* has no upper bound (can be arbitrarily -#' large, depending on the expected distribution). Normalized Chi is an adjusted -#' Cohen's *w*, accounting for the expected distribution, making it bounded -#' between 0-1. Pearson's *C* is also bounded between 0-1. +#' For goodness-of-fit in 1D tables Cohen's *W*, Fei (\eqn{פ}) or Pearson's *C* +#' can be used. Cohen's *w* has no upper bound (can be arbitrarily large, +#' depending on the expected distribution). Fei is an adjusted Cohen's *w*, +#' accounting for the expected distribution, making it bounded between 0-1. +#' Pearson's *C* is also bounded between 0-1. #' \cr \cr #' To summarize, for correlation-like effect sizes, we recommend: #' #' - For a 2x2 table, use `phi()` #' - For larger tables, use `cramers_v()` -#' - For goodness-of-fit, use `normalized_chi()` +#' - For goodness-of-fit, use `fei()` #' #' ## Other Effect Sizes for 2-by-2 xtabs #' @@ -69,15 +68,15 @@ #' \cr \cr #' See *Confidence (Compatibility) Intervals (CIs)*, *CIs and Significance Tests*, #' and *One-Sided CIs* sections for *phi*, Cohen's *w*, Cramer's *V*, -#' Pearson's *C*, and normalized Chi. +#' Pearson's *C*, and *Fei*. #' #' @inheritSection effectsize_CIs Confidence (Compatibility) Intervals (CIs) #' @inheritSection effectsize_CIs CIs and Significance Tests #' #' @return A data frame with the effect size (`Cramers_v`, `phi` (possibly with -#' the suffix `_adjusted`), `Cohens_w`, `normalized_chi`, `Odds_ratio`, -#' `Risk_ratio` (possibly with the prefix `log_`), `Cohens_h`, or `Cohens_g`) -#' and its CIs (`CI_low` and `CI_high`). +#' the suffix `_adjusted`), `Cohens_w`, `Fei`, `Odds_ratio`, `Risk_ratio` +#' (possibly with the prefix `log_`), `Cohens_h`, or `Cohens_g`) and its CIs +#' (`CI_low` and `CI_high`). #' #' @seealso [chisq_to_phi()] for details regarding estimation and CIs. #' @family effect size indices @@ -141,14 +140,14 @@ #' #' Smoking_ASD <- as.table(c(ASD = 17, ASP = 11, TD = 640)) #' -#' normalized_chi(Smoking_ASD) +#' fei(Smoking_ASD) #' #' cohens_w(Smoking_ASD) #' #' pearsons_c(Smoking_ASD) #' #' # Use custom expected values: -#' normalized_chi(Smoking_ASD, p = c(0.015, 0.010, 0.975)) +#' fei(Smoking_ASD, p = c(0.015, 0.010, 0.975)) #' #' cohens_w(Smoking_ASD, p = c(0.015, 0.010, 0.975)) #' @@ -268,11 +267,11 @@ cramers_v <- function(x, y = NULL, ci = 0.95, alternative = "greater", adjust = #' @rdname phi #' @export -normalized_chi <- function(x, y = NULL, ci = 0.95, alternative = "greater", ...) { +fei <- function(x, y = NULL, ci = 0.95, alternative = "greater", ...) { alternative <- match.arg(alternative, c("greater", "two.sided", "less")) if (inherits(x, "BFBayesFactor")) { - stop("Normalized Chi is only applicable to goodness of fit tests.", call. = FALSE) + stop("Fei is only applicable to goodness of fit tests.", call. = FALSE) } @@ -286,7 +285,7 @@ normalized_chi <- function(x, y = NULL, ci = 0.95, alternative = "greater", ...) x$data.name <- NULL } - effectsize(x, type = "normalized_chi", ci = ci, alternative = alternative) + effectsize(x, type = "fei", ci = ci, alternative = alternative) } #' @rdname phi diff --git a/R/zzz_deprecated.R b/R/zzz_deprecated.R index 5624fe0eb..f550fbeee 100644 --- a/R/zzz_deprecated.R +++ b/R/zzz_deprecated.R @@ -7,6 +7,8 @@ #' - `interpret_g` is now [`interpret_hedges_g`]. #' - `interpret_delta` is now [`interpret_glass_delta`]. #' - `interpret_parameters` for *standardized parameters* was incorrect. Use [`interpret_r`] instead. +#' - `normalized_chi` is now [`fei`]. +#' - `chisq_to_normalized` is now [`chisq_to_fei`]. #' #' @rdname effectsize_deprecated #' @name effectsize_deprecated @@ -40,3 +42,19 @@ interpret_parameters <- function(...) { .Deprecated("interpret_r") interpret_r(...) } + +#' @rdname effectsize_deprecated +#' @export +normalized_chi <- function(...) { + .Deprecated("fei") + fei(...) +} + +#' @rdname effectsize_deprecated +#' @export +chisq_to_normalized <- function(...) { + .Deprecated("chisq_to_fei") + chisq_to_fei(...) +} + + diff --git a/man/chisq_to_phi.Rd b/man/chisq_to_phi.Rd index 6ec6e15b9..29b02f958 100644 --- a/man/chisq_to_phi.Rd +++ b/man/chisq_to_phi.Rd @@ -4,7 +4,7 @@ \alias{chisq_to_phi} \alias{chisq_to_cohens_w} \alias{chisq_to_cramers_v} -\alias{chisq_to_normalized} +\alias{chisq_to_fei} \alias{chisq_to_pearsons_c} \alias{phi_to_chisq} \title{Conversion Chi-Squared to Phi or Cramer's V} @@ -41,16 +41,7 @@ chisq_to_cramers_v( ... ) -chisq_to_normalized( - chisq, - n, - nrow, - ncol, - p, - ci = 0.95, - alternative = "greater", - ... -) +chisq_to_fei(chisq, n, nrow, ncol, p, ci = 0.95, alternative = "greater", ...) chisq_to_pearsons_c( chisq, @@ -93,19 +84,19 @@ A data frame with the effect size(s), and confidence interval(s). See } \description{ Convert between Chi square (\eqn{\chi^2}), Cramer's V, phi (\eqn{\phi}), -Cohen's \emph{w}, normalized Chi (\eqn{\chi}) and Pearson's \emph{C} for contingency -tables or goodness of fit. +Cohen's \emph{w}, Fei (\eqn{פ}) and Pearson's \emph{C} for contingency tables or +goodness of fit. } \details{ These functions use the following formulae: \cr -\deqn{\phi = \sqrt{\chi^2 / n}}{phi = sqrt(\chi^2 / n)} +\deqn{\phi = w = \sqrt{\chi^2 / n}}{phi = w = sqrt(\chi^2 / n)} \cr -\deqn{Cramer's V = \phi / \sqrt{min(nrow,ncol)-1}}{Cramer's V = \phi / sqrt(min(nrow,ncol)-1)} +\deqn{\text{Cramer's }V = \phi / \sqrt{min(nrow,ncol)-1}}{Cramer's V = \phi / sqrt(min(nrow,ncol)-1)} \cr -\deqn{Pearson's C = \sqrt{\chi^2 / (\chi^2 + n)}}{Pearson's C = sqrt(\chi^2 / (\chi^2 + n))} +\deqn{\text{Pearson's }C = \sqrt{\chi^2 / (\chi^2 + n)}}{Pearson's C = sqrt(\chi^2 / (\chi^2 + n))} \cr -\deqn{\chi_{Normalized} = w \times \sqrt{\frac{q}{1-q}}}{Chi (Normalized) = w * sqrt(q/(1-q))} +\deqn{פ = w \times \sqrt{\frac{q}{1-q}}}{Fei = w * sqrt(q/(1-q))} Where \code{q} is the smallest of the expected probabilities. \cr\cr For adjusted versions of \emph{phi} and \emph{V}, see Bergsma, 2013. @@ -177,7 +168,7 @@ Smoking_ASD <- as.table(c(ASD = 17, ASP = 11, TD = 640)) #> data: Smoking_ASD #> X-squared = 7.8521, df = 2, p-value = 0.01972 -chisq_to_normalized( +chisq_to_fei( 7.8521, n = sum(Smoking_ASD), nrow = 1, diff --git a/man/effectsize.Rd b/man/effectsize.Rd index f1ded3589..10b3f7dd7 100644 --- a/man/effectsize.Rd +++ b/man/effectsize.Rd @@ -47,7 +47,7 @@ input model. See details. \itemize{ \item A \strong{t-test} depending on \code{type}: \code{"cohens_d"} (default), \code{"hedges_g"}, or \code{"cles"}. \item A \strong{Chi-squared tests of independence}, depending on \code{type}: \code{"cramers_v"} (default), \code{"phi"}, \code{"cohens_w"}, \code{"pearsons_c"}, \code{"cohens_h"}, \code{"oddsratio"}, or \code{"riskratio"}. -\item A \strong{Chi-squared tests of goodness-of-fit}, depending on \code{type}: \code{"normalized_chi"} (default) \code{"cohens_w"}, \code{"pearsons_c"} +\item A \strong{Chi-squared tests of goodness-of-fit}, depending on \code{type}: \code{"fei"} (default) \code{"cohens_w"}, \code{"pearsons_c"} \item A \strong{One-way ANOVA test}, depending on \code{type}: \code{"eta"} (default), \code{"omega"} or \code{"epsilon"} -squared, \code{"f"}, or \code{"f2"}. \item A \strong{McNemar test} returns \emph{Cohen's g}. \item A \strong{Wilcoxon test} depending on \code{type}: returns "\code{rank_biserial}" correlation (default) or \code{"cles"}. diff --git a/man/effectsize_deprecated.Rd b/man/effectsize_deprecated.Rd index 823654fde..89dec7152 100644 --- a/man/effectsize_deprecated.Rd +++ b/man/effectsize_deprecated.Rd @@ -6,6 +6,8 @@ \alias{interpret_g} \alias{interpret_delta} \alias{interpret_parameters} +\alias{normalized_chi} +\alias{chisq_to_normalized} \title{Deprecated functions} \usage{ interpret_d(...) @@ -15,6 +17,10 @@ interpret_g(...) interpret_delta(...) interpret_parameters(...) + +normalized_chi(...) + +chisq_to_normalized(...) } \arguments{ \item{...}{Arguments to the deprecated function.} @@ -28,5 +34,7 @@ Deprecated functions \item \code{interpret_g} is now \code{\link{interpret_hedges_g}}. \item \code{interpret_delta} is now \code{\link{interpret_glass_delta}}. \item \code{interpret_parameters} for \emph{standardized parameters} was incorrect. Use \code{\link{interpret_r}} instead. +\item \code{normalized_chi} is now \code{\link{fei}}. +\item \code{chisq_to_normalized} is now \code{\link{chisq_to_fei}}. } } diff --git a/man/phi.Rd b/man/phi.Rd index 69e3e1992..b56b929cf 100644 --- a/man/phi.Rd +++ b/man/phi.Rd @@ -4,7 +4,7 @@ \alias{phi} \alias{cohens_w} \alias{cramers_v} -\alias{normalized_chi} +\alias{fei} \alias{pearsons_c} \alias{oddsratio} \alias{riskratio} @@ -18,7 +18,7 @@ cohens_w(x, y = NULL, ci = 0.95, alternative = "greater", ...) cramers_v(x, y = NULL, ci = 0.95, alternative = "greater", adjust = FALSE, ...) -normalized_chi(x, y = NULL, ci = 0.95, alternative = "greater", ...) +fei(x, y = NULL, ci = 0.95, alternative = "greater", ...) pearsons_c( x, @@ -62,15 +62,14 @@ goodness-of-fit. Ignored for \code{cohens_g()}.} } \value{ A data frame with the effect size (\code{Cramers_v}, \code{phi} (possibly with -the suffix \verb{_adjusted}), \code{Cohens_w}, \code{normalized_chi}, \code{Odds_ratio}, -\code{Risk_ratio} (possibly with the prefix \code{log_}), \code{Cohens_h}, or \code{Cohens_g}) -and its CIs (\code{CI_low} and \code{CI_high}). +the suffix \verb{_adjusted}), \code{Cohens_w}, \code{Fei}, \code{Odds_ratio}, \code{Risk_ratio} +(possibly with the prefix \code{log_}), \code{Cohens_h}, or \code{Cohens_g}) and its CIs +(\code{CI_low} and \code{CI_high}). } \description{ -Compute Cramer's \emph{V}, phi (\eqn{\phi}), Cohen's \emph{w}, normalized Chi -(\eqn{\chi}), Pearson's contingency coefficient, Odds ratios, Risk ratios, -Cohen's \emph{h} and Cohen's \emph{g} for contingency tables or goodness-of-fit. See -details. +Compute Cramer's \emph{V}, phi (\eqn{\phi}), Cohen's \emph{w}, Fei (\eqn{פ}), Pearson's +contingency coefficient, Odds ratios, Risk ratios, Cohen's \emph{h} and Cohen's +\emph{g} for contingency tables or goodness-of-fit. See details. } \details{ \subsection{Correlation-like Effect Sizes}{ @@ -84,17 +83,17 @@ Pearson's \emph{C} should be used, as they are bounded between 0-1. Cohen's \emp can also be used, but since it is not bounded at 1 (can be larger) its interpretation is more difficult. \cr \cr -For goodness-of-fit in 1D tables Cohen's \emph{W}, normalized Chi (\eqn{\chi}) or -Pearson's \emph{C} can be used. Cohen's \emph{w} has no upper bound (can be arbitrarily -large, depending on the expected distribution). Normalized Chi is an adjusted -Cohen's \emph{w}, accounting for the expected distribution, making it bounded -between 0-1. Pearson's \emph{C} is also bounded between 0-1. +For goodness-of-fit in 1D tables Cohen's \emph{W}, Fei (\eqn{פ}) or Pearson's \emph{C} +can be used. Cohen's \emph{w} has no upper bound (can be arbitrarily large, +depending on the expected distribution). Fei is an adjusted Cohen's \emph{w}, +accounting for the expected distribution, making it bounded between 0-1. +Pearson's \emph{C} is also bounded between 0-1. \cr \cr To summarize, for correlation-like effect sizes, we recommend: \itemize{ \item For a 2x2 table, use \code{phi()} \item For larger tables, use \code{cramers_v()} -\item For goodness-of-fit, use \code{normalized_chi()} +\item For goodness-of-fit, use \code{fei()} } } @@ -127,7 +126,7 @@ Szumilas, 2010). \cr \cr See \emph{Confidence (Compatibility) Intervals (CIs)}, \emph{CIs and Significance Tests}, and \emph{One-Sided CIs} sections for \emph{phi}, Cohen's \emph{w}, Cramer's \emph{V}, -Pearson's \emph{C}, and normalized Chi. +Pearson's \emph{C}, and \emph{Fei}. } \section{Confidence (Compatibility) Intervals (CIs)}{ @@ -228,14 +227,14 @@ pearsons_c(M) Smoking_ASD <- as.table(c(ASD = 17, ASP = 11, TD = 640)) -normalized_chi(Smoking_ASD) +fei(Smoking_ASD) cohens_w(Smoking_ASD) pearsons_c(Smoking_ASD) # Use custom expected values: -normalized_chi(Smoking_ASD, p = c(0.015, 0.010, 0.975)) +fei(Smoking_ASD, p = c(0.015, 0.010, 0.975)) cohens_w(Smoking_ASD, p = c(0.015, 0.010, 0.975)) diff --git a/tests/testthat/test-effectsize.R b/tests/testthat/test-effectsize.R index f27f7aea3..dafcd6c48 100644 --- a/tests/testthat/test-effectsize.R +++ b/tests/testthat/test-effectsize.R @@ -88,8 +88,8 @@ if (require("testthat") && require("effectsize")) { expect_error(effectsize(x, type = "v"), "goodness") expect_error(effectsize(x, type = "phi"), "appropriate") expect_equal(effectsize(x), effectsize(x, type = "chi")) - expect_equal(effectsize(x, type = "chi"), nchi <- normalized_chi(observed.dfc, p = expected.dfc)) - expect_equal(normalized_chi(x), nchi) + expect_equal(effectsize(x, type = "fei"), Fei <- fei(observed.dfc, p = expected.dfc)) + expect_equal(fei(x), Fei) }) test_that("cor.test / other", { diff --git a/tests/testthat/test-xtab.R b/tests/testthat/test-xtab.R index a86ed3bb1..26581744a 100644 --- a/tests/testthat/test-xtab.R +++ b/tests/testthat/test-xtab.R @@ -84,14 +84,14 @@ if (require("testthat") && require("effectsize")) { w1 <- cohens_w(table(mtcars$cyl), p = c(0.34375, 0.21875, 0.43750)) w2 <- cohens_w(table(mtcars$cyl), p = c(0.8, 0.1, 0.1)) - nchi1 <- normalized_chi(table(mtcars$cyl), p = c(0.34375, 0.21875, 0.43750)) - nchi2 <- normalized_chi(table(mtcars$cyl), p = c(0.8, 0.1, 0.1)) + Fei1 <- fei(table(mtcars$cyl), p = c(0.34375, 0.21875, 0.43750)) + Fei2 <- fei(table(mtcars$cyl), p = c(0.8, 0.1, 0.1)) expect_equal(w1[[1]], 0) expect_true(w1[[1]] < w2[[1]]) - expect_true(nchi1[[1]] < nchi2[[1]]) - expect_true(nchi2[[1]] < w2[[1]]) - expect_equal(w2[[1]] * sqrt(0.1 / 0.9), nchi2[[1]]) + expect_true(Fei1[[1]] < Fei2[[1]]) + expect_true(Fei2[[1]] < w2[[1]]) + expect_equal(w2[[1]] * sqrt(0.1 / 0.9), Fei2[[1]]) expect_true(w1$CI_low < w2$CI_low) expect_true(w2$CI_low < w2$CI_high) expect_equal(w2$CI_high, Inf) @@ -116,8 +116,8 @@ if (require("testthat") && require("effectsize")) { cohens_w(O, p = E_tab, rescale.p = TRUE) ) expect_equal( - normalized_chi(O, p = E_vec, rescale.p = TRUE), - normalized_chi(O, p = E_tab, rescale.p = TRUE) + fei(O, p = E_vec, rescale.p = TRUE), + fei(O, p = E_tab, rescale.p = TRUE) ) expect_equal( pearsons_c(O, p = E_vec, rescale.p = TRUE), diff --git a/vignettes/simple_htests.Rmd b/vignettes/simple_htests.Rmd index 9966ef8bd..9d4ca51ac 100644 --- a/vignettes/simple_htests.Rmd +++ b/vignettes/simple_htests.Rmd @@ -252,10 +252,10 @@ cohens_w(O, p = E) However, Cohen's *w* does not account for the distribution of expected probabilities, and as such may be seen is an inflated effect size, and since it can be larger than 1 it is also harder to interpret. -For these reasons, we recommend the Normalized $\chi$ (Chi), which adjusted Cohen's *w* to account for the expected distribution of probabilities, making it range between 0 (observed distribution matches the expected distribution perfectly) and 1 (the observed distribution is maximally different than the expected one). +For these reasons, we recommend the $פ$ (Fei) coefficient, which adjusted Cohen's *w* to account for the expected distribution of probabilities, making it range between 0 (observed distribution matches the expected distribution perfectly) and 1 (the observed distribution is maximally different than the expected one). ```{r} -normalized_chi(O, p = E) +fei(O, p = E) ``` ### Paired Contingency Tables From 996536d5a7f66816b6d87bdc5e0071e2a7f1ec40 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Sat, 10 Sep 2022 19:17:57 +0300 Subject: [PATCH 02/14] fix test --- tests/testthat/test-effectsize.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-effectsize.R b/tests/testthat/test-effectsize.R index dafcd6c48..04e2c478f 100644 --- a/tests/testthat/test-effectsize.R +++ b/tests/testthat/test-effectsize.R @@ -87,7 +87,7 @@ if (require("testthat") && require("effectsize")) { x <- chisq.test(x = observed.dfc, p = expected.dfc) expect_error(effectsize(x, type = "v"), "goodness") expect_error(effectsize(x, type = "phi"), "appropriate") - expect_equal(effectsize(x), effectsize(x, type = "chi")) + expect_equal(effectsize(x), effectsize(x, type = "fei")) expect_equal(effectsize(x, type = "fei"), Fei <- fei(observed.dfc, p = expected.dfc)) expect_equal(fei(x), Fei) }) From 2ab8a809e6518f788c86b0873afccefa62736be1 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Sat, 10 Sep 2022 19:29:31 +0300 Subject: [PATCH 03/14] clean docs --- R/convert_stat_chisq.R | 6 +++--- man/chisq_to_phi.Rd | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/R/convert_stat_chisq.R b/R/convert_stat_chisq.R index 9a9a07a68..ac2e0df09 100644 --- a/R/convert_stat_chisq.R +++ b/R/convert_stat_chisq.R @@ -25,10 +25,10 @@ #' \cr #' \deqn{\text{Cramer's }V = \phi / \sqrt{min(nrow,ncol)-1}}{Cramer's V = \phi / sqrt(min(nrow,ncol)-1)} #' \cr -#' \deqn{\text{Pearson's }C = \sqrt{\chi^2 / (\chi^2 + n)}}{Pearson's C = sqrt(\chi^2 / (\chi^2 + n))} +#' \deqn{פ = w / \sqrt{\frac{1}{min(p_E)}-1}}{Fei = w / sqrt(1/min(p_E) - 1))} +#' Where `p_E` are the expected probabilities. #' \cr -#' \deqn{פ = w \times \sqrt{\frac{q}{1-q}}}{Fei = w * sqrt(q/(1-q))} -#' Where `q` is the smallest of the expected probabilities. +#' \deqn{\text{Pearson's }C = \sqrt{\chi^2 / (\chi^2 + n)}}{Pearson's C = sqrt(\chi^2 / (\chi^2 + n))} #' \cr\cr #' For adjusted versions of *phi* and *V*, see Bergsma, 2013. #' diff --git a/man/chisq_to_phi.Rd b/man/chisq_to_phi.Rd index 29b02f958..eabefd0b4 100644 --- a/man/chisq_to_phi.Rd +++ b/man/chisq_to_phi.Rd @@ -94,10 +94,10 @@ These functions use the following formulae: \cr \deqn{\text{Cramer's }V = \phi / \sqrt{min(nrow,ncol)-1}}{Cramer's V = \phi / sqrt(min(nrow,ncol)-1)} \cr -\deqn{\text{Pearson's }C = \sqrt{\chi^2 / (\chi^2 + n)}}{Pearson's C = sqrt(\chi^2 / (\chi^2 + n))} +\deqn{פ = w / \sqrt{\frac{1}{min(p_E)}-1}}{Fei = w / sqrt(1/min(p_E) - 1))} +Where \code{p_E} are the expected probabilities. \cr -\deqn{פ = w \times \sqrt{\frac{q}{1-q}}}{Fei = w * sqrt(q/(1-q))} -Where \code{q} is the smallest of the expected probabilities. +\deqn{\text{Pearson's }C = \sqrt{\chi^2 / (\chi^2 + n)}}{Pearson's C = sqrt(\chi^2 / (\chi^2 + n))} \cr\cr For adjusted versions of \emph{phi} and \emph{V}, see Bergsma, 2013. } From df64ae984828ed6cd5d0a59a2f6fe9d85b286c5d Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Sat, 10 Sep 2022 19:40:07 +0300 Subject: [PATCH 04/14] clean up some more --- R/convert_stat_chisq.R | 2 +- man/chisq_to_phi.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/convert_stat_chisq.R b/R/convert_stat_chisq.R index ac2e0df09..cce0d5d57 100644 --- a/R/convert_stat_chisq.R +++ b/R/convert_stat_chisq.R @@ -1,6 +1,6 @@ #' Conversion Chi-Squared to Phi or Cramer's V #' -#' Convert between Chi square (\eqn{\chi^2}), Cramer's V, phi (\eqn{\phi}), +#' Convert between Chi square (\eqn{\chi^2}), phi (\eqn{\phi}), Cramer's V, #' Cohen's *w*, Fei (\eqn{פ}) and Pearson's *C* for contingency tables or #' goodness of fit. #' diff --git a/man/chisq_to_phi.Rd b/man/chisq_to_phi.Rd index eabefd0b4..1bc017d47 100644 --- a/man/chisq_to_phi.Rd +++ b/man/chisq_to_phi.Rd @@ -83,7 +83,7 @@ A data frame with the effect size(s), and confidence interval(s). See \code{\link[=cramers_v]{cramers_v()}}. } \description{ -Convert between Chi square (\eqn{\chi^2}), Cramer's V, phi (\eqn{\phi}), +Convert between Chi square (\eqn{\chi^2}), phi (\eqn{\phi}), Cramer's V, Cohen's \emph{w}, Fei (\eqn{פ}) and Pearson's \emph{C} for contingency tables or goodness of fit. } From 683843869fdd753c418bca66f0757d5964918d99 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Sat, 10 Sep 2022 19:41:12 +0300 Subject: [PATCH 05/14] clean up xtab docs --- R/xtab.R | 42 +++++++++++++++++++++++------------------- man/phi.Rd | 30 +++++++++++++++++++++++------- 2 files changed, 46 insertions(+), 26 deletions(-) diff --git a/R/xtab.R b/R/xtab.R index 33cba6292..61e81e8c3 100644 --- a/R/xtab.R +++ b/R/xtab.R @@ -13,8 +13,8 @@ #' Partial matching is allowed (e.g., `"g"`, `"l"`, `"two"`...). See #' *One-Sided CIs* in [effectsize_CIs]. #' @param adjust Should the effect size be bias-corrected? Defaults to `FALSE`. -#' @param ... Arguments passed to [stats::chisq.test()], such as `p` for -#' goodness-of-fit. Ignored for `cohens_g()`. +#' @param ... For goodness-of-fit effect sizes, can pass `rescale.p` (see +#' [stats::chisq.test()]). Else, ignored. #' #' @details #' @@ -204,7 +204,7 @@ phi <- function(x, y = NULL, ci = 0.95, alternative = "greater", adjust = FALSE, stop("'x' is not a Chi-squared test!", call. = FALSE) } } else { - x <- suppressWarnings(stats::chisq.test(x, y, ...)) + x <- suppressWarnings(stats::chisq.test(x, y)) x$data.name <- NULL } @@ -212,42 +212,44 @@ phi <- function(x, y = NULL, ci = 0.95, alternative = "greater", adjust = FALSE, } #' @rdname phi +#' @importFrom stats chisq.test #' @export -cohens_w <- function(x, y = NULL, ci = 0.95, alternative = "greater", ...) { +cramers_v <- function(x, y = NULL, ci = 0.95, alternative = "greater", adjust = FALSE, ...) { alternative <- match.arg(alternative, c("greater", "two.sided", "less")) if (inherits(x, "BFBayesFactor")) { if (!inherits(x@numerator[[1]], "BFcontingencyTable")) { stop("'x' is not a Chi-squared test!", call. = FALSE) } - return(effectsize(x, type = "phi", ci = ci, ...)) + return(effectsize(x, type = "cramers_v", adjust = adjust, ci = ci, ...)) } if (inherits(x, "htest")) { if (!(grepl("Pearson's Chi-squared", x$method) || - grepl("Chi-squared test for given probabilities", x$method))) { + grepl("Chi-squared test for given probabilities", x$method))) { stop("'x' is not a Chi-squared test!", call. = FALSE) } } else { - x <- suppressWarnings(stats::chisq.test(x, y, ...)) + x <- suppressWarnings(stats::chisq.test(x, y)) x$data.name <- NULL } - effectsize(x, type = "cohens_w", ci = ci, alternative = alternative) + effectsize(x, type = "cramers_v", adjust = adjust, ci = ci, alternative = alternative) } #' @rdname phi #' @importFrom stats chisq.test #' @export -cramers_v <- function(x, y = NULL, ci = 0.95, alternative = "greater", adjust = FALSE, ...) { +cohens_w <- function(x, y = NULL, p = rep(1/length(x), length(x)), + ci = 0.95, alternative = "greater", ...) { alternative <- match.arg(alternative, c("greater", "two.sided", "less")) if (inherits(x, "BFBayesFactor")) { if (!inherits(x@numerator[[1]], "BFcontingencyTable")) { stop("'x' is not a Chi-squared test!", call. = FALSE) } - return(effectsize(x, type = "cramers_v", adjust = adjust, ci = ci, ...)) + return(effectsize(x, type = "phi", ci = ci, ...)) } @@ -257,17 +259,18 @@ cramers_v <- function(x, y = NULL, ci = 0.95, alternative = "greater", adjust = stop("'x' is not a Chi-squared test!", call. = FALSE) } } else { - x <- suppressWarnings(stats::chisq.test(x, y, ...)) + x <- suppressWarnings(stats::chisq.test(x, y, p = p, ...)) x$data.name <- NULL } - effectsize(x, type = "cramers_v", adjust = adjust, ci = ci, alternative = alternative) + effectsize(x, type = "cohens_w", ci = ci, alternative = alternative) } #' @rdname phi +#' @importFrom stats chisq.test #' @export -fei <- function(x, y = NULL, ci = 0.95, alternative = "greater", ...) { +fei <- function(x, p = rep(1/length(x), length(x)), ci = 0.95, alternative = "greater", ...) { alternative <- match.arg(alternative, c("greater", "two.sided", "less")) if (inherits(x, "BFBayesFactor")) { @@ -281,7 +284,7 @@ fei <- function(x, y = NULL, ci = 0.95, alternative = "greater", ...) { stop("'x' is not a Chi-squared test!", call. = FALSE) } } else { - x <- suppressWarnings(stats::chisq.test(x, y, ...)) + x <- suppressWarnings(stats::chisq.test(x, y = NULL, p = p, ...)) x$data.name <- NULL } @@ -291,7 +294,8 @@ fei <- function(x, y = NULL, ci = 0.95, alternative = "greater", ...) { #' @rdname phi #' @importFrom stats chisq.test #' @export -pearsons_c <- function(x, y = NULL, ci = 0.95, alternative = "greater", adjust = FALSE, ...) { +pearsons_c <- function(x, y = NULL, p = rep(1/length(x), length(x)), + ci = 0.95, alternative = "greater", ...) { alternative <- match.arg(alternative, c("greater", "two.sided", "less")) if (inherits(x, "BFBayesFactor")) { @@ -308,7 +312,7 @@ pearsons_c <- function(x, y = NULL, ci = 0.95, alternative = "greater", adjust = stop("'x' is not a Chi-squared test!", call. = FALSE) } } else { - x <- suppressWarnings(stats::chisq.test(x, y, ...)) + x <- suppressWarnings(stats::chisq.test(x, y, p = p, ...)) x$data.name <- NULL } @@ -339,7 +343,7 @@ oddsratio <- function(x, y = NULL, ci = 0.95, alternative = "two.sided", log = F return(effectsize(x, type = "or", log = log, ci = ci, ...)) } - res <- suppressWarnings(stats::chisq.test(x, y, ...)) + res <- suppressWarnings(stats::chisq.test(x, y)) Obs <- res$observed if (any(c(colSums(Obs), rowSums(Obs)) == 0L)) { @@ -415,7 +419,7 @@ riskratio <- function(x, y = NULL, ci = 0.95, alternative = "two.sided", log = F return(effectsize(x, type = "rr", log = log, ci = ci, ...)) } - res <- suppressWarnings(stats::chisq.test(x, y, ...)) + res <- suppressWarnings(stats::chisq.test(x, y)) Obs <- res$observed if (any(c(colSums(Obs), rowSums(Obs)) == 0L)) { @@ -493,7 +497,7 @@ cohens_h <- function(x, y = NULL, ci = 0.95, alternative = "two.sided", ...) { return(effectsize(x, type = "cohens_h", ci = ci, ...)) } - res <- suppressWarnings(stats::chisq.test(x, y, ...)) + res <- suppressWarnings(stats::chisq.test(x, y)) Obs <- res$observed if (any(c(colSums(Obs), rowSums(Obs)) == 0L)) { diff --git a/man/phi.Rd b/man/phi.Rd index b56b929cf..7c497911a 100644 --- a/man/phi.Rd +++ b/man/phi.Rd @@ -2,8 +2,8 @@ % Please edit documentation in R/xtab.R \name{phi} \alias{phi} -\alias{cohens_w} \alias{cramers_v} +\alias{cohens_w} \alias{fei} \alias{pearsons_c} \alias{oddsratio} @@ -14,18 +14,31 @@ \usage{ phi(x, y = NULL, ci = 0.95, alternative = "greater", adjust = FALSE, ...) -cohens_w(x, y = NULL, ci = 0.95, alternative = "greater", ...) - cramers_v(x, y = NULL, ci = 0.95, alternative = "greater", adjust = FALSE, ...) -fei(x, y = NULL, ci = 0.95, alternative = "greater", ...) +cohens_w( + x, + y = NULL, + p = rep(1/length(x), length(x)), + ci = 0.95, + alternative = "greater", + ... +) + +fei( + x, + p = rep(1/length(x), length(x)), + ci = 0.95, + alternative = "greater", + ... +) pearsons_c( x, y = NULL, + p = rep(1/length(x), length(x)), ci = 0.95, alternative = "greater", - adjust = FALSE, ... ) @@ -55,8 +68,11 @@ Partial matching is allowed (e.g., \code{"g"}, \code{"l"}, \code{"two"}...). See \item{adjust}{Should the effect size be bias-corrected? Defaults to \code{FALSE}.} -\item{...}{Arguments passed to \code{\link[stats:chisq.test]{stats::chisq.test()}}, such as \code{p} for -goodness-of-fit. Ignored for \code{cohens_g()}.} +\item{...}{For goodness-of-fit effect sizes, can pass \code{rescale.p} (see +\code{\link[stats:chisq.test]{stats::chisq.test()}}). Else, ignored.} + +\item{p}{a vector of probabilities of the same length as \code{x}. + An error is given if any entry of \code{p} is negative.} \item{log}{Take in or output the log of the ratio (such as in logistic models).} } From 8fef7cfcdf706d9ca1bdfc203460cc2d1b134f06 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Sat, 10 Sep 2022 19:45:54 +0300 Subject: [PATCH 06/14] remove redundant adjust argument from pearson_c --- R/xtab.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/xtab.R b/R/xtab.R index 61e81e8c3..f8aac48b1 100644 --- a/R/xtab.R +++ b/R/xtab.R @@ -302,7 +302,7 @@ pearsons_c <- function(x, y = NULL, p = rep(1/length(x), length(x)), if (!inherits(x@numerator[[1]], "BFcontingencyTable")) { stop("'x' is not a Chi-squared test!", call. = FALSE) } - return(effectsize(x, type = "pearsons_c", adjust = adjust, ci = ci, ...)) + return(effectsize(x, type = "pearsons_c", ci = ci, ...)) } @@ -316,7 +316,7 @@ pearsons_c <- function(x, y = NULL, p = rep(1/length(x), length(x)), x$data.name <- NULL } - effectsize(x, type = "pearsons_c", adjust = adjust, ci = ci, alternative = alternative) + effectsize(x, type = "pearsons_c", ci = ci, alternative = alternative) } From ff122726ab76e7562792178e81a74f6b7de64697 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Sat, 10 Sep 2022 20:15:29 +0300 Subject: [PATCH 07/14] Skip this test on older R versions --- tests/testthat/test-eta_squared.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/testthat/test-eta_squared.R b/tests/testthat/test-eta_squared.R index c73a0de8e..37bfb5f55 100644 --- a/tests/testthat/test-eta_squared.R +++ b/tests/testthat/test-eta_squared.R @@ -647,8 +647,7 @@ if (require("testthat") && require("effectsize")) { expect_output(print(out), "Type II") skip_if_not_installed("car") - skip_if(getRversion() <= "3.6" && - Sys.info()["sysname"] == "Darwin") + skip_if(getRversion() <= "3.6") b_lm <- car::Anova(lm(mpg ~ cyl + am, data = mtcars), type = 2) out_lm <- eta_squared(b_lm) expect_equal(out[1:2, ], out_lm, ignore_attr = TRUE) From 64f2c24c7ab66da9000e98ceb27d4948dc6666dc Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Sat, 10 Sep 2022 21:33:47 +0300 Subject: [PATCH 08/14] Use XXX as test --- R/convert_stat_chisq.R | 4 ++-- R/xtab.R | 4 ++-- man/chisq_to_phi.Rd | 4 ++-- man/phi.Rd | 4 ++-- vignettes/simple_htests.Rmd | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/R/convert_stat_chisq.R b/R/convert_stat_chisq.R index cce0d5d57..5bd0cfab8 100644 --- a/R/convert_stat_chisq.R +++ b/R/convert_stat_chisq.R @@ -1,7 +1,7 @@ #' Conversion Chi-Squared to Phi or Cramer's V #' #' Convert between Chi square (\eqn{\chi^2}), phi (\eqn{\phi}), Cramer's V, -#' Cohen's *w*, Fei (\eqn{פ}) and Pearson's *C* for contingency tables or +#' Cohen's *w*, Fei (\eqn{XXX}) and Pearson's *C* for contingency tables or #' goodness of fit. #' #' @param chisq The Chi-squared statistic. @@ -25,7 +25,7 @@ #' \cr #' \deqn{\text{Cramer's }V = \phi / \sqrt{min(nrow,ncol)-1}}{Cramer's V = \phi / sqrt(min(nrow,ncol)-1)} #' \cr -#' \deqn{פ = w / \sqrt{\frac{1}{min(p_E)}-1}}{Fei = w / sqrt(1/min(p_E) - 1))} +#' \deqn{XXX = w / \sqrt{\frac{1}{min(p_E)}-1}}{Fei = w / sqrt(1/min(p_E) - 1))} #' Where `p_E` are the expected probabilities. #' \cr #' \deqn{\text{Pearson's }C = \sqrt{\chi^2 / (\chi^2 + n)}}{Pearson's C = sqrt(\chi^2 / (\chi^2 + n))} diff --git a/R/xtab.R b/R/xtab.R index f8aac48b1..6db7ca69f 100644 --- a/R/xtab.R +++ b/R/xtab.R @@ -1,6 +1,6 @@ #' Effect size for contingency tables #' -#' Compute Cramer's *V*, phi (\eqn{\phi}), Cohen's *w*, Fei (\eqn{פ}), Pearson's +#' Compute Cramer's *V*, phi (\eqn{\phi}), Cohen's *w*, Fei (\eqn{XXX}), Pearson's #' contingency coefficient, Odds ratios, Risk ratios, Cohen's *h* and Cohen's #' *g* for contingency tables or goodness-of-fit. See details. #' @@ -29,7 +29,7 @@ #' can also be used, but since it is not bounded at 1 (can be larger) its #' interpretation is more difficult. #' \cr \cr -#' For goodness-of-fit in 1D tables Cohen's *W*, Fei (\eqn{פ}) or Pearson's *C* +#' For goodness-of-fit in 1D tables Cohen's *W*, Fei (\eqn{XXX}) or Pearson's *C* #' can be used. Cohen's *w* has no upper bound (can be arbitrarily large, #' depending on the expected distribution). Fei is an adjusted Cohen's *w*, #' accounting for the expected distribution, making it bounded between 0-1. diff --git a/man/chisq_to_phi.Rd b/man/chisq_to_phi.Rd index 1bc017d47..f6f12523b 100644 --- a/man/chisq_to_phi.Rd +++ b/man/chisq_to_phi.Rd @@ -84,7 +84,7 @@ A data frame with the effect size(s), and confidence interval(s). See } \description{ Convert between Chi square (\eqn{\chi^2}), phi (\eqn{\phi}), Cramer's V, -Cohen's \emph{w}, Fei (\eqn{פ}) and Pearson's \emph{C} for contingency tables or +Cohen's \emph{w}, Fei (\eqn{XXX}) and Pearson's \emph{C} for contingency tables or goodness of fit. } \details{ @@ -94,7 +94,7 @@ These functions use the following formulae: \cr \deqn{\text{Cramer's }V = \phi / \sqrt{min(nrow,ncol)-1}}{Cramer's V = \phi / sqrt(min(nrow,ncol)-1)} \cr -\deqn{פ = w / \sqrt{\frac{1}{min(p_E)}-1}}{Fei = w / sqrt(1/min(p_E) - 1))} +\deqn{XXX = w / \sqrt{\frac{1}{min(p_E)}-1}}{Fei = w / sqrt(1/min(p_E) - 1))} Where \code{p_E} are the expected probabilities. \cr \deqn{\text{Pearson's }C = \sqrt{\chi^2 / (\chi^2 + n)}}{Pearson's C = sqrt(\chi^2 / (\chi^2 + n))} diff --git a/man/phi.Rd b/man/phi.Rd index 7c497911a..fbf47dafa 100644 --- a/man/phi.Rd +++ b/man/phi.Rd @@ -83,7 +83,7 @@ the suffix \verb{_adjusted}), \code{Cohens_w}, \code{Fei}, \code{Odds_ratio}, \c (\code{CI_low} and \code{CI_high}). } \description{ -Compute Cramer's \emph{V}, phi (\eqn{\phi}), Cohen's \emph{w}, Fei (\eqn{פ}), Pearson's +Compute Cramer's \emph{V}, phi (\eqn{\phi}), Cohen's \emph{w}, Fei (\eqn{XXX}), Pearson's contingency coefficient, Odds ratios, Risk ratios, Cohen's \emph{h} and Cohen's \emph{g} for contingency tables or goodness-of-fit. See details. } @@ -99,7 +99,7 @@ Pearson's \emph{C} should be used, as they are bounded between 0-1. Cohen's \emp can also be used, but since it is not bounded at 1 (can be larger) its interpretation is more difficult. \cr \cr -For goodness-of-fit in 1D tables Cohen's \emph{W}, Fei (\eqn{פ}) or Pearson's \emph{C} +For goodness-of-fit in 1D tables Cohen's \emph{W}, Fei (\eqn{XXX}) or Pearson's \emph{C} can be used. Cohen's \emph{w} has no upper bound (can be arbitrarily large, depending on the expected distribution). Fei is an adjusted Cohen's \emph{w}, accounting for the expected distribution, making it bounded between 0-1. diff --git a/vignettes/simple_htests.Rmd b/vignettes/simple_htests.Rmd index 9d4ca51ac..e79c69cbb 100644 --- a/vignettes/simple_htests.Rmd +++ b/vignettes/simple_htests.Rmd @@ -252,7 +252,7 @@ cohens_w(O, p = E) However, Cohen's *w* does not account for the distribution of expected probabilities, and as such may be seen is an inflated effect size, and since it can be larger than 1 it is also harder to interpret. -For these reasons, we recommend the $פ$ (Fei) coefficient, which adjusted Cohen's *w* to account for the expected distribution of probabilities, making it range between 0 (observed distribution matches the expected distribution perfectly) and 1 (the observed distribution is maximally different than the expected one). +For these reasons, we recommend the $XXX$ (Fei) coefficient, which adjusted Cohen's *w* to account for the expected distribution of probabilities, making it range between 0 (observed distribution matches the expected distribution perfectly) and 1 (the observed distribution is maximally different than the expected one). ```{r} fei(O, p = E) From 2b684eeec578a656e367109330a94e5fcfa0957b Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Sat, 10 Sep 2022 21:51:10 +0300 Subject: [PATCH 09/14] try 1 --- vignettes/simple_htests.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/simple_htests.Rmd b/vignettes/simple_htests.Rmd index e79c69cbb..9d4ca51ac 100644 --- a/vignettes/simple_htests.Rmd +++ b/vignettes/simple_htests.Rmd @@ -252,7 +252,7 @@ cohens_w(O, p = E) However, Cohen's *w* does not account for the distribution of expected probabilities, and as such may be seen is an inflated effect size, and since it can be larger than 1 it is also harder to interpret. -For these reasons, we recommend the $XXX$ (Fei) coefficient, which adjusted Cohen's *w* to account for the expected distribution of probabilities, making it range between 0 (observed distribution matches the expected distribution perfectly) and 1 (the observed distribution is maximally different than the expected one). +For these reasons, we recommend the $פ$ (Fei) coefficient, which adjusted Cohen's *w* to account for the expected distribution of probabilities, making it range between 0 (observed distribution matches the expected distribution perfectly) and 1 (the observed distribution is maximally different than the expected one). ```{r} fei(O, p = E) From 63df210da0d756af936e1afe276ec10dd83405b0 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Sat, 10 Sep 2022 21:59:08 +0300 Subject: [PATCH 10/14] try 2 --- R/convert_stat_chisq.R | 2 +- man/chisq_to_phi.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/convert_stat_chisq.R b/R/convert_stat_chisq.R index 5bd0cfab8..fb6bce4e6 100644 --- a/R/convert_stat_chisq.R +++ b/R/convert_stat_chisq.R @@ -1,7 +1,7 @@ #' Conversion Chi-Squared to Phi or Cramer's V #' #' Convert between Chi square (\eqn{\chi^2}), phi (\eqn{\phi}), Cramer's V, -#' Cohen's *w*, Fei (\eqn{XXX}) and Pearson's *C* for contingency tables or +#' Cohen's *w*, Fei (*פ*) and Pearson's *C* for contingency tables or #' goodness of fit. #' #' @param chisq The Chi-squared statistic. diff --git a/man/chisq_to_phi.Rd b/man/chisq_to_phi.Rd index f6f12523b..2fe695427 100644 --- a/man/chisq_to_phi.Rd +++ b/man/chisq_to_phi.Rd @@ -84,7 +84,7 @@ A data frame with the effect size(s), and confidence interval(s). See } \description{ Convert between Chi square (\eqn{\chi^2}), phi (\eqn{\phi}), Cramer's V, -Cohen's \emph{w}, Fei (\eqn{XXX}) and Pearson's \emph{C} for contingency tables or +Cohen's \emph{w}, Fei (\emph{פ}) and Pearson's \emph{C} for contingency tables or goodness of fit. } \details{ From 9e9ac9e0fd741ac3b433463b18f0a0ca970d456d Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Sat, 10 Sep 2022 22:16:30 +0300 Subject: [PATCH 11/14] try 3 --- R/convert_stat_chisq.R | 2 ++ man/chisq_to_phi.Rd | 1 + 2 files changed, 3 insertions(+) diff --git a/R/convert_stat_chisq.R b/R/convert_stat_chisq.R index fb6bce4e6..a7ce86469 100644 --- a/R/convert_stat_chisq.R +++ b/R/convert_stat_chisq.R @@ -4,6 +4,8 @@ #' Cohen's *w*, Fei (*פ*) and Pearson's *C* for contingency tables or #' goodness of fit. #' +#' @encoding UTF-8 +#' #' @param chisq The Chi-squared statistic. #' @param n Total sample size. #' @param nrow,ncol The number of rows/columns in the contingency table. diff --git a/man/chisq_to_phi.Rd b/man/chisq_to_phi.Rd index 2fe695427..cd6486827 100644 --- a/man/chisq_to_phi.Rd +++ b/man/chisq_to_phi.Rd @@ -1,5 +1,6 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/convert_stat_chisq.R +\encoding{UTF-8} \name{chisq_to_phi} \alias{chisq_to_phi} \alias{chisq_to_cohens_w} From 218bc282960581360f775638cc97f427d2098222 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Sun, 11 Sep 2022 08:14:17 +0300 Subject: [PATCH 12/14] try 4 --- R/convert_stat_chisq.R | 5 ++--- man/chisq_to_phi.Rd | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/R/convert_stat_chisq.R b/R/convert_stat_chisq.R index a7ce86469..2172db823 100644 --- a/R/convert_stat_chisq.R +++ b/R/convert_stat_chisq.R @@ -1,10 +1,9 @@ #' Conversion Chi-Squared to Phi or Cramer's V #' #' Convert between Chi square (\eqn{\chi^2}), phi (\eqn{\phi}), Cramer's V, -#' Cohen's *w*, Fei (*פ*) and Pearson's *C* for contingency tables or +#' Cohen's *w*, Fei (\u05e4) and Pearson's *C* for contingency tables or #' goodness of fit. #' -#' @encoding UTF-8 #' #' @param chisq The Chi-squared statistic. #' @param n Total sample size. @@ -27,7 +26,7 @@ #' \cr #' \deqn{\text{Cramer's }V = \phi / \sqrt{min(nrow,ncol)-1}}{Cramer's V = \phi / sqrt(min(nrow,ncol)-1)} #' \cr -#' \deqn{XXX = w / \sqrt{\frac{1}{min(p_E)}-1}}{Fei = w / sqrt(1/min(p_E) - 1))} +#' \deqn{Fei = w / \sqrt{\frac{1}{min(p_E)}-1}}{Fei = w / sqrt(1/min(p_E) - 1))} #' Where `p_E` are the expected probabilities. #' \cr #' \deqn{\text{Pearson's }C = \sqrt{\chi^2 / (\chi^2 + n)}}{Pearson's C = sqrt(\chi^2 / (\chi^2 + n))} diff --git a/man/chisq_to_phi.Rd b/man/chisq_to_phi.Rd index cd6486827..ac5bfc666 100644 --- a/man/chisq_to_phi.Rd +++ b/man/chisq_to_phi.Rd @@ -1,6 +1,5 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/convert_stat_chisq.R -\encoding{UTF-8} \name{chisq_to_phi} \alias{chisq_to_phi} \alias{chisq_to_cohens_w} @@ -85,7 +84,7 @@ A data frame with the effect size(s), and confidence interval(s). See } \description{ Convert between Chi square (\eqn{\chi^2}), phi (\eqn{\phi}), Cramer's V, -Cohen's \emph{w}, Fei (\emph{פ}) and Pearson's \emph{C} for contingency tables or +Cohen's \emph{w}, Fei (\u05e4) and Pearson's \emph{C} for contingency tables or goodness of fit. } \details{ @@ -95,7 +94,7 @@ These functions use the following formulae: \cr \deqn{\text{Cramer's }V = \phi / \sqrt{min(nrow,ncol)-1}}{Cramer's V = \phi / sqrt(min(nrow,ncol)-1)} \cr -\deqn{XXX = w / \sqrt{\frac{1}{min(p_E)}-1}}{Fei = w / sqrt(1/min(p_E) - 1))} +\deqn{Fei = w / \sqrt{\frac{1}{min(p_E)}-1}}{Fei = w / sqrt(1/min(p_E) - 1))} Where \code{p_E} are the expected probabilities. \cr \deqn{\text{Pearson's }C = \sqrt{\chi^2 / (\chi^2 + n)}}{Pearson's C = sqrt(\chi^2 / (\chi^2 + n))} From e70a1ca410d45e2df6e50099688edffee617b8d0 Mon Sep 17 00:00:00 2001 From: "Brenton M. Wiernik" Date: Mon, 12 Sep 2022 11:42:13 -0400 Subject: [PATCH 13/14] Update documentation formatting --- DESCRIPTION | 2 +- R/convert_stat_chisq.R | 55 +++++++++++++---------- man/{chisq_to_phi.Rd => convert_chisq.Rd} | 43 ++++++++++-------- 3 files changed, 58 insertions(+), 42 deletions(-) rename man/{chisq_to_phi.Rd => convert_chisq.Rd} (83%) diff --git a/DESCRIPTION b/DESCRIPTION index 6938f3e94..53e871b13 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -89,7 +89,7 @@ VignetteBuilder: Encoding: UTF-8 Language: en-US Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.1 +RoxygenNote: 7.2.1.9000 Config/testthat/edition: 3 Config/testthat/parallel: true Config/Needs/website: diff --git a/R/convert_stat_chisq.R b/R/convert_stat_chisq.R index 2172db823..cdf2f707c 100644 --- a/R/convert_stat_chisq.R +++ b/R/convert_stat_chisq.R @@ -1,11 +1,13 @@ -#' Conversion Chi-Squared to Phi or Cramer's V +#' Convert chi-square to correlation-like effect sizes (phi, V, Fei, C) #' -#' Convert between Chi square (\eqn{\chi^2}), phi (\eqn{\phi}), Cramer's V, -#' Cohen's *w*, Fei (\u05e4) and Pearson's *C* for contingency tables or -#' goodness of fit. +#' Convert between \eqn{\chi^2} (chi-square), \eqn{\phi} (phi), Cramer's \eqn{V}, +#' Cohen's \eqn{w}, \ifelse{latex}{\eqn{Fei}}{פ (Fei)} and Pearson's \eqn{C} +#' for contingency tables or goodness of fit. #' +#' @name chisq_to_phi +#' @rdname convert_chisq #' -#' @param chisq The Chi-squared statistic. +#' @param chisq The \eqn{\chi^2} (chi-square) statistic. #' @param n Total sample size. #' @param nrow,ncol The number of rows/columns in the contingency table. #' @param ci Confidence Interval (CI) level @@ -20,18 +22,25 @@ #' @return A data frame with the effect size(s), and confidence interval(s). See #' [cramers_v()]. #' -#' @details These functions use the following formulae: -#' \cr -#' \deqn{\phi = w = \sqrt{\chi^2 / n}}{phi = w = sqrt(\chi^2 / n)} -#' \cr -#' \deqn{\text{Cramer's }V = \phi / \sqrt{min(nrow,ncol)-1}}{Cramer's V = \phi / sqrt(min(nrow,ncol)-1)} -#' \cr -#' \deqn{Fei = w / \sqrt{\frac{1}{min(p_E)}-1}}{Fei = w / sqrt(1/min(p_E) - 1))} -#' Where `p_E` are the expected probabilities. -#' \cr -#' \deqn{\text{Pearson's }C = \sqrt{\chi^2 / (\chi^2 + n)}}{Pearson's C = sqrt(\chi^2 / (\chi^2 + n))} -#' \cr\cr -#' For adjusted versions of *phi* and *V*, see Bergsma, 2013. +#' @details These functions use the following formulas: +#' +#' \deqn{\phi = w = \sqrt{\chi^2 / n}}{phi = w = sqrt(\frac{\chi^2}{n})} +#' \ifelse{latex}{ +#' \deqn{\textrm{Cramer's } V = \phi / \sqrt{\min(\textit{nrow}, \textit{ncol}) - 1}} +#' }{ +#' \deqn{\textrm{Cramer's } V = \phi / \sqrt{\min(\textit{nrow}, \textit{ncol }) - 1}}{Cramer's V = \phi / sqrt(min(nrow, ncol) - 1)} +#' } +#' +#' \ifelse{latex}{ +#' \deqn{\textit{Fei} = \phi / \sqrt{[1 / \min(p_E)] - 1}} +#' }{ +#' \deqn{פ = \phi / \sqrt{[1 / \min(p_E)] - 1}}{פ = w / sqrt(1 / min(p_E) - 1))} +#' } +#' Where \eqn{p_E} are the expected probabilities. +#' +#' \deqn{\textrm{Pearson's } C = \sqrt{\chi^2 / (\chi^2 + n)}}{Pearson's C = sqrt(\chi^2 / (\chi^2 + n))} +#' +#' For adjusted versions of \eqn{\phi} and \eqn{V}, see Bergsma, 2013. #' #' @inheritSection effectsize_CIs Confidence (Compatibility) Intervals (CIs) #' @inheritSection effectsize_CIs CIs and Significance Tests @@ -161,7 +170,7 @@ chisq_to_phi <- function(chisq, n, nrow = 2, ncol = 2, ci = 0.95, alternative = } -#' @rdname chisq_to_phi +#' @rdname convert_chisq #' @export chisq_to_cohens_w <- function(chisq, n, nrow, ncol, ci = 0.95, alternative = "greater", ...) { res <- chisq_to_phi(chisq, n, nrow, ncol, ci = ci, alternative = alternative, adjust = FALSE, dont_stop = TRUE) @@ -192,7 +201,7 @@ chisq_to_cohens_w <- function(chisq, n, nrow, ncol, ci = 0.95, alternative = "gr return(res) } -#' @rdname chisq_to_phi +#' @rdname convert_chisq #' @export chisq_to_cramers_v <- function(chisq, n, nrow, ncol, ci = 0.95, alternative = "greater", adjust = FALSE, ...) { if (ncol == 1 || nrow == 1) { @@ -227,7 +236,7 @@ chisq_to_cramers_v <- function(chisq, n, nrow, ncol, ci = 0.95, alternative = "g } -#' @rdname chisq_to_phi +#' @rdname convert_chisq #' @export #' @param p Vector of expected values. See [stats::chisq.test()]. chisq_to_fei <- function(chisq, n, nrow, ncol, p, @@ -273,7 +282,7 @@ chisq_to_fei <- function(chisq, n, nrow, ncol, p, return(res) } -#' @rdname chisq_to_phi +#' @rdname convert_chisq #' @export chisq_to_pearsons_c <- function(chisq, n, nrow, ncol, ci = 0.95, alternative = "greater", ...) { res <- chisq_to_phi(chisq, n, nrow, ncol, ci = ci, alternative = alternative, adjust = FALSE, dont_stop = TRUE) @@ -293,8 +302,8 @@ chisq_to_pearsons_c <- function(chisq, n, nrow, ncol, ci = 0.95, alternative = " # Reverse ----------------------------------------------------------------- -#' @rdname chisq_to_phi -#' @param phi The Phi statistic. +#' @rdname convert_chisq +#' @param phi The \eqn{\phi} (phi) statistic. #' @export phi_to_chisq <- function(phi, n, ...) { n * (phi^2) diff --git a/man/chisq_to_phi.Rd b/man/convert_chisq.Rd similarity index 83% rename from man/chisq_to_phi.Rd rename to man/convert_chisq.Rd index ac5bfc666..1589c7b4f 100644 --- a/man/chisq_to_phi.Rd +++ b/man/convert_chisq.Rd @@ -7,7 +7,7 @@ \alias{chisq_to_fei} \alias{chisq_to_pearsons_c} \alias{phi_to_chisq} -\title{Conversion Chi-Squared to Phi or Cramer's V} +\title{Convert chi-square to correlation-like effect sizes (phi, V, Fei, C)} \usage{ chisq_to_phi( chisq, @@ -56,7 +56,7 @@ chisq_to_pearsons_c( phi_to_chisq(phi, n, ...) } \arguments{ -\item{chisq}{The Chi-squared statistic.} +\item{chisq}{The \eqn{\chi^2} (chi-square) statistic.} \item{n}{Total sample size.} @@ -76,30 +76,37 @@ is allowed (e.g., \code{"g"}, \code{"l"}, \code{"two"}...). See \emph{One-Sided \item{p}{Vector of expected values. See \code{\link[stats:chisq.test]{stats::chisq.test()}}.} -\item{phi}{The Phi statistic.} +\item{phi}{The \eqn{\phi} (phi) statistic.} } \value{ A data frame with the effect size(s), and confidence interval(s). See \code{\link[=cramers_v]{cramers_v()}}. } \description{ -Convert between Chi square (\eqn{\chi^2}), phi (\eqn{\phi}), Cramer's V, -Cohen's \emph{w}, Fei (\u05e4) and Pearson's \emph{C} for contingency tables or -goodness of fit. +Convert between \eqn{\chi^2} (chi-square), \eqn{\phi} (phi), Cramer's \eqn{V}, +Cohen's \eqn{w}, \ifelse{latex}{\eqn{Fei}}{פ (Fei)} and Pearson's \eqn{C} +for contingency tables or goodness of fit. } \details{ -These functions use the following formulae: -\cr -\deqn{\phi = w = \sqrt{\chi^2 / n}}{phi = w = sqrt(\chi^2 / n)} -\cr -\deqn{\text{Cramer's }V = \phi / \sqrt{min(nrow,ncol)-1}}{Cramer's V = \phi / sqrt(min(nrow,ncol)-1)} -\cr -\deqn{Fei = w / \sqrt{\frac{1}{min(p_E)}-1}}{Fei = w / sqrt(1/min(p_E) - 1))} -Where \code{p_E} are the expected probabilities. -\cr -\deqn{\text{Pearson's }C = \sqrt{\chi^2 / (\chi^2 + n)}}{Pearson's C = sqrt(\chi^2 / (\chi^2 + n))} -\cr\cr -For adjusted versions of \emph{phi} and \emph{V}, see Bergsma, 2013. +These functions use the following formulas: + +\deqn{\phi = w = \sqrt{\chi^2 / n}}{phi = w = sqrt(\frac{\chi^2}{n})} +\ifelse{latex}{ +\deqn{\textrm{Cramer's } V = \phi / \sqrt{\min(\textit{nrow}, \textit{ncol}) - 1}} +}{ +\deqn{\textrm{Cramer's } V = \phi / \sqrt{\min(\textit{nrow}, \textit{ncol }) - 1}}{Cramer's V = \phi / sqrt(min(nrow, ncol) - 1)} +} + +\ifelse{latex}{ +\deqn{\textit{Fei} = \phi / \sqrt{[1 / \min(p_E)] - 1}} +}{ +\deqn{פ = \phi / \sqrt{[1 / \min(p_E)] - 1}}{פ = w / sqrt(1 / min(p_E) - 1))} +} +Where \eqn{p_E} are the expected probabilities. + +\deqn{\textrm{Pearson's } C = \sqrt{\chi^2 / (\chi^2 + n)}}{Pearson's C = sqrt(\chi^2 / (\chi^2 + n))} + +For adjusted versions of \eqn{\phi} and \eqn{V}, see Bergsma, 2013. } \section{Confidence (Compatibility) Intervals (CIs)}{ From d1a25fdd02644b2b06f6c52219374610a4ca941d Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Mon, 12 Sep 2022 20:48:24 +0300 Subject: [PATCH 14/14] add missing Fei --- R/xtab.R | 17 +++++++++-------- man/phi.Rd | 17 +++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/R/xtab.R b/R/xtab.R index 6db7ca69f..3479846e3 100644 --- a/R/xtab.R +++ b/R/xtab.R @@ -1,8 +1,9 @@ #' Effect size for contingency tables #' -#' Compute Cramer's *V*, phi (\eqn{\phi}), Cohen's *w*, Fei (\eqn{XXX}), Pearson's -#' contingency coefficient, Odds ratios, Risk ratios, Cohen's *h* and Cohen's -#' *g* for contingency tables or goodness-of-fit. See details. +#' Compute Cramer's *V*, phi (\eqn{\phi}), Cohen's *w*, +#' \ifelse{latex}{\eqn{Fei}}{פ (Fei)}, Pearson's contingency coefficient, Odds +#' ratios, Risk ratios, Cohen's *h* and Cohen's *g* for contingency tables or +#' goodness-of-fit. See details. #' #' @inheritParams stats::chisq.test #' @param ci Confidence Interval (CI) level @@ -29,11 +30,11 @@ #' can also be used, but since it is not bounded at 1 (can be larger) its #' interpretation is more difficult. #' \cr \cr -#' For goodness-of-fit in 1D tables Cohen's *W*, Fei (\eqn{XXX}) or Pearson's *C* -#' can be used. Cohen's *w* has no upper bound (can be arbitrarily large, -#' depending on the expected distribution). Fei is an adjusted Cohen's *w*, -#' accounting for the expected distribution, making it bounded between 0-1. -#' Pearson's *C* is also bounded between 0-1. +#' For goodness-of-fit in 1D tables Cohen's *W*, \ifelse{latex}{\eqn{Fei}}{פ (Fei)} +#' or Pearson's *C* can be used. Cohen's *w* has no upper bound (can be +#' arbitrarily large, depending on the expected distribution). *Fei* is an +#' adjusted Cohen's *w*, accounting for the expected distribution, making it +#' bounded between 0-1. Pearson's *C* is also bounded between 0-1. #' \cr \cr #' To summarize, for correlation-like effect sizes, we recommend: #' diff --git a/man/phi.Rd b/man/phi.Rd index fbf47dafa..8e00c0bbb 100644 --- a/man/phi.Rd +++ b/man/phi.Rd @@ -83,9 +83,10 @@ the suffix \verb{_adjusted}), \code{Cohens_w}, \code{Fei}, \code{Odds_ratio}, \c (\code{CI_low} and \code{CI_high}). } \description{ -Compute Cramer's \emph{V}, phi (\eqn{\phi}), Cohen's \emph{w}, Fei (\eqn{XXX}), Pearson's -contingency coefficient, Odds ratios, Risk ratios, Cohen's \emph{h} and Cohen's -\emph{g} for contingency tables or goodness-of-fit. See details. +Compute Cramer's \emph{V}, phi (\eqn{\phi}), Cohen's \emph{w}, +\ifelse{latex}{\eqn{Fei}}{פ (Fei)}, Pearson's contingency coefficient, Odds +ratios, Risk ratios, Cohen's \emph{h} and Cohen's \emph{g} for contingency tables or +goodness-of-fit. See details. } \details{ \subsection{Correlation-like Effect Sizes}{ @@ -99,11 +100,11 @@ Pearson's \emph{C} should be used, as they are bounded between 0-1. Cohen's \emp can also be used, but since it is not bounded at 1 (can be larger) its interpretation is more difficult. \cr \cr -For goodness-of-fit in 1D tables Cohen's \emph{W}, Fei (\eqn{XXX}) or Pearson's \emph{C} -can be used. Cohen's \emph{w} has no upper bound (can be arbitrarily large, -depending on the expected distribution). Fei is an adjusted Cohen's \emph{w}, -accounting for the expected distribution, making it bounded between 0-1. -Pearson's \emph{C} is also bounded between 0-1. +For goodness-of-fit in 1D tables Cohen's \emph{W}, \ifelse{latex}{\eqn{Fei}}{פ (Fei)} +or Pearson's \emph{C} can be used. Cohen's \emph{w} has no upper bound (can be +arbitrarily large, depending on the expected distribution). \emph{Fei} is an +adjusted Cohen's \emph{w}, accounting for the expected distribution, making it +bounded between 0-1. Pearson's \emph{C} is also bounded between 0-1. \cr \cr To summarize, for correlation-like effect sizes, we recommend: \itemize{