From 361166aba1af43b1a4e9f5a0699819aef5b6253a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 08:35:28 +0300 Subject: [PATCH 01/30] Bump actions/checkout from 3 to 4 (#600) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/pkgdown-no-suggests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pkgdown-no-suggests.yaml b/.github/workflows/pkgdown-no-suggests.yaml index 25698b85b..37388c958 100644 --- a/.github/workflows/pkgdown-no-suggests.yaml +++ b/.github/workflows/pkgdown-no-suggests.yaml @@ -21,7 +21,7 @@ jobs: R_KEEP_PKG_SOURCE: yes steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Always try to use the latest pandoc version # https://github.com/jgm/pandoc/releases From 4c2c83c23f3c8804fd0e9212d6fe68aac43c3289 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Tue, 5 Sep 2023 08:44:52 +0300 Subject: [PATCH 02/30] close #529 --- vignettes/from_test_statistics.Rmd | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/vignettes/from_test_statistics.Rmd b/vignettes/from_test_statistics.Rmd index 64951f2a2..6b021a168 100644 --- a/vignettes/from_test_statistics.Rmd +++ b/vignettes/from_test_statistics.Rmd @@ -116,19 +116,19 @@ library(emmeans) joint_tests(aov_fit, by = "noise") F_to_eta2( - f = c(5, 79), + f = c(8, 51), df = 2, - df_error = 29 + df_error = 9 ) ``` We can also use `t_to_eta2()` for contrast analysis: ```{r, eval = .eval_if_requireNamespace("afex", "emmeans")} -pairs(emmeans(aov_fit, ~angle)) +pairs(emmeans(aov_fit, ~ angle)) t_to_eta2( - t = c(-6.2, -8.2, -3.3), + t = c(-6.2, -8.2, -3.2), df_error = 9 ) ``` @@ -142,7 +142,7 @@ fit_lmm <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy) anova(fit_lmm) -F_to_eta2(45.8, 1, 17) +F_to_eta2(45.9, 1, 17) ``` We can also use `t_to_eta2()` for the slope of `Days` (which in this case gives @@ -161,9 +161,9 @@ $\epsilon^2_p$ (Epsilon; sometimes called $\text{Adj. }\eta^2_p$, which is equivalent to $R^2_{adj}$; @albers2018power, @mordkoff2019simple). ```{r} -F_to_eta2(45.8, 1, 17) -F_to_epsilon2(45.8, 1, 17) -F_to_omega2(45.8, 1, 17) +F_to_eta2(45.9, 1, 17) +F_to_epsilon2(45.9, 1, 17) +F_to_omega2(45.9, 1, 17) ``` ## Measure of Association @@ -212,11 +212,11 @@ This measure is also sometimes used in contrast analysis, where it is called the point bi-serial correlation - $r_{pb}$ [@cohen1965some; @rosnow2000contrasts]: ```{r, eval = .eval_if_requireNamespace("afex", "emmeans")} -pairs(emmeans(aov_fit, ~angle)) +pairs(emmeans(aov_fit, ~ angle)) t_to_r( - t = c(-5.7, -8.9, -3.2), - df_error = 18 + t = c(-6.2, -8.2, -3.2), + df_error = 9 ) ``` @@ -254,11 +254,11 @@ eff_size(em_tension, sigma = sigma(m), edf = df.residual(m)) ### Within-Subject Contrasts ```{r, eval = .eval_if_requireNamespace("afex", "emmeans")} -pairs(emmeans(aov_fit, ~angle)) +pairs(emmeans(aov_fit, ~ angle)) t_to_d( - t = c(-5.7, -5.9, -3.2), - df_error = 18, + t = c(-6.2, -8.2, -3.3), + df_error = 9, paired = TRUE ) ``` From 6102cd792041e6e0f6c73a97d7d7b026482bb3f3 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" <35330040+mattansb@users.noreply.github.com> Date: Thu, 14 Sep 2023 14:28:55 +0300 Subject: [PATCH 03/30] fix devel 4.4.0 (#602) --- DESCRIPTION | 17 +++++++------- NEWS.md | 13 +++++++++++ R/cohens_d.R | 5 +++++ R/common_language.R | 20 +++++++++++------ R/eta_squared-methods.R | 7 +++++- R/means_ratio.R | 1 + R/pooled.R | 6 +++++ R/rank_diff.R | 31 ++++++++++++++++---------- R/utils_validate_input_data.R | 12 ++++++++-- inst/WORDLIST | 1 + man/rank_biserial.Rd | 24 ++++++++++++-------- tests/testthat/test-eta_squared.R | 1 + tests/testthat/test-rom.R | 17 ++++++++++++-- vignettes/standardized_differences.Rmd | 19 ++++++++++------ 14 files changed, 125 insertions(+), 49 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index cfb6b655a..e6745576f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: effectsize Title: Indices of Effect Size -Version: 0.8.5 +Version: 0.8.6 Authors@R: c(person(given = "Mattan S.", family = "Ben-Shachar", @@ -66,16 +66,16 @@ BugReports: https://github.com/easystats/effectsize/issues/ Depends: R (>= 3.6) Imports: - bayestestR (>= 0.13.0), - insight (>= 0.19.3.2), - parameters (>= 0.20.2), - performance (>= 0.10.2), - datawizard (>= 0.6.5), + bayestestR (>= 0.13.1), + insight (>= 0.19.5), + parameters (>= 0.21.1), + performance (>= 0.10.5), + datawizard (>= 0.8.0), stats, utils Suggests: - correlation (>= 0.8.3), - see (>= 0.7.4), + correlation (>= 0.8.4), + see (>= 0.8.0), afex, BayesFactor, boot, @@ -107,4 +107,3 @@ Config/Needs/website: rstudio/bslib, r-lib/pkgdown, easystats/easystatstemplate -Remotes: easystats/insight diff --git a/NEWS.md b/NEWS.md index 86f3331d3..ebb789db6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,16 @@ +# effectsize 0.8.6 + +This is a minor update to bring `effectsize` in-line with the formula methods +in `t.test()` and `wilcox.test()` in `R>=4.4.0`. + +## Breaking Changes + +- `cohens_d()`, `hedges_g()`, `p_superiority()`, `wmw_odds()`, `means_ratio()` and `rank_biserial()` no longer support setting `paired = TRUE` when using the formula method. + +## Bug fixes + +- `eta_squared()` returns (approximate) effect sizes for smooths. + # effectsize 0.8.5 ## New features diff --git a/R/cohens_d.R b/R/cohens_d.R index 1c35ed51a..5069f1440 100644 --- a/R/cohens_d.R +++ b/R/cohens_d.R @@ -206,6 +206,7 @@ glass_delta <- function(x, y = NULL, data = NULL, out <- .get_data_2_samples(x, y, data, paired = paired, verbose = verbose, ...) x <- out[["x"]] y <- out[["y"]] + paired <- out[["paired"]] if (is.null(y)) { if (type == "delta") { @@ -217,6 +218,10 @@ glass_delta <- function(x, y = NULL, data = NULL, # Compute index if (paired) { + if (type == "delta") { + insight::format_error("This effect size is only applicable for two independent samples.") + } + d <- mean(x - y) n <- length(x) s <- stats::sd(x - y) diff --git a/R/common_language.R b/R/common_language.R index d6b92e572..9b8ef22f2 100644 --- a/R/common_language.R +++ b/R/common_language.R @@ -123,6 +123,7 @@ p_superiority <- function(x, y = NULL, data = NULL, ) x <- data[["x"]] y <- data[["y"]] + paired <- data[["paired"]] if (parametric) { d <- cohens_d( @@ -162,14 +163,15 @@ cohens_u1 <- function(x, y = NULL, data = NULL, return(effectsize(x, type = "u1", ci = ci, verbose = verbose, ...)) } - data <- .get_data_2_samples(x, y, data, allow_ordered = !parametric, verbose = verbose, ... ) x <- data[["x"]] y <- data[["y"]] - if (is.null(y)) insight::format_error("cohens_u3 only applicable to two sample case.") + if (is.null(y) || isTRUE(match.call()$paired) || isTRUE(data[["paired"]])) { + insight::format_error("This effect size is only applicable for two independent samples.") + } if (!parametric) { insight::format_error("Cohen's U1 only available for parametric estimation.") @@ -202,14 +204,15 @@ cohens_u2 <- function(x, y = NULL, data = NULL, return(effectsize(x, type = "u2", ci = ci, verbose = verbose, ...)) } - data <- .get_data_2_samples(x, y, data, allow_ordered = !parametric, verbose = verbose, ... ) x <- data[["x"]] y <- data[["y"]] - if (is.null(y)) insight::format_error("cohens_u3 only applicable to two sample case.") + if (is.null(y) || isTRUE(match.call()$paired) || isTRUE(data[["paired"]])) { + insight::format_error("This effect size is only applicable for two independent samples.") + } if (parametric) { d <- cohens_d( @@ -253,7 +256,9 @@ cohens_u3 <- function(x, y = NULL, data = NULL, ) x <- data[["x"]] y <- data[["y"]] - if (is.null(y)) insight::format_error("cohens_u3 only applicable to two sample case.") + if (is.null(y) || isTRUE(match.call()$paired) || isTRUE(data[["paired"]])) { + insight::format_error("This effect size is only applicable for two independent samples.") + } if (parametric) { d <- cohens_d( @@ -289,14 +294,15 @@ p_overlap <- function(x, y = NULL, data = NULL, return(effectsize(x, type = "overlap", ci = ci, verbose = verbose, ...)) } - data <- .get_data_2_samples(x, y, data, allow_ordered = !parametric, verbose = verbose, ... ) x <- data[["x"]] y <- data[["y"]] - if (is.null(y)) insight::format_error("Overlap only applicable to two sample case.") + if (is.null(y) || isTRUE(match.call()$paired) || isTRUE(data[["paired"]])) { + insight::format_error("This effect size is only applicable for two independent samples.") + } if (parametric) { d <- cohens_d( diff --git a/R/eta_squared-methods.R b/R/eta_squared-methods.R index 2e1cf8568..bee08cacf 100644 --- a/R/eta_squared-methods.R +++ b/R/eta_squared-methods.R @@ -354,13 +354,16 @@ model <- stats::anova(model) p.table <- as.data.frame(model$pTerms.table) + p.table$Component <- "conditional" s.table <- as.data.frame(model$s.table) + s.table$Component <- "smooth_terms" + colnames(s.table)[colnames(s.table) == "Ref.df"] <- "df" s.table[setdiff(colnames(p.table), colnames(s.table))] <- NA p.table[setdiff(colnames(s.table), colnames(p.table))] <- NA tab <- rbind(p.table, s.table) - colnames(tab)[colnames(tab) == "F"] <- "F-value" colnames(tab)[colnames(tab) == "df"] <- "npar" tab$df_error <- model$residual.df + # tab$df_error <- Inf out <- .anova_es.anova( @@ -371,6 +374,8 @@ ci = ci, alternative = alternative, verbose = verbose ) + out$Component <- tab$Component + out <- datawizard::data_relocate(out, select = "Component", before = 1) attr(out, "anova_type") <- 3 attr(out, "approximate") <- TRUE diff --git a/R/means_ratio.R b/R/means_ratio.R index 639c490ec..fb883f234 100644 --- a/R/means_ratio.R +++ b/R/means_ratio.R @@ -76,6 +76,7 @@ means_ratio <- function(x, y = NULL, data = NULL, ) x <- out[["x"]] y <- out[["y"]] + paired <- out[["paired"]] if (is.null(y)) { insight::format_error("Only one sample provided. y or data must be provided.") diff --git a/R/pooled.R b/R/pooled.R index 391e1bfa3..44776477b 100644 --- a/R/pooled.R +++ b/R/pooled.R @@ -28,6 +28,9 @@ sd_pooled <- function(x, y = NULL, data = NULL, verbose = TRUE, ...) { data <- .get_data_2_samples(x, y, data, verbose = verbose, ...) x <- data[["x"]] y <- data[["y"]] + if (is.null(y) || isTRUE(match.call()$paired) || isTRUE(data[["paired"]])) { + insight::format_error("This effect size is only applicable for two independent samples.") + } V <- cov_pooled( data.frame(x = x), @@ -46,6 +49,9 @@ mad_pooled <- function(x, y = NULL, data = NULL, data <- .get_data_2_samples(x, y, data, verbose = verbose, ...) x <- data[["x"]] y <- data[["y"]] + if (is.null(y) || isTRUE(match.call()$paired) || isTRUE(data[["paired"]])) { + insight::format_error("This effect size is only applicable for two independent samples.") + } n1 <- length(x) n2 <- length(y) diff --git a/R/rank_diff.R b/R/rank_diff.R index a6ea009cd..e252656bf 100644 --- a/R/rank_diff.R +++ b/R/rank_diff.R @@ -62,6 +62,7 @@ #' # Same as: #' # rank_biserial("mpg", "am", data = mtcars) #' # rank_biserial(mtcars$mpg[mtcars$am=="0"], mtcars$mpg[mtcars$am=="1"]) +#' # cliffs_delta(mpg ~ am, data = mtcars) #' #' # More options: #' rank_biserial(mpg ~ am, data = mtcars, mu = -5) @@ -69,21 +70,26 @@ #' #' #' # One Sample ---------- -#' rank_biserial(wt ~ 1, data = mtcars, mu = 3) +#' # from help("wilcox.test") +#' 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) +#' depression <- data.frame(first = x, second = y, change = y - x) +#' +#' rank_biserial(change ~ 1, data = depression) +#' #' # same as: -#' # rank_biserial("wt", data = mtcars, mu = 3) -#' # rank_biserial(mtcars$wt, mu = 3) +#' # rank_biserial("change", data = depression) +#' # rank_biserial(mtcars$wt) +#' +#' # More options: +#' rank_biserial(change ~ 1, data = depression, mu = -0.5) #' #' #' # Paired Samples ---------- -#' dat <- data.frame( -#' Cond1 = c(1.83, 0.5, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.3), -#' Cond2 = c(0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29) -#' ) -#' (rb <- rank_biserial(Pair(Cond1, Cond2) ~ 1, data = dat, paired = TRUE)) +#' (rb <- rank_biserial(Pair(first, second) ~ 1, data = depression)) #' #' # same as: -#' # rank_biserial(dat$Cond1, dat$Cond2, paired = TRUE) +#' # rank_biserial(depression$first, depression$second, paired = TRUE) #' #' interpret_rank_biserial(0.78) #' interpret(rb, rules = "funder2019") @@ -127,8 +133,9 @@ rank_biserial <- function(x, y = NULL, data = NULL, allow_ordered = TRUE, verbose = verbose, ... ) - x <- out$x - y <- out$y + x <- out[["x"]] + y <- out[["y"]] + paired <- out[["paired"]] if (is.null(y)) { y <- 0 @@ -208,7 +215,7 @@ cliffs_delta <- function(x, y = NULL, data = NULL, ) x <- data$x y <- data$y - if (is.null(y) || isTRUE(eval.parent(cl$paired))) { + if (is.null(y) || isTRUE(match.call()$paired) || isTRUE(data[["paired"]])) { insight::format_error("This effect size is only applicable for two independent samples.") } diff --git a/R/utils_validate_input_data.R b/R/utils_validate_input_data.R index 786c3edcd..30c488b04 100644 --- a/R/utils_validate_input_data.R +++ b/R/utils_validate_input_data.R @@ -3,11 +3,18 @@ paired = FALSE, allow_ordered = FALSE, verbose = TRUE, ...) { if (inherits(x, "formula")) { + if (isTRUE(paired)) { + # This is to be consistent with R>=4.4.0 + insight::format_error("cannot use 'paired = TRUE' in formula method.") + } + # Validate: if (length(x) != 3L) { insight::format_error( "Formula must have one of the following forms:", - "\n\ty ~ group,\n\ty ~ 1,\n\tPair(x,y) ~ 1" + " y ~ group (independant samples)", + " y ~ 1 (one sample)", + " Pair(x,y) ~ 1 (paired samples)" ) } @@ -49,6 +56,7 @@ } else if (inherits(x, "Pair")) { x <- x[, 1] - x[, 2] y <- NULL + paired <- TRUE } @@ -90,7 +98,7 @@ } - list(x = x, y = y) + list(x = x, y = y, paired = paired) } diff --git a/inst/WORDLIST b/inst/WORDLIST index a7ad5f319..56e5a5894 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -83,6 +83,7 @@ Koo Kruschke LMM Labelled +labelled Lajeunesse Lakens Landis diff --git a/man/rank_biserial.Rd b/man/rank_biserial.Rd index bb84a12d3..68252c34e 100644 --- a/man/rank_biserial.Rd +++ b/man/rank_biserial.Rd @@ -131,6 +131,7 @@ mtcars$cyl <- factor(mtcars$cyl) # Same as: # rank_biserial("mpg", "am", data = mtcars) # rank_biserial(mtcars$mpg[mtcars$am=="0"], mtcars$mpg[mtcars$am=="1"]) +# cliffs_delta(mpg ~ am, data = mtcars) # More options: rank_biserial(mpg ~ am, data = mtcars, mu = -5) @@ -138,21 +139,26 @@ print(rb, append_CLES = TRUE) # One Sample ---------- -rank_biserial(wt ~ 1, data = mtcars, mu = 3) +# from help("wilcox.test") +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) +depression <- data.frame(first = x, second = y, change = y - x) + +rank_biserial(change ~ 1, data = depression) + # same as: -# rank_biserial("wt", data = mtcars, mu = 3) -# rank_biserial(mtcars$wt, mu = 3) +# rank_biserial("change", data = depression) +# rank_biserial(mtcars$wt) + +# More options: +rank_biserial(change ~ 1, data = depression, mu = -0.5) # Paired Samples ---------- -dat <- data.frame( - Cond1 = c(1.83, 0.5, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.3), - Cond2 = c(0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29) -) -(rb <- rank_biserial(Pair(Cond1, Cond2) ~ 1, data = dat, paired = TRUE)) +(rb <- rank_biserial(Pair(first, second) ~ 1, data = depression)) # same as: -# rank_biserial(dat$Cond1, dat$Cond2, paired = TRUE) +# rank_biserial(depression$first, depression$second, paired = TRUE) interpret_rank_biserial(0.78) interpret(rb, rules = "funder2019") diff --git a/tests/testthat/test-eta_squared.R b/tests/testthat/test-eta_squared.R index c48bc56e1..56a9f07f6 100644 --- a/tests/testthat/test-eta_squared.R +++ b/tests/testthat/test-eta_squared.R @@ -660,6 +660,7 @@ test_that("ets_squared | gam", { b <- mgcv::gam(y ~ x0 + s(x1) + s(x2) + t2(x1, x2) + s(x3), data = dat) expect_error(out <- eta_squared(b), regexp = NA) + expect_warning(eta_squared(b), regexp = NA) expect_output(print(out), "Type III") }) diff --git a/tests/testthat/test-rom.R b/tests/testthat/test-rom.R index b9741b392..1e3a52906 100644 --- a/tests/testthat/test-rom.R +++ b/tests/testthat/test-rom.R @@ -73,7 +73,14 @@ test_that("means_ratio paired - adjusted", { expect_error(means_ratio(extra ~ group, data = sleep), "negative") sleep$y <- sleep$extra + 4 - x <- means_ratio(y ~ group, + sleep_wide <- datawizard::data_to_wide(sleep, + id_cols = "ID", + values_from = "y", + names_from = "group", + names_prefix = "extra_" + ) + + x <- means_ratio(sleep_wide[["extra_1"]], sleep_wide[["extra_2"]], data = sleep, adjust = TRUE, paired = TRUE ) @@ -86,7 +93,13 @@ test_that("means_ratio paired - adjusted", { test_that("means_ratio paired - not adjusted", { data(sleep) sleep$y <- sleep$extra + 4 - x <- means_ratio(y ~ group, + sleep_wide <- datawizard::data_to_wide(sleep, + id_cols = "ID", + values_from = "y", + names_from = "group", + names_prefix = "extra_" + ) + x <- means_ratio(sleep_wide[["extra_1"]], sleep_wide[["extra_2"]], data = sleep, adjust = FALSE, paired = TRUE ) diff --git a/vignettes/standardized_differences.Rmd b/vignettes/standardized_differences.Rmd index c5c7eca5c..a1aa33e1d 100644 --- a/vignettes/standardized_differences.Rmd +++ b/vignettes/standardized_differences.Rmd @@ -108,11 +108,18 @@ hedges_g(mtcars$wt, mu = 2.7) For paired-samples, the difference is standardized by the variation in the differences. This effect size, known as Cohen's $d_z$, represents the difference in terms of its homogeneity (a small but stable difference will have a large $d_z$). ```{r} -t.test(extra ~ group, data = sleep, paired = TRUE) +sleep_wide <- datawizard::data_to_wide(sleep, + id_cols = "ID", + values_from = "extra", + names_from = "group", + names_prefix = "extra_" +) + +t.test(sleep_wide[["extra_1"]], sleep_wide[["extra_2"]], paired = TRUE) -cohens_d(extra ~ group, data = sleep, paired = TRUE) +cohens_d(sleep_wide[["extra_1"]], sleep_wide[["extra_2"]], paired = TRUE) -hedges_g(extra ~ group, data = sleep, paired = TRUE) +hedges_g(sleep_wide[["extra_1"]], sleep_wide[["extra_2"]], paired = TRUE) ``` ## For a Bayesian *t*-test @@ -297,13 +304,11 @@ p_superiority(mtcars$wt, mu = 2.75, parametric = FALSE) For paired samples, *probability of superiority* is the probability that, when sampling an observation at random, its *difference* will be larger than $\mu$. ```{r} -p_superiority(extra ~ group, - data = sleep, +p_superiority(sleep_wide[["extra_1"]], sleep_wide[["extra_2"]], paired = TRUE, mu = -1 ) -p_superiority(extra ~ group, - data = sleep, +p_superiority(sleep_wide[["extra_1"]], sleep_wide[["extra_2"]], paired = TRUE, mu = -1, parametric = FALSE ) From 79b8d10d80e1a762f81586ea6db2374e91f777d7 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Thu, 14 Sep 2023 14:31:00 +0300 Subject: [PATCH 04/30] close #603 --- .gitattributes | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..7bcb49abf --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +# Basic .gitattributes for a R repo. + +# Source files +# ============================= +*.Rdata binary +*.RData binary +*.rda binary +*.rdb binary +*.rds binary +*.Rd text +*.Rdx binary +*.Rmd text +*.R text eol=crlf +*.Rproj text +*.[Rr]md linguist-detectable + +# Documentation files +# ============================= +docs/* linguist-documentation +man/* linguist-documentation +misc/* linguist-documentation +pkgdown/* linguist-documentation +*.html linguist-documentation \ No newline at end of file From 7eff7bcf98b195fa0e5879fe4b6d7ee1df881c66 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Thu, 14 Sep 2023 13:35:13 +0200 Subject: [PATCH 05/30] add missing newline --- .gitattributes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 7bcb49abf..db9706737 100644 --- a/.gitattributes +++ b/.gitattributes @@ -20,4 +20,4 @@ docs/* linguist-documentation man/* linguist-documentation misc/* linguist-documentation pkgdown/* linguist-documentation -*.html linguist-documentation \ No newline at end of file +*.html linguist-documentation From 1c07bf52977c5cdffc4b1675feffd341f08fe5cd Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Thu, 14 Sep 2023 13:42:36 +0200 Subject: [PATCH 06/30] more specific gitattributes to effectsize --- .gitattributes | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index db9706737..1f5686ff3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9,15 +9,17 @@ *.rds binary *.Rd text *.Rdx binary -*.Rmd text +*.Rmd text *.R text eol=crlf *.Rproj text *.[Rr]md linguist-detectable +*.PS linguist-detectable # Documentation files # ============================= docs/* linguist-documentation man/* linguist-documentation misc/* linguist-documentation +papers/* linguist-documentation pkgdown/* linguist-documentation *.html linguist-documentation From 90e88e5f76c818f6240f012a5644cd03844d8a32 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Thu, 14 Sep 2023 13:50:48 +0200 Subject: [PATCH 07/30] fix styling workflow --- R/rank_diff.R | 2 +- man/rank_biserial.Rd | 2 +- vignettes/from_test_statistics.Rmd | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/R/rank_diff.R b/R/rank_diff.R index e252656bf..6ecc51dfd 100644 --- a/R/rank_diff.R +++ b/R/rank_diff.R @@ -71,7 +71,7 @@ #' #' # One Sample ---------- #' # from help("wilcox.test") -#' x <- c(1.83, 0.50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.30) +#' 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) #' depression <- data.frame(first = x, second = y, change = y - x) #' diff --git a/man/rank_biserial.Rd b/man/rank_biserial.Rd index 68252c34e..b5577eb4f 100644 --- a/man/rank_biserial.Rd +++ b/man/rank_biserial.Rd @@ -140,7 +140,7 @@ print(rb, append_CLES = TRUE) # One Sample ---------- # from help("wilcox.test") -x <- c(1.83, 0.50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.30) +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) depression <- data.frame(first = x, second = y, change = y - x) diff --git a/vignettes/from_test_statistics.Rmd b/vignettes/from_test_statistics.Rmd index 6b021a168..f58a6076c 100644 --- a/vignettes/from_test_statistics.Rmd +++ b/vignettes/from_test_statistics.Rmd @@ -125,7 +125,7 @@ F_to_eta2( We can also use `t_to_eta2()` for contrast analysis: ```{r, eval = .eval_if_requireNamespace("afex", "emmeans")} -pairs(emmeans(aov_fit, ~ angle)) +pairs(emmeans(aov_fit, ~angle)) t_to_eta2( t = c(-6.2, -8.2, -3.2), @@ -212,7 +212,7 @@ This measure is also sometimes used in contrast analysis, where it is called the point bi-serial correlation - $r_{pb}$ [@cohen1965some; @rosnow2000contrasts]: ```{r, eval = .eval_if_requireNamespace("afex", "emmeans")} -pairs(emmeans(aov_fit, ~ angle)) +pairs(emmeans(aov_fit, ~angle)) t_to_r( t = c(-6.2, -8.2, -3.2), @@ -254,7 +254,7 @@ eff_size(em_tension, sigma = sigma(m), edf = df.residual(m)) ### Within-Subject Contrasts ```{r, eval = .eval_if_requireNamespace("afex", "emmeans")} -pairs(emmeans(aov_fit, ~ angle)) +pairs(emmeans(aov_fit, ~angle)) t_to_d( t = c(-6.2, -8.2, -3.3), From 09e3209a08686d5f87c616fe6d9351ad8f015f65 Mon Sep 17 00:00:00 2001 From: Philip Waggoner <31326382+pdwaggoner@users.noreply.github.com> Date: Fri, 15 Sep 2023 08:43:13 -0600 Subject: [PATCH 08/30] Update WORDLIST (#606) --- inst/WORDLIST | 1 + 1 file changed, 1 insertion(+) diff --git a/inst/WORDLIST b/inst/WORDLIST index 56e5a5894..a02cc55d5 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -211,6 +211,7 @@ mis mixor modelling mrc +mtcars multicollinearity ncp ncps From 9a6bb14ca68a8364bdf12109c8f7071c13f2e19a Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Thu, 21 Sep 2023 01:23:07 +0530 Subject: [PATCH 09/30] Remove unnecessary import directives (#607) * Remove unnecessary import directives Discovered while thinking about https://github.com/easystats/easystats/issues/379 * fix strict workflow * clean up some lints --- NAMESPACE | 6 --- R/cohens_d.R | 2 +- R/convert_stat_chisq.R | 3 +- R/effectsize-package.R | 5 +- R/eta_squared-main.R | 5 -- R/eta_squared-methods.R | 5 +- R/xtab_diff.R | 2 +- man/convert_chisq.Rd | 3 +- man/effectsize-package.Rd | 5 +- tests/testthat/test-effectsize.R | 54 ++++++++++++++++++--- tests/testthat/test-eta_squared.R | 79 +++++++++++++++++++++---------- 11 files changed, 116 insertions(+), 53 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 969a9e4f7..358496b63 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -247,14 +247,8 @@ importFrom(bayestestR,equivalence_test) importFrom(datawizard,standardise) importFrom(datawizard,standardize) importFrom(insight,display) -importFrom(insight,find_predictors) importFrom(insight,print_html) importFrom(insight,print_md) -importFrom(parameters,model_parameters) importFrom(parameters,standardize_info) importFrom(parameters,standardize_parameters) importFrom(parameters,standardize_posteriors) -importFrom(stats,anova) -importFrom(stats,aov) -importFrom(stats,na.omit) -importFrom(utils,packageVersion) diff --git a/R/cohens_d.R b/R/cohens_d.R index 5069f1440..5956bf6a7 100644 --- a/R/cohens_d.R +++ b/R/cohens_d.R @@ -266,7 +266,7 @@ glass_delta <- function(x, y = NULL, data = NULL, } out <- data.frame(d = (d - mu) / s) - types <- c("d" = "Cohens_d", "g" = "Hedges_g", "delta" = "Glass_delta") + types <- c(d = "Cohens_d", g = "Hedges_g", delta = "Glass_delta") colnames(out) <- types[type] if (.test_ci(ci)) { diff --git a/R/convert_stat_chisq.R b/R/convert_stat_chisq.R index 6700528f2..fcf0d57a2 100644 --- a/R/convert_stat_chisq.R +++ b/R/convert_stat_chisq.R @@ -48,7 +48,8 @@ #' #' \deqn{\textrm{Pearson's } C = \sqrt{\chi^2 / (\chi^2 + n)}}{Pearson's C = sqrt(\chi^2 / (\chi^2 + n))} #' -#' For versions adjusted for small-sample bias of \eqn{\phi}, \eqn{V}, and \eqn{T}, see [Bergsma, 2013](https://en.wikipedia.org/wiki/Cram%C3%A9r%27s_V#Bias_correction). +#' For versions adjusted for small-sample bias of \eqn{\phi}, \eqn{V}, and \eqn{T}, +#' see [Bergsma, 2013](https://en.wikipedia.org/wiki/Cram%C3%A9r%27s_V#Bias_correction). #' #' @inheritSection effectsize_CIs Confidence (Compatibility) Intervals (CIs) #' @inheritSection effectsize_CIs CIs and Significance Tests diff --git a/R/effectsize-package.R b/R/effectsize-package.R index ba31a5cd3..d4351affd 100644 --- a/R/effectsize-package.R +++ b/R/effectsize-package.R @@ -18,8 +18,9 @@ #' and hypothesis tests, such as [cohens_d()], [phi()], [eta_squared()], and #' many more. #' -#' See [`vignette("effectsize", package = "effectsize")`](https://easystats.github.io/effectsize/articles/effectsize.html) for more details, -#' or [`vignette(package = "effectsize")`](https://easystats.github.io/effectsize/articles/) for a full list of vignettes. +#' See [`vignette("effectsize", package = "effectsize")`](https://easystats.github.io/effectsize/articles/effectsize.html) +#' for more details, or [`vignette(package = "effectsize")`](https://easystats.github.io/effectsize/articles/) +#' for a full list of vignettes. #' #' References: Ben-Shachar et al. (2020) \doi{10.21105/joss.02815}. #' diff --git a/R/eta_squared-main.R b/R/eta_squared-main.R index ff464089e..1f5d24475 100644 --- a/R/eta_squared-main.R +++ b/R/eta_squared-main.R @@ -764,7 +764,6 @@ cohens_f_squared <- function(model, #' @keywords internal -#' @importFrom stats anova .anova_es.default <- function(model, ...) { .anova_es.anova(stats::anova(model), ...) } @@ -842,8 +841,6 @@ cohens_f_squared <- function(model, } #' @keywords internal -#' @importFrom parameters model_parameters -#' @importFrom stats anova .anova_es.aov <- function(model, type = c("eta", "omega", "epsilon"), partial = TRUE, @@ -885,8 +882,6 @@ cohens_f_squared <- function(model, .anova_es.glm <- .anova_es.lm #' @keywords internal -#' @importFrom parameters model_parameters -#' @importFrom insight find_predictors .anova_es.aovlist <- function(model, type = c("eta", "omega", "epsilon"), partial = TRUE, diff --git a/R/eta_squared-methods.R b/R/eta_squared-methods.R index bee08cacf..9368f4f62 100644 --- a/R/eta_squared-methods.R +++ b/R/eta_squared-methods.R @@ -110,7 +110,7 @@ within <- names(model$idata) within <- lapply(within, function(x) c(NA, x)) within <- do.call(expand.grid, within) - within <- apply(within, 1, na.omit) + within <- apply(within, 1, stats::na.omit) ns <- sapply(within, length) within <- sapply(within, paste, collapse = ":") within <- within[order(ns)] @@ -179,7 +179,6 @@ #' @keywords internal .anova_es.anova.lme <- .anova_es.anova -#' @importFrom stats na.omit #' @keywords internal .anova_es.parameters_model <- function(model, type = c("eta", "omega", "epsilon"), @@ -249,8 +248,6 @@ # Specific models --------------------------------------------------------- #' @keywords internal -#' @importFrom stats aov -#' @importFrom utils packageVersion .anova_es.maov <- function(model, type = c("eta", "omega", "epsilon"), partial = TRUE, diff --git a/R/xtab_diff.R b/R/xtab_diff.R index 3ce053319..a80f64553 100644 --- a/R/xtab_diff.R +++ b/R/xtab_diff.R @@ -295,7 +295,7 @@ arr <- function(x, y = NULL, ci = 0.95, alternative = "two.sided", ...) { nnt <- function(x, y = NULL, ci = 0.95, alternative = "two.sided", ...) { alternative <- .match.alt(alternative) - flip_alt <- c("less" = "greater", "greater" = "less", "two.sided" = "two.sided") + flip_alt <- c(less = "greater", greater = "less", two.sided = "two.sided") alternative2 <- unname(flip_alt[alternative]) if (.is_htest_of_type(x, "Pearson's Chi-squared", "Chi-squared-test")) { diff --git a/man/convert_chisq.Rd b/man/convert_chisq.Rd index 694eedb68..68da11c29 100644 --- a/man/convert_chisq.Rd +++ b/man/convert_chisq.Rd @@ -127,7 +127,8 @@ 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 versions adjusted for small-sample bias of \eqn{\phi}, \eqn{V}, and \eqn{T}, see \href{https://en.wikipedia.org/wiki/Cram\%C3\%A9r\%27s_V#Bias_correction}{Bergsma, 2013}. +For versions adjusted for small-sample bias of \eqn{\phi}, \eqn{V}, and \eqn{T}, +see \href{https://en.wikipedia.org/wiki/Cram\%C3\%A9r\%27s_V#Bias_correction}{Bergsma, 2013}. } \section{Confidence (Compatibility) Intervals (CIs)}{ Unless stated otherwise, confidence (compatibility) intervals (CIs) are diff --git a/man/effectsize-package.Rd b/man/effectsize-package.Rd index 6098ac39b..30c9a4414 100644 --- a/man/effectsize-package.Rd +++ b/man/effectsize-package.Rd @@ -20,8 +20,9 @@ and their confidence intervals (CIs), from a variety of statistical models and hypothesis tests, such as \code{\link[=cohens_d]{cohens_d()}}, \code{\link[=phi]{phi()}}, \code{\link[=eta_squared]{eta_squared()}}, and many more. -See \href{https://easystats.github.io/effectsize/articles/effectsize.html}{\code{vignette("effectsize", package = "effectsize")}} for more details, -or \href{https://easystats.github.io/effectsize/articles/}{\code{vignette(package = "effectsize")}} for a full list of vignettes. +See \href{https://easystats.github.io/effectsize/articles/effectsize.html}{\code{vignette("effectsize", package = "effectsize")}} +for more details, or \href{https://easystats.github.io/effectsize/articles/}{\code{vignette(package = "effectsize")}} +for a full list of vignettes. References: Ben-Shachar et al. (2020) \doi{10.21105/joss.02815}. } diff --git a/tests/testthat/test-effectsize.R b/tests/testthat/test-effectsize.R index 552080599..32b7d160b 100644 --- a/tests/testthat/test-effectsize.R +++ b/tests/testthat/test-effectsize.R @@ -252,14 +252,56 @@ test_that("htest | rank", { }) test_that("htest | Get args from htest", { - tt <- t.test(mtcars$hp, mtcars$mpg, alternative = "l", mu = -3, conf.level = 0.8, var.equal = TRUE) - expect_equal(cohens_d(tt), cohens_d(mtcars$hp, mtcars$mpg, alternative = "l", mu = -3, ci = 0.8), ignore_attr = TRUE) + tt <- t.test( + mtcars$hp, + mtcars$mpg, + alternative = "l", + mu = -3, + conf.level = 0.8, + var.equal = TRUE + ) + expect_equal( + cohens_d(tt), + cohens_d( + mtcars$hp, + mtcars$mpg, + alternative = "l", + mu = -3, + ci = 0.8 + ), + ignore_attr = TRUE + ) - suppressWarnings(ww1 <- wilcox.test(mtcars$hp, mtcars$mpg, alternative = "l", mu = -3)) - expect_equal(rank_biserial(ww1), rank_biserial(mtcars$hp, mtcars$mpg, alternative = "l", mu = -3), ignore_attr = TRUE) + suppressWarnings({ + ww1 <- wilcox.test(mtcars$hp, mtcars$mpg, alternative = "l", mu = -3) + }) + expect_equal( + rank_biserial(ww1), + rank_biserial(mtcars$hp, mtcars$mpg, alternative = "l", mu = -3), + ignore_attr = TRUE + ) - suppressWarnings(ww2 <- wilcox.test(mtcars$hp, mtcars$mpg, alternative = "l", mu = -3, conf.int = TRUE, conf.level = 0.8)) - expect_equal(rank_biserial(ww2), rank_biserial(mtcars$hp, mtcars$mpg, alternative = "l", mu = -3, ci = 0.8), ignore_attr = TRUE) + suppressWarnings({ + ww2 <- wilcox.test( + mtcars$hp, + mtcars$mpg, + alternative = "l", + mu = -3, + conf.int = TRUE, + conf.level = 0.8 + ) + }) + expect_equal( + rank_biserial(ww2), + rank_biserial( + mtcars$hp, + mtcars$mpg, + alternative = "l", + mu = -3, + ci = 0.8 + ), + ignore_attr = TRUE + ) }) diff --git a/tests/testthat/test-eta_squared.R b/tests/testthat/test-eta_squared.R index 56a9f07f6..fbf897696 100644 --- a/tests/testthat/test-eta_squared.R +++ b/tests/testthat/test-eta_squared.R @@ -516,19 +516,47 @@ test_that("afex | mixed()", { # Intercept data("stroop", package = "afex") stroop <- subset(stroop, study == 1 & acc == 1 & trialnum < 20) - suppressMessages(m1 <- afex::mixed(rt ~ condition + (condition | pno), data = stroop, method = "KR")) - suppressMessages(m2 <- afex::mixed(rt ~ condition + (condition | pno), data = stroop, test_intercept = TRUE, method = "KR")) + suppressMessages({ + m1 <- afex::mixed(rt ~ condition + (condition | pno), data = stroop, method = "KR") + }) + suppressMessages({ + m2 <- afex::mixed(rt ~ condition + (condition | pno), + data = stroop, + test_intercept = TRUE, + method = "KR" + ) + }) - expect_warning(a1a <- eta_squared(m1, include_intercept = TRUE), regexp = "Intercept") - expect_warning(a1b <- eta_squared(m1, include_intercept = FALSE), regexp = NA) + expect_warning( + { + a1a <- eta_squared(m1, include_intercept = TRUE) + }, + regexp = "Intercept" + ) + expect_warning( + { + a1b <- eta_squared(m1, include_intercept = FALSE) + }, + regexp = NA + ) expect_equal(a1a, a1b) expect_equal(nrow(a1a), 1L) - expect_warning(a2a <- eta_squared(m2, include_intercept = TRUE), regexp = NA) - expect_warning(a2b <- eta_squared(m2, include_intercept = FALSE), regexp = NA) + expect_warning( + { + a2a <- eta_squared(m2, include_intercept = TRUE) + }, + regexp = NA + ) + expect_warning( + { + a2b <- eta_squared(m2, include_intercept = FALSE) + }, + regexp = NA + ) expect_equal(nrow(a2a), 2L) expect_equal(nrow(a2b), 1L) - expect_equal(a1a, a2a[2, ], ignore_attr = TRUE) + expect_equal(a1a, a2a[2L, ], ignore_attr = TRUE) }) @@ -546,17 +574,18 @@ test_that("car MVM", { id = 1:8 ) - ds_long <- - datawizard::reshape_longer(ds, - select = 1:4, - names_to = "ind_var", - values_to = "score" - ) + ds_long <- datawizard::reshape_longer(ds, + select = 1:4, + names_to = "ind_var", + values_to = "score" + ) fit <- lm(cbind(I, II, III, IV) ~ 1, data = ds) - in_rep <- data.frame(ind_var = gl(4, 1)) - suppressMessages(A_car <- car::Anova(fit, idata = in_rep, idesign = ~ind_var)) + in_rep <- data.frame(ind_var = gl(4L, 1L)) + suppressMessages({ + A_car <- car::Anova(fit, idata = in_rep, idesign = ~ind_var) + }) eta_car <- effectsize::eta_squared(A_car, ci = NULL)[[2]] @@ -570,11 +599,13 @@ test_that("car MVM", { # Complex --- data(obk.long, package = "afex") - suppressMessages(mod <- afex::aov_ez("id", "value", obk.long, - between = c("treatment", "gender"), - within = c("phase", "hour"), - observed = "gender" - )) + suppressMessages({ + mod <- afex::aov_ez("id", "value", obk.long, + between = c("treatment", "gender"), + within = c("phase", "hour"), + observed = "gender" + ) + }) expect_equal( sort(eta_squared(mod$Anova, generalized = "gender")[[2]]), sort(mod$anova_table$ges) @@ -592,7 +623,7 @@ test_that("Anova.mlm Manova", { mod <- lm(cbind(mpg, qsec, disp) ~ am_f * cyl_f, data = mtcars) - Manova <- car::Manova(mod, type = 2) + Manova <- car::Manova(mod, type = 2L) expect_true(is.null(summary(Manova, univariate = TRUE)[["univariate.tests"]])) expect_error(eta_squared(Manova), regexp = NA) @@ -622,8 +653,8 @@ test_that("merMod and lmerModLmerTest", { data("sleepstudy", package = "lme4") - m <- lme4::lmer(Reaction ~ Days + (Days | Subject), sleepstudy) - mtest <- lmerTest::lmer(Reaction ~ Days + (Days | Subject), sleepstudy) + m <- lme4::lmer(Reaction ~ Days + (Days | Subject), data = sleepstudy) + mtest <- lmerTest::lmer(Reaction ~ Days + (Days | Subject), data = sleepstudy) expect_equal( eta_squared(m), @@ -676,7 +707,7 @@ test_that("ets_squared | rms", { skip_if_not_installed("car") skip_if_not_installed("base", minimum_version = "3.6.1") - b_lm <- car::Anova(lm(mpg ~ cyl + am, data = mtcars), type = 2) + b_lm <- car::Anova(lm(mpg ~ cyl + am, data = mtcars), type = 2L) out_lm <- eta_squared(b_lm) expect_equal(out[1:2, ], out_lm, ignore_attr = TRUE) }) From ad341f7ab42cd0b1e58839d6d958898cc65d2ef4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Th=C3=A9riault?= <13123390+rempsyc@users.noreply.github.com> Date: Sun, 24 Sep 2023 10:59:43 -0400 Subject: [PATCH 10/30] Add interpretation for fei effect size --- DESCRIPTION | 2 +- NAMESPACE | 1 + NEWS.md | 6 ++++++ R/interpret.R | 2 +- R/interpret_r.R | 4 ++++ man/effectsize.Rd | 2 +- man/interpret_r.Rd | 3 +++ 7 files changed, 17 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e6745576f..4c966ee72 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: effectsize Title: Indices of Effect Size -Version: 0.8.6 +Version: 0.8.6.1 Authors@R: c(person(given = "Mattan S.", family = "Ben-Shachar", diff --git a/NAMESPACE b/NAMESPACE index 358496b63..5c5977eb4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -139,6 +139,7 @@ export(interpret_direction) export(interpret_epsilon_squared) export(interpret_ess) export(interpret_eta_squared) +export(interpret_fei) export(interpret_g) export(interpret_gfi) export(interpret_glass_delta) diff --git a/NEWS.md b/NEWS.md index ebb789db6..c953d6d2b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# effectsize 0.8.7 + +## New features + +- New function: `interpret_fei()` + # effectsize 0.8.6 This is a minor update to bring `effectsize` in-line with the formula methods diff --git a/R/interpret.R b/R/interpret.R index b3ee48f7e..6d85e6e45 100644 --- a/R/interpret.R +++ b/R/interpret.R @@ -178,7 +178,7 @@ interpret.effectsize_table <- function(x, rules, ...) { Cohens_w = , Tschuprows_t = , Tschuprows_t_adjusted = , - fei = interpret_cramers_v(value, rules = rules), + Fei = interpret_fei(value, rules = rules), ## xtab 2x2 Cohens_h = interpret_cohens_d(value, rules = rules), diff --git a/R/interpret_r.R b/R/interpret_r.R index 5565cbb02..c461fd7e7 100644 --- a/R/interpret_r.R +++ b/R/interpret_r.R @@ -109,3 +109,7 @@ interpret_cramers_v <- interpret_r #' @export #' @rdname interpret_r interpret_rank_biserial <- interpret_r + +#' @export +#' @rdname interpret_r +interpret_fei <- interpret_r diff --git a/man/effectsize.Rd b/man/effectsize.Rd index f1b55ddfb..7770ab81b 100644 --- a/man/effectsize.Rd +++ b/man/effectsize.Rd @@ -22,7 +22,7 @@ effectsize(model, ...) \item{type}{The effect size of interest. See details.} \item{ci}{Value or vector of probability of the CI (between 0 and 1) -to be estimated. Default to \code{0.95} (\verb{95\%}).} +to be estimated. Default to \code{.95} (\verb{95\%}).} \item{test}{The indices of effect existence to compute. Character (vector) or list with one or more of these options: \code{"p_direction"} (or \code{"pd"}), diff --git a/man/interpret_r.Rd b/man/interpret_r.Rd index b69290160..c8ea33801 100644 --- a/man/interpret_r.Rd +++ b/man/interpret_r.Rd @@ -5,6 +5,7 @@ \alias{interpret_phi} \alias{interpret_cramers_v} \alias{interpret_rank_biserial} +\alias{interpret_fei} \title{Interpret Correlation Coefficient} \usage{ interpret_r(r, rules = "funder2019", ...) @@ -14,6 +15,8 @@ interpret_phi(r, rules = "funder2019", ...) interpret_cramers_v(r, rules = "funder2019", ...) interpret_rank_biserial(r, rules = "funder2019", ...) + +interpret_fei(r, rules = "funder2019", ...) } \arguments{ \item{r}{Value or vector of correlation coefficient.} From 24910d57791d45d117791fc6eb71a5e7ca5bd6ae Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Wed, 27 Sep 2023 16:54:38 +0200 Subject: [PATCH 11/30] Create update-to-latest-easystats.yaml --- .github/workflows/update-to-latest-easystats.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/workflows/update-to-latest-easystats.yaml diff --git a/.github/workflows/update-to-latest-easystats.yaml b/.github/workflows/update-to-latest-easystats.yaml new file mode 100644 index 000000000..7718d763a --- /dev/null +++ b/.github/workflows/update-to-latest-easystats.yaml @@ -0,0 +1,10 @@ +on: + schedule: + # Check for dependency updates once a month + - cron: "0 0 1 * *" + +name: update-to-latest-easystats + +jobs: + update-to-latest-easystats: + uses: easystats/workflows/.github/workflows/update-to-latest-easystats.yaml@main From 14e388dc5c4e7243f8acd2ad14da8da9d09f9b74 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Thu, 28 Sep 2023 13:09:37 +0200 Subject: [PATCH 12/30] Update html-5-check.yaml --- .github/workflows/html-5-check.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/html-5-check.yaml b/.github/workflows/html-5-check.yaml index 1439a3228..f25b4eeaf 100644 --- a/.github/workflows/html-5-check.yaml +++ b/.github/workflows/html-5-check.yaml @@ -6,8 +6,8 @@ on: pull_request: branches: [main, master] -name: HTML5 check +name: html-5-check jobs: - HTML5-check: + html-5-check: uses: easystats/workflows/.github/workflows/html-5-check.yaml@main From dabde3f359a3b88dfa7f450541f4af40ea28a8a5 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Thu, 5 Oct 2023 21:12:29 +0200 Subject: [PATCH 13/30] avoid loaded term [skip ci] --- R/interpret.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/interpret.R b/R/interpret.R index 6d85e6e45..9afb4cbed 100644 --- a/R/interpret.R +++ b/R/interpret.R @@ -36,7 +36,7 @@ rules <- function(values, labels = NULL, name = NULL, right = TRUE) { } } - # Sanity checks + # validation checks if (length(labels) < length(values)) { insight::format_error("There cannot be less labels than reference values!") } else if (length(labels) > length(values) + 1) { From bf6cb28ac2dd8da2e30d5150e0ab8fe130138613 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Tue, 24 Oct 2023 12:29:42 +0300 Subject: [PATCH 14/30] MIT LICENSE https://github.com/easystats/easystats/issues/368 --- DESCRIPTION | 2 +- LICENSE | 695 ++-------------------------------------------------- NEWS.md | 4 + 3 files changed, 26 insertions(+), 675 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4c966ee72..95cb6cf05 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -60,7 +60,7 @@ Description: Provide utilities to work with indices of effect size for a wide the function 'insight::supported_models()'), allowing computation of and conversion between indices such as Cohen's d, r, odds, etc. References: Ben-Shachar et al. (2020) . -License: GPL-3 +License: MIT + file LICENSE URL: https://easystats.github.io/effectsize/ BugReports: https://github.com/easystats/effectsize/issues/ Depends: diff --git a/LICENSE b/LICENSE index f288702d2..ea50e7887 100644 --- a/LICENSE +++ b/LICENSE @@ -1,674 +1,21 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. +# MIT License + +Copyright (c) 2023 easystats team + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/NEWS.md b/NEWS.md index c953d6d2b..1d3532561 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# effectsize 0.8.7.xxx + +- This release changes the licensing model of `{effectsize}` to an MIT license. + # effectsize 0.8.7 ## New features From 18978e8a7751782de08c0d9f877d44b9ba99769d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 4 Nov 2023 13:01:50 +0530 Subject: [PATCH 15/30] [create-pull-request] automated change (#614) Co-authored-by: IndrajeetPatil --- DESCRIPTION | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 95cb6cf05..54e95fb29 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -67,10 +67,10 @@ Depends: R (>= 3.6) Imports: bayestestR (>= 0.13.1), - insight (>= 0.19.5), - parameters (>= 0.21.1), - performance (>= 0.10.5), - datawizard (>= 0.8.0), + insight (>= 0.19.6), + parameters (>= 0.21.2), + performance (>= 0.10.8), + datawizard (>= 0.9.0), stats, utils Suggests: From 448e39bdbb66b24fe1f83922fb1c9696951c51db Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sat, 4 Nov 2023 08:40:26 +0100 Subject: [PATCH 16/30] fix warning about licence --- .Rbuildignore | 4 ++-- DESCRIPTION | 2 +- LICENSE | 23 ++--------------------- LICENSE.md | 21 +++++++++++++++++++++ README.md | 44 +++++++++++++++++++++++--------------------- man/effectsize.Rd | 4 ++-- 6 files changed, 51 insertions(+), 47 deletions(-) create mode 100644 LICENSE.md diff --git a/.Rbuildignore b/.Rbuildignore index 5aaffd82b..f809dcf3c 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -28,7 +28,6 @@ publication/* ^\.httr-oauth$ ^CRAN-RELEASE$ tests\^spelling -^LICENSE ^\.lintr$ ^\.circleci$ ^tests/manual$ @@ -52,4 +51,5 @@ hextools \.code-workspace$ # Flip these two to no build vignettes: # ^vignettes/(?!additional).* -^vignettes/additional \ No newline at end of file +^vignettes/additional +^LICENSE\.md$ diff --git a/DESCRIPTION b/DESCRIPTION index 54e95fb29..5c10ce472 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: effectsize Title: Indices of Effect Size -Version: 0.8.6.1 +Version: 0.8.6.2 Authors@R: c(person(given = "Mattan S.", family = "Ben-Shachar", diff --git a/LICENSE b/LICENSE index ea50e7887..f3dcba36a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,2 @@ -# MIT License - -Copyright (c) 2023 easystats team - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +YEAR: 2023 +COPYRIGHT HOLDER: effectsize authors diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 000000000..b5aac20e0 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +# MIT License + +Copyright (c) 2023 effectsize authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index b4ff4a0c8..d610f50ce 100644 --- a/README.md +++ b/README.md @@ -54,22 +54,24 @@ Click on the buttons above to access the package [**easystats blog**](https://easystats.github.io/blog/posts/), and check-out these vignettes: -- **Effect Sizes** - - [**Standardized - Differences**](https://easystats.github.io/effectsize/articles/standardized_differences.html) - - [**For Contingency - Tables**](https://easystats.github.io/effectsize/articles/xtabs.html) - - [**ANOVA Effect - Sizes**](https://easystats.github.io/effectsize/articles/anovaES.html) -- **Effect Sizes Conversion** - - [**Between Effect - Sizes**](https://easystats.github.io/effectsize/articles/convert_r_d_OR.html) - - [**Between Probabilities and Odds and Risk - Ratios**](https://easystats.github.io/effectsize/articles/convert_p_OR_RR.html) - - [**Effect Size from Test - Statistics**](https://easystats.github.io/effectsize/articles/from_test_statistics.html) -- [**Automated Interpretation of Indices of Effect - Size**](https://easystats.github.io/effectsize/articles/interpret.html) +- **Effect Sizes** + - [**Standardized + Differences**](https://easystats.github.io/effectsize/articles/standardized_differences.html) + - [**For Contingency + Tables**](https://easystats.github.io/effectsize/articles/xtabs.html) + - [**ANOVA Effect + Sizes**](https://easystats.github.io/effectsize/articles/anovaES.html) +- **Effect Sizes Conversion** + - [**Between Effect + Sizes**](https://easystats.github.io/effectsize/articles/convert_r_d_OR.html) + - [**Between Probabilities and Odds and Risk + Ratios**](https://easystats.github.io/effectsize/articles/convert_p_OR_RR.html) + - [**Effect Size from Test + Statistics**](https://easystats.github.io/effectsize/articles/from_test_statistics.html) +- [**Plotting Functions for the ‘effectsize’ + Package**](https://easystats.github.io/see/articles/effectsize.html) +- [**Automated Interpretation of Indices of Effect + Size**](https://easystats.github.io/effectsize/articles/interpret.html) # Features @@ -122,7 +124,7 @@ language effect sizes* and more… ### Contingency Tables ``` r -# Dependence +# Dependence phi(mtcars$am, mtcars$vs) ## ϕ (adj.) | 95% CI ## ----------------------- @@ -143,7 +145,7 @@ fei(table(mtcars$cyl), p = c(0.1, 0.3, 0.6)) ## ------------------- ## 0.27 | [0.17, 1.00] ## -## - Adjusted for non-uniform expected probabilities. +## - Adjusted for uniform expected probabilities. ## - One-sided CIs: upper bound fixed at [1.00]. ``` @@ -256,9 +258,9 @@ interpret_cohens_d(d = 0.45, rules = "gignac2016") In order to cite this package, please use the following citation: -- Ben-Shachar M, Lüdecke D, Makowski D (2020). effectsize: Estimation - of Effect Size Indices and Standardized Parameters. *Journal of Open - Source Software*, *5*(56), 2815. doi: 10.21105/joss.02815 +- Ben-Shachar M, Lüdecke D, Makowski D (2020). effectsize: Estimation of + Effect Size Indices and Standardized Parameters. *Journal of Open + Source Software*, *5*(56), 2815. doi: 10.21105/joss.02815 Corresponding BibTeX entry: diff --git a/man/effectsize.Rd b/man/effectsize.Rd index 7770ab81b..5d931c82e 100644 --- a/man/effectsize.Rd +++ b/man/effectsize.Rd @@ -22,7 +22,7 @@ effectsize(model, ...) \item{type}{The effect size of interest. See details.} \item{ci}{Value or vector of probability of the CI (between 0 and 1) -to be estimated. Default to \code{.95} (\verb{95\%}).} +to be estimated. Default to \code{0.95} (\verb{95\%}).} \item{test}{The indices of effect existence to compute. Character (vector) or list with one or more of these options: \code{"p_direction"} (or \code{"pd"}), @@ -32,7 +32,7 @@ For each "test", the corresponding \pkg{bayestestR} function is called (e.g. \code{\link[bayestestR:rope]{rope()}} or \code{\link[bayestestR:p_direction]{p_direction()}}) and its results included in the summary output.} -\item{verbose}{Toggle warnings and messages on or off.} +\item{verbose}{Toggle off warnings.} \item{...}{Arguments passed to or from other methods. See details.} } From b0caa91f2662ce7b9d8768ab5ae537047889043b Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" <35330040+mattansb@users.noreply.github.com> Date: Tue, 7 Nov 2023 09:20:59 +0200 Subject: [PATCH 17/30] New `repeated_measures_d()` (#618) This PR introduces the new `repeated_measures_d()` function (#372). --- NAMESPACE | 2 + NEWS.md | 5 + R/cohens_d.R | 23 +- R/common_language.R | 7 + R/datasets.R | 30 + R/effectsize.R | 8 + R/effectsize.htest.R | 9 +- R/mahalanobis_D.R | 1 - R/print.effectsize_table.R | 3 +- R/rank_diff.R | 1 + R/repeated_measures_d.R | 306 +++ R/sysdata.rda | Bin 1234 -> 1342 bytes R/utils_ci.R | 2 + R/utils_validate_input_data.R | 85 +- README.Rmd | 2 +- WIP/paired_d examples.R | 75 - WIP/paired_d2.R | 202 -- _pkgdown.yml | 2 + data-raw/df data.R | 12 + data-raw/effectSizePuzzler.txt | 2501 ++++++++++++++++++++++++ data-raw/es_info.R | 5 + data/rouder2016.rdata | Bin 0 -> 6442 bytes man/Music_preferences.Rd | 1 + man/Music_preferences2.Rd | 1 + man/RCT_table.Rd | 1 + man/Smoking_FASD.Rd | 1 + man/cohens_d.Rd | 13 +- man/effectsize.Rd | 10 + man/food_class.Rd | 1 + man/hardlyworking.Rd | 1 + man/mahalanobis_d.Rd | 3 +- man/means_ratio.Rd | 3 +- man/p_superiority.Rd | 3 +- man/rank_biserial.Rd | 3 +- man/repeated_measures_d.Rd | 241 +++ man/rouder2016.Rd | 43 + man/screening_test.Rd | 3 +- tests/testthat/test-effectsize.R | 21 +- tests/testthat/test-rm_d.R | 126 ++ vignettes/standardized_differences.Rmd | 34 +- 40 files changed, 3484 insertions(+), 306 deletions(-) create mode 100644 R/repeated_measures_d.R delete mode 100644 WIP/paired_d examples.R delete mode 100644 WIP/paired_d2.R create mode 100644 data-raw/effectSizePuzzler.txt create mode 100644 data/rouder2016.rdata create mode 100644 man/repeated_measures_d.Rd create mode 100644 man/rouder2016.Rd create mode 100644 tests/testthat/test-rm_d.R diff --git a/NAMESPACE b/NAMESPACE index 5c5977eb4..233ea5b63 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -211,11 +211,13 @@ export(rb_to_common_language) export(rb_to_p_superiority) export(rb_to_vda) export(rb_to_wmw_odds) +export(repeated_measures_d) export(riskratio) export(riskratio_to_arr) export(riskratio_to_logoddsratio) export(riskratio_to_nnt) export(riskratio_to_oddsratio) +export(rm_d) export(rules) export(sd_pooled) export(standardise) diff --git a/NEWS.md b/NEWS.md index 1d3532561..05d6febf2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,11 @@ - This release changes the licensing model of `{effectsize}` to an MIT license. +## New features + +- `repeated_measures_d()` to compute standardized mean differences (SMD) for repeated measures data. + - Also supported in `effectsize()` + # effectsize 0.8.7 ## New features diff --git a/R/cohens_d.R b/R/cohens_d.R index 5956bf6a7..f778e6242 100644 --- a/R/cohens_d.R +++ b/R/cohens_d.R @@ -25,7 +25,7 @@ #' variance). Else the mean SD from both groups is used instead. #' @param paired If `TRUE`, the values of `x` and `y` are considered as paired. #' This produces an effect size that is equivalent to the one-sample effect -#' size on `x - y`. +#' size on `x - y`. See also [repeated_measures_d()] for more options. #' @param ... Arguments passed to or from other methods. When `x` is a formula, #' these can be `subset` and `na.action`. #' @inheritParams chisq_to_phi @@ -48,7 +48,7 @@ #' `Glass_delta`) and their CIs (`CI_low` and `CI_high`). #' #' @family standardized differences -#' @seealso [sd_pooled()], [t_to_d()], [r_to_d()] +#' @seealso [rm_d()], [sd_pooled()], [t_to_d()], [r_to_d()] #' #' @examples #' \donttest{ @@ -91,10 +91,12 @@ #' #' # same as: #' # cohens_d(sleep$extra[sleep$group == 1], sleep$extra[sleep$group == 2], paired = TRUE) +#' # cohens_d(sleep$extra[sleep$group == 1] - sleep$extra[sleep$group == 2]) +#' # rm_d(sleep$extra[sleep$group == 1], sleep$extra[sleep$group == 2], method = "z", adjust = FALSE) #' #' # More options: -#' cohens_d(Pair(extra[group == 1], extra[group == 2]) ~ 1, data = sleep, mu = -1) -#' hedges_g(Pair(extra[group == 1], extra[group == 2]) ~ 1, data = sleep) +#' cohens_d(Pair(extra[group == 1], extra[group == 2]) ~ 1, data = sleep, mu = -1, verbose = FALSE) +#' hedges_g(Pair(extra[group == 1], extra[group == 2]) ~ 1, data = sleep, verbose = FALSE) #' #' #' # Interpretation ----------------------- @@ -208,6 +210,12 @@ glass_delta <- function(x, y = NULL, data = NULL, y <- out[["y"]] paired <- out[["paired"]] + if (verbose && paired && !is.null(y)) { + insight::format_alert( + "For paired samples, 'repeated_measures_d()' provides more options." + ) + } + if (is.null(y)) { if (type == "delta") { insight::format_error("For Glass' Delta, please provide data from two samples.") @@ -287,7 +295,7 @@ glass_delta <- function(x, y = NULL, data = NULL, if (type == "g") { - J <- exp(lgamma(df / 2) - log(sqrt(df / 2)) - lgamma((df - 1) / 2)) # exact method + J <- .J(df) out[, colnames(out) %in% c("Hedges_g", "CI_low", "CI_high")] <- out[, colnames(out) %in% c("Hedges_g", "CI_low", "CI_high")] * J @@ -300,3 +308,8 @@ glass_delta <- function(x, y = NULL, data = NULL, ) return(out) } + +#' @keywords internal +.J <- function(df) { + exp(lgamma(df / 2) - log(sqrt(df / 2)) - lgamma((df - 1) / 2)) # exact method +} diff --git a/R/common_language.R b/R/common_language.R index 9b8ef22f2..392c094ad 100644 --- a/R/common_language.R +++ b/R/common_language.R @@ -7,6 +7,9 @@ #' any reported [`stats::t.test()`] or [`stats::wilcox.test()`]. #' #' @inheritParams cohens_d +#' @param paired If `TRUE`, the values of `x` and `y` are considered as paired. +#' This produces an effect size that is equivalent to the one-sample effect +#' size on `x - y`. #' @param parametric Use parametric estimation (see [cohens_d()]) or #' non-parametric estimation (see [rank_biserial()]). See details. #' @param iterations The number of bootstrap replicates for computing confidence @@ -126,6 +129,10 @@ p_superiority <- function(x, y = NULL, data = NULL, paired <- data[["paired"]] if (parametric) { + if (paired) { + x <- x - y + y <- NULL + } d <- cohens_d( x = x, y = y, diff --git a/R/datasets.R b/R/datasets.R index 68aed4ada..7a6ac62b9 100644 --- a/R/datasets.R +++ b/R/datasets.R @@ -28,6 +28,36 @@ #' NULL +#' Jeff Rouder's Example Dataset for Repeated Measures +#' +#' A dataset "with 25 people each observing 50 trials in 2 conditions", +#' published as `effectSizePuzzler.txt` by Jeff Rouder on March 24, 2016 +#' (_http://jeffrouder.blogspot.com/2016/03/the-effect-size-puzzler.html_). +#' \cr\cr +#' The data is used in examples and tests of [rm_d()]. +#' +#' @docType data +#' +#' @name rouder2016 +#' +#' @keywords data +#' +#' @format A data frame with 2500 rows and 3 variables: +#' \describe{ +#' \item{id}{participant: 1...25} +#' \item{cond}{condition: 1,2} +#' \item{rt}{response time in seconds} +#' } +#' +#' ```{r} +#' data("rouder2016") +#' head(rouder2016, n = 5) +#' ``` +#' @family effect size datasets +#' +NULL + + #' Results from 2 Screening Tests #' #' A sample (simulated) dataset, used in tests and some examples. diff --git a/R/effectsize.R b/R/effectsize.R index 1ebca00be..b0377c17b 100644 --- a/R/effectsize.R +++ b/R/effectsize.R @@ -14,6 +14,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 one of `"p_superiority"`, `"u1"`, `"u2"`, `"u3"`, `"overlap"`. +#' - For a **Paired t-test**: depending on `type`: `"rm"`, `"av"`, `"b"`, `"d"`, `"z"`. #' - A **Chi-squared tests of independence** or **Fisher's Exact Test**, depending on `type`: `"cramers_v"` (default), `"tschuprows_t"`, `"phi"`, `"cohens_w"`, `"pearsons_c"`, `"cohens_h"`, `"oddsratio"`, `"riskratio"`, `"arr"`, or `"nnt"`. #' - 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"`. @@ -50,6 +51,13 @@ #' Tt <- t.test(1:10, y = c(7:20), alternative = "less") #' effectsize(Tt) #' +#' Tt <- t.test( +#' 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), +#' paired = TRUE +#' ) +#' effectsize(Tt, type = "rm_b") +#' #' Aov <- oneway.test(extra ~ group, data = sleep, var.equal = TRUE) #' effectsize(Aov) #' effectsize(Aov, type = "omega") diff --git a/R/effectsize.htest.R b/R/effectsize.htest.R index bce6e5957..86d7213ad 100644 --- a/R/effectsize.htest.R +++ b/R/effectsize.htest.R @@ -44,11 +44,11 @@ effectsize.htest <- function(model, type = NULL, verbose = TRUE, ...) { dots$alternative <- model$alternative dots$ci <- attr(model$conf.int, "conf.level") dots$mu <- model$null.value - dots$paired <- !grepl("Two", model$method, fixed = TRUE) + dots$paired <- grepl("Paired", model$method, fixed = TRUE) dots$verbose <- verbose if (!type %in% c("d", "g")) { - .fail_if_approx(approx, "cles") + .fail_if_approx(approx, if (startsWith(type, "rm")) "rm_d" else "cles") } if (approx) { @@ -81,6 +81,11 @@ effectsize.htest <- function(model, type = NULL, verbose = TRUE, ...) { d = cohens_d, g = hedges_g ) + } else if (dots$paired && startsWith(type, "rm")) { + args[c("x", "y")] <- split(args$x, args$y) + dots$paired <- args$pooled_sd <- NULL + args$method <- gsub("^rm\\_", "", type) + f <- rm_d } else { if (!dots$paired && !args$pooled_sd) { insight::format_error("Common language effect size only applicable to Cohen's d with pooled SD.") diff --git a/R/mahalanobis_D.R b/R/mahalanobis_D.R index c7e30eb64..c365b4519 100644 --- a/R/mahalanobis_D.R +++ b/R/mahalanobis_D.R @@ -85,7 +85,6 @@ mahalanobis_d <- function(x, y = NULL, data = NULL, pooled_cov = TRUE, mu = 0, ci = 0.95, alternative = "greater", verbose = TRUE, ...) { - # TODO add one sample case DV1 + DV2 ~ 1 # TODO add paired samples case DV1 + DV2 ~ 1 | ID alternative <- .match.alt(alternative, FALSE) data <- .get_data_multivariate(x, y, data, verbose = verbose, ...) diff --git a/R/print.effectsize_table.R b/R/print.effectsize_table.R index 62e22ff79..8af3354c4 100644 --- a/R/print.effectsize_table.R +++ b/R/print.effectsize_table.R @@ -161,7 +161,8 @@ print.effectsize_difference <- function(x, digits = 2, append_CLES = NULL, ...) #' @export format.effectsize_difference <- function(x, digits = 2, ...) { - caption <- subtitle <- footer <- NULL + caption <- subtitle <- NULL + footer <- attr(x, "table_footer") ## Add footer mu <- attr(x, "mu") diff --git a/R/rank_diff.R b/R/rank_diff.R index 6ecc51dfd..c1a58ae70 100644 --- a/R/rank_diff.R +++ b/R/rank_diff.R @@ -6,6 +6,7 @@ #' to the [Common Language Effect Sizes][cohens_u3]. Pair with any reported #' [`stats::wilcox.test()`]. #' +#' @inheritParams p_superiority #' @inheritParams cohens_d #' @param x,y A numeric or ordered vector, or a character name of one in `data`. #' Any missing values (`NA`s) are dropped from the resulting vector. `x` can diff --git a/R/repeated_measures_d.R b/R/repeated_measures_d.R new file mode 100644 index 000000000..53fcace62 --- /dev/null +++ b/R/repeated_measures_d.R @@ -0,0 +1,306 @@ +#' Standardized Mean Differences for Repeated Measures +#' +#' Compute effect size indices for standardized mean differences in repeated +#' measures data. Pair with any reported `stats::t.test(paired = TRUE)`. +#' \cr\cr +#' In a repeated-measures design, the same subjects are measured in multiple +#' conditions or time points. Unlike the case of independent groups, there are +#' multiple sources of variation that can be used to standardized the +#' differences between the means of the conditions / times. +#' +#' @param x,y Paired numeric vectors, or names of ones in `data`. `x` can also +#' be a formula: +#' - `Pair(x,y) ~ 1` for wide data. +#' - `y ~ condition | id` for long data, possibly with repetitions. +#' @param method Method of repeated measures standardized differences. See +#' details. +#' @param adjust Apply Hedges' small-sample bias correction? See [hedges_g()]. +#' @inheritParams cohens_d +#' +#' @details +#' +#' # Standardized Mean Differences for Repeated Measures +#' +#' Unlike [Cohen's d][cohens_d()] for independent groups, where standardization +#' naturally is done by the (pooled) population standard deviation (cf. Glass’s +#' \eqn{\Delta}), when measured across two conditions are dependent, there are +#' many more options for what error term to standardize by. Additionally, some +#' options allow for data to be replicated (many measurements per condition per +#' individual), others require a single observation per condition per individual +#' (aka, paired data; so replications are aggregated). +#' +#' (It should be noted that all of these have awful and confusing notations.) +#' +#' Standardize by... + +#' - **Difference Score Variance: \eqn{d_{z}}** (_Requires paired data_) - This +#' is akin to computing difference scores for each individual and then +#' computing a one-sample Cohen's _d_ (Cohen, 1988, pp. 48; see examples). +#' - **Within-Subject Variance: \eqn{d_{rm}}** (_Requires paired data_) - Cohen +#' suggested adjusting \eqn{d_{z}} to estimate the "standard" between-subjects +#' _d_ by a factor of \eqn{\sqrt{2(1-r)}}, where _r_ is the Pearson correlation +#' between the paired measures (Cohen, 1988, pp. 48). +#' - **Control Variance: \eqn{d_{b}} (aka Becker's _d_)** (_Requires paired +#' data_) - Standardized by the variance of the control condition (or in a pre- +#' post-treatment setting, the pre-treatment condition). This is akin to Glass' +#' _delta_ ([glass_delta()]) (Becker, 1988). Note that this is taken here as the +#' _second_ condition (`y`). +#' - **Average Variance: \eqn{d_{av}}** (_Requires paired data_) - Instead of +#' standardizing by the variance in the of the control (or pre) condition, +#' Cumming suggests standardizing by the average variance of the two paired +#' conditions (Cumming, 2013, pp. 291). +#' - **All Variance: \eqn{d_{d}}** - This is the same as computing a standard +#' independent-groups Cohen's _d_ (Cohen, 1988). Note that CIs _do_ account for +#' the dependence, and so are typically more narrow (see examples). +#' - **Residual Variance: \eqn{d_{r}}** (_Requires data with replications_) - +#' Divide by the pooled variance after all individual differences have been +#' partialled out (i.e., the residual/level-1 variance in an ANOVA or MLM +#' setting). In between-subjects designs where each subject contributes a single +#' response, this is equivalent to classical Cohen’s d. Priors in the +#' `BayesFactor` package are defined on this scale (Rouder et al., 2012). +#' \cr\cr +#' Note that for paired data, when the two conditions have equal variance, +#' \eqn{d_{rm}}, \eqn{d_{av}}, \eqn{d_{b}} are equal to \eqn{d}. +#' +#' # Confidence (Compatibility) Intervals (CIs) +#' Confidence intervals are estimated using the standard normal parametric +#' method (see Algina & Keselman, 2003; Becker, 1988; Cooper et al., 2009; +#' Hedges & Olkin, 1985; Pustejovsky et al., 2014). +#' +#' @inheritSection effectsize_CIs CIs and Significance Tests +#' @inheritSection print.effectsize_table Plotting with `see` +#' +#' @note +#' `rm_d()` is an alias for `repeated_measures_d()`. +#' +#' @return A data frame with the effect size and their CIs (`CI_low` and +#' `CI_high`). +#' +#' @family standardized differences +#' @seealso [cohens_d()], and `lmeInfo::g_mlm()` and `emmeans::effsize()` for +#' more flexible methods. +#' +#' @references +#' +#' - Algina, J., & Keselman, H. J. (2003). Approximate confidence intervals for +#' effect sizes. Educational and Psychological Measurement, 63(4), 537-553. +#' - Becker, B. J. (1988). Synthesizing standardized mean‐change measures. +#' British Journal of Mathematical and Statistical Psychology, 41(2), 257-278. +#' - Cohen, J. (1988). Statistical power analysis for the behavioral +#' sciences (2nd Ed.). New York: Routledge. +#' - Cooper, H., Hedges, L., & Valentine, J. (2009). Handbook of research +#' synthesis and meta-analysis. Russell Sage Foundation, New York. +#' - Cumming, G. (2013). Understanding the new statistics: Effect sizes, +#' confidence intervals, and meta-analysis. Routledge. +#' - Hedges, L. V. & Olkin, I. (1985). Statistical methods for +#' meta-analysis. Orlando, FL: Academic Press. +#' - Pustejovsky, J. E., Hedges, L. V., & Shadish, W. R. (2014). +#' Design-comparable effect sizes in multiple baseline designs: A general +#' modeling framework. Journal of Educational and Behavioral Statistics, 39(5), +#' 368-393. +#' - Rouder, J. N., Morey, R. D., Speckman, P. L., & Province, J. M. (2012). +#' Default Bayes factors for ANOVA designs. Journal of mathematical psychology, +#' 56(5), 356-374. +#' +#' @examples +#' # Paired data ------- +#' +#' data("sleep") +#' sleep2 <- reshape(sleep, +#' direction = "wide", +#' idvar = "ID", timevar = "group" +#' ) +#' +#' repeated_measures_d(Pair(extra.1, extra.2) ~ 1, data = sleep2) +#' +#' # Same as: +#' # repeated_measures_d(sleep$extra[sleep$group==1], +#' # sleep$extra[sleep$group==2]) +#' # repeated_measures_d(extra ~ group | ID, data = sleep) +#' +#' +#' # More options: +#' repeated_measures_d(Pair(extra.1, extra.2) ~ 1, data = sleep2, mu = -1) +#' repeated_measures_d(Pair(extra.1, extra.2) ~ 1, data = sleep2, alternative = "less") +#' +#' # Other methods +#' repeated_measures_d(Pair(extra.1, extra.2) ~ 1, data = sleep2, method = "av") +#' repeated_measures_d(Pair(extra.1, extra.2) ~ 1, data = sleep2, method = "b") +#' repeated_measures_d(Pair(extra.1, extra.2) ~ 1, data = sleep2, method = "d") +#' repeated_measures_d(Pair(extra.1, extra.2) ~ 1, data = sleep2, method = "z", adjust = FALSE) +#' +#' # d_z is the same as Cohen's d for one sample (of individual difference): +#' cohens_d(extra.1 - extra.2 ~ 1, data = sleep2) +#' +#' +#' +#' # Repetition data ----------- +#' +#' data("rouder2016") +#' +#' # For rm, ad, z, b, data is aggregated +#' repeated_measures_d(rt ~ cond | id, data = rouder2016) +#' +#' # same as: +#' rouder2016_wide <- tapply(rouder2016[["rt"]], rouder2016[1:2], mean) +#' repeated_measures_d(rouder2016_wide[, 1], rouder2016_wide[, 2]) +#' +#' # For r or d, data is not aggragated: +#' repeated_measures_d(rt ~ cond | id, data = rouder2016, method = "r") +#' repeated_measures_d(rt ~ cond | id, data = rouder2016, method = "d", adjust = FALSE) +#' +#' # d is the same as Cohen's d for two independent groups: +#' cohens_d(rt ~ cond, data = rouder2016, ci = NULL) +#' +#' @export +repeated_measures_d <- function(x, y, + data = NULL, + mu = 0, method = c("rm", "av", "z", "b", "d", "r"), + adjust = TRUE, + ci = 0.95, alternative = "two.sided", + verbose = TRUE, ...) { + method <- match.arg(method) + if (.is_htest_of_type(x, "t-test")) { + return(effectsize(x, type = paste0("rm_", method), verbose = verbose, adjust = adjust, ...)) + } + + alternative <- .match.alt(alternative) + data <- .get_data_paired(x, y, data = data, method = method, verbose = verbose, ...) + + if (method %in% c("d", "r")) { + values <- .replication_d(data, mu = mu, method = method) + } else { + values <- .paired_d(data, mu = mu, method = method) + } + + out <- data.frame(d = values[["d"]]) + + if (.test_ci(ci)) { + # TODO use ncp + # Add cis + out$CI <- ci + ci.level <- .adjust_ci(ci, alternative) + + alpha <- 1 - ci.level + probs <- c(alpha / 2, 1 - alpha / 2) + qs <- stats::qnorm(probs) + + confint <- out[["d"]] + qs * values[["se"]] + out$CI_low <- confint[1] + out$CI_high <- confint[2] + + ci_method <- list(method = "normal") + out <- .limit_ci(out, alternative, -Inf, Inf) + } else { + ci_method <- alternative <- NULL + } + + + if (adjust) { + J <- .J(values[["df"]]) + + out[, colnames(out) %in% c("d", "CI_low", "CI_high")] <- + out[, colnames(out) %in% c("d", "CI_low", "CI_high")] * J + + attr(out, "table_footer") <- "Adjusted for small sample bias." + } + + # rename column to method + colnames(out)[1] <- switch(method, + d = "Cohens_d", + b = "Beckers_d", + paste0("d_", method) + ) + + class(out) <- c("effectsize_difference", "effectsize_table", "see_effectsize_table", class(out)) + .someattributes(out) <- .nlist( + mu, ci, ci_method, alternative, + approximate = FALSE + ) + return(out) +} + +#' @rdname repeated_measures_d +#' @export +rm_d <- repeated_measures_d + +#' @keywords internal +.paired_d <- function(data, mu, method) { + x <- data[["x"]] + y <- data[["y"]] + + m <- mean(x - y) + n <- length(x) + df <- n - 1 + r <- stats::cor(x, y) + f <- 2 * (1 - r) + + if (method == "rm") { + s <- stats::sd(x - y) / sqrt(f) + d <- (m - mu) / s + + # Cooper et al., 2009, eq 12.21 + se <- sqrt((1 / n + (d^2) / (2 * n)) * f) + } else if (method == "av") { + s <- sqrt((stats::var(x) + stats::var(y)) / 2) + d <- (m - mu) / s + + # Algina & Keselman, 2003, eq 4 (from Bird 2002?) + se <- sqrt(stats::var(x - y) / n) / s + } else if (method == "z") { + s <- stats::sd(x - y) + d <- (m - mu) / s + + # Hedges and Olkin, 1985, page 86, eq 14 + se <- sqrt((1 / n) + (d^2) / (2 * n)) + } else if (method == "b") { + s <- stats::sd(y) + d <- (m - mu) / s + + # Becker 1988, eq. 6 + se <- sqrt(f / n + (d^2) / (2 * n)) + } + + .nlist(d, se, df) +} + +#' @keywords internal +.replication_d <- function(data, mu, method) { + if (method == "r") { + # for r - need to make sure there are replications! + cell_ns <- tapply(data[[1]], data[3:2], function(v) length(stats::na.omit(v))) + all(cell_ns > 1L) + } + + mod <- suppressWarnings( + stats::aov(y ~ condition + Error(id / condition), + data = data, + contrasts = list(condition = stats::contr.treatment) + ) + ) + m <- -unname(stats::coef(mod[["id:condition"]])) + m_V <- unname(stats::vcov(mod[["id:condition"]])[1]) + + pars <- parameters::model_parameters(mod) + + if (method == "d") { + e <- as.data.frame(pars[pars$Parameter == "Residuals", ]) + } else if (method == "r") { + e <- as.data.frame(pars[pars$Group == "Within", ]) + } + + s <- sqrt(sum(e[["Sum_Squares"]]) / sum(e[["df"]])) + v <- sum(e[["df"]]) + + d <- (m - mu) / s + + # Pustejovsky et al 2014 eq 15 + J <- .J(v) + g <- d * J + k <- sqrt(m_V) / s + se <- sqrt( + (v * k^2) / (v - 2) + g^2 * (v / (v - 2) - 1 / J^2) + ) + + .nlist(d, se, df = v) +} diff --git a/R/sysdata.rda b/R/sysdata.rda index 16b7380ab367f7c7321a36234f42977965c9c6fc..50806d5790d96ab6b2573e8cdf00627330d48495 100644 GIT binary patch literal 1342 zcmV-E1;P44T4*^jL0KkKSRKL7v#002EU2uMJlfiW;9Mn)zh012ZenE=3;03#z4BTQl(00Te(&=~*# z13&<2pa1{>13(S{0iXbA41fRupa3+`00001paV}-RA>R}00Te(007Vc0000001wp; z00E!?XbgY=0iXah&;S4c0iXd=NFWH%6!gk^6A`0B)HOXuXwo#vrY6NR5f3PB45pd@ zGyZ?7RY;XpQ6q|^wH;cuf82)t(A&)rvVm11q%=}XN{QxSX%bH5>m-z@lGP-h2UB*| z_V0-?R1|S#idsHD|7a7vQXht#*GLiJ?X>r6+53FICHQ%5_sXpBbLvP>5#c;N{nl53 zwc9s0AI)X9=ZW;W`gUXY>g2zixt8AhV{wh~CF+BIiRk5}o#%z9!kLzM-&-o?NA$~c z(0;eX($ZGeELgEzV5jmjGThkXXS<0+`o94Yv;tir}kNTGn08S#QY2=p7Cv z%pE6n$g%dRBj;IS`h`_dVvBo?>ytySQf(e`mJOXWs&_L-Z zqX(+Q#VJDN?q{s;Fh&hBYn4<|j>iL_I8nf15>3=kklQnrs)akO6s5?}Toir9jiigC zCIQt^NktTCYQrwh0|wi*X6V*yKUHJ$;;UR-rIeQ_=EA9F^oi^}RVlu7HN1&5wB{Xs zgm8wAvvtNtzHq}quGfm{=PDMneO$O14o+O*_(~Kh_y36Jc zsV_RE* zg)EU!>uz*!7sQ$INVzUjOA1VRFcH9VJSMQBM;;tY;nImLxcI?yavG0qoiS0=M>zG} zm4}i|)}ydxes$^Sv*XC+U~upZOwQAyu{y;RQMtTk9EBIM^^V0CrYN1Awa-NDx&@S2 z7Ad8M3bO>~sphGAk%ES^7`(%gihGAw9!wN2z&i=L1?|a=bcaQeU7pwXX z@`8+zhDiegLI7q4NE3Z2K_m_ygaUZy!ADP--K=s@5}hQ8H5d51k}1N3hJ(%n*r54; Ax&QzG literal 1234 zcmV;@1TFhQT4*^jL0KkKSr35HI{*f|fB*mg|5R}2I6&{~-_XDR|FF;@1^@&A5`fSF zfPhc{KuORA+tdh(0003=jx;oA&}h&!00000G5`PoGzLHchZ-6*Xf$XV0000082|tP z8Ur8z!6vAYMne-vlzN7M4Fl8wG5`#QhK7NlGy_c^svKx&(V)?wXaE2J0Av6F0B8(= z0|KOwfS5qiGEYIGji#A3Jf_oAOqh>I*)T-Y(V?cNspSA{r}I@7LMq4x21+JdDC=v2 z_Ba_BkbyywDw3p`>K2qaSXl`?7pzH2i7iq|={Q?TQ!>a&bYKiHYv7a&@AV{vJnWL) zj$4vMKK}mKhQ1HwYrQu9@~b2q6$u_w?mq9UZISh~ca3visl%6(g16c0<7jDNd`Wts z+ovT)J1p)xqwyW>! zE?laM+U{K^*>#fXdG0aK$f%`JN4c-@7LBvHG3!nRm1@zvloFy`E``84{9m)YVK~TW zq?{P6edo4tyzdJVbC2M+i|O&;PWew8=vO#NN&b=p#U;(B3%I%3V3bihik%gXx{rB* zf>MRfyY)P4(Vk5*s)|wC*yj!eY%mgTB7Fvds*MrCPqwSv80XA)YwOG-qQ6cETt^@j149< z^Uvp+Y;h!d4l>Ccvw4)@F`m)LUYQQIHaL=;qLibQau@e7FjXsXF(uA}Y{7Gc#7N=P zs(A)kx|~VGsFbOk)M7IUH=(tP5sckr;2ea!&g(fa$0yZ4Sl+YAN z;=`7{9FZlL9oZ7+6f_;SWW=MSjuYf|)*gvBS`NYSt~zV^jy2~7!JyLpu6o4k6j4Uz z@sx84I)`S97ov9cu5`}>oLNPZOBBq*1zCb~R9vK9rD97CX~tRejZCJ9Q7|qz`WmBt zCmJwW+|Id5YnZvH*58#Xq!d^&K~#vWQF3852@)8@h0u<#Mnu~^M^{cmuskT%d#x@t z%SUEJqKtXW$vx^n3X{9f4`q7ZUtONhVJ?#+C;Q?2{ePb>%GlXuD}RU0-P0Detu`2Q wHKA>`l>}f56cJWM1tzIu7L7zyt4i8nD~X|QRc13|a7<{sk}1N3fP4m#*!Mg~-~a#s diff --git a/R/utils_ci.R b/R/utils_ci.R index 2e6de1da5..20950705b 100644 --- a/R/utils_ci.R +++ b/R/utils_ci.R @@ -1,5 +1,7 @@ # NCP ------------------------- +# TODO: other packages like lmeInfo, MOTE and others use qt/qf for these. + #' @keywords internal .get_ncp_F <- function(f, df, df_error, conf.level = 0.9) { if (!is.finite(f) || !is.finite(df) || !is.finite(df_error)) { diff --git a/R/utils_validate_input_data.R b/R/utils_validate_input_data.R index 30c488b04..3002ece00 100644 --- a/R/utils_validate_input_data.R +++ b/R/utils_validate_input_data.R @@ -54,8 +54,8 @@ if (!is.numeric(x)) { insight::format_error("Cannot compute effect size for a non-numeric vector.") } else if (inherits(x, "Pair")) { - x <- x[, 1] - x[, 2] - y <- NULL + y <- x[, 2] + x <- x[, 1] paired <- TRUE } @@ -101,6 +101,87 @@ list(x = x, y = y, paired = paired) } +#' @keywords internal +.get_data_paired <- function(x, y = NULL, data = NULL, method, + verbose = TRUE, ...) { + if (inherits(x, "formula")) { + formula_error <- + "Formula must have one of the following forms: + y ~ condition | id + Pair(x,y) ~ 1" + + # Validate: + if (length(x) != 3L) { + insight::format_error(formula_error) + } else if (length(x[[3]]) == 3L && x[[3]][[1]] == as.name("|")) { + # is long + x[[3L]][[1L]] <- as.name("+") + mf <- .resolve_formula(x, data, ...) + mf <- stats::na.omit(mf) + + if (method %in% c("d", "r")) { + mf[[2]] <- as.factor(mf[[2]]) + mf[[3]] <- as.factor(mf[[3]]) + colnames(mf) <- c("y", "condition", "id") + return(mf) + } + + if (verbose && any(tapply(mf[[1]], mf[3:2], length) > 1L)) { + insight::format_alert( + paste0("The ", method, " standardized difference requires paired data,"), + "but data contains more than one observation per design cell.", + "Aggregating data using `mean()`." + ) + } + + mf <- tapply(mf[[1]], mf[3:2], mean, na.rm = TRUE) + x <- mf[, 1] + y <- mf[, 2] + } else if (x[[2]][[1]] == as.name("Pair")) { + # is Pair (wide) + mf <- .resolve_formula(x, data, ...) + if (ncol(mf) != 1L) { + insight::format_error(formula_error) + } + x <- mf[[1]] + } else { + insight::format_error(formula_error) + } + } else { + # Test if they are they are column names + x <- .resolve_char(x, data) + y <- .resolve_char(y, data) + } + + if (inherits(x, "Pair")) { + y <- x[, 2] + x <- x[, 1] + } + + # x should be a numeric vector or a Pair: + if (!is.numeric(x) || !is.numeric(y)) { + insight::format_error("Cannot compute effect size for a non-numeric vector.") + } + + o <- stats::complete.cases(x, y) + x <- x[o] + y <- y[o] + + if (method == "r") { + insight::format_error("d{r} requires replications.") + } else if (method == "d") { + n <- length(x) + data <- data.frame( + y = c(x, y), + condition = factor(rep(1:2, each = n)), + id = factor(rep(seq(n), times = 2)) + ) + return(data) + } + + list(x = x, y = y) +} + #' @keywords internal .get_data_xtabs <- function(x, y = NULL, p = NULL) { diff --git a/README.Rmd b/README.Rmd index 444bf16b5..1e8edc642 100644 --- a/README.Rmd +++ b/README.Rmd @@ -109,7 +109,7 @@ hedges_g(mpg ~ am, data = mtcars) glass_delta(mpg ~ am, data = mtcars) ``` -`effectsize` also provides effect sizes for *rank tests*, *common language effect sizes* and more... +`effectsize` also provides effect sizes for *paired standardized differences*, *rank tests*, *common language effect sizes* and more... ### Contingency Tables diff --git a/WIP/paired_d examples.R b/WIP/paired_d examples.R deleted file mode 100644 index e62a2f1d4..000000000 --- a/WIP/paired_d examples.R +++ /dev/null @@ -1,75 +0,0 @@ -library(effectsize) - -source("WIP/paired_d2.R") - -dat <- read.table("http://pcl.missouri.edu/exp/effectSizePuzzler.txt", header = TRUE) - -# From http://jakewestfall.org/blog/index.php/2016/03/25/five-different-cohens-d-statistics-for-within-subject-designs/ -# More types: -# https://doi.org/10.3389/fpsyg.2013.00863 -# https://journals.sagepub.com/doi/pdf/10.1177/0013164403256358 (CIs) - -# Are CIs correct? -# Need to simulate data with a big subject:condition interaction. - -#' Single measurement: -#' d - classic definition -#' r - standardize by the residual sd (sigma) -paired_d(rt ~ cond | id, data = dat, type = "d") # 0.2497971 -paired_d(rt ~ cond | id, data = dat, type = "r") # 0.2587388 - -#' Aggregate: -#' a - aggregate -#' z - standardized scores -#' t - (incorrect) conversion from t statistic (d_z * sqrt(2)) -#' rm - d, but accounts for correlation between repeated measures (not a good name) -#' av - d, but just use average sd (isn't this type a?) -paired_d(rt ~ cond | id, data = dat, type = "a") # 0.8357347 -paired_d(rt ~ cond | id, data = dat, type = "z") # 1.353713 -paired_d(rt ~ cond | id, data = dat, type = "t") # 1.914439 -paired_d(rt ~ cond | id, data = dat, type = "rm") -paired_d(rt ~ cond | id, data = dat, type = "av") - - - -# Test on other data: -data(stroop, package = "afex") -stroop <- subset(stroop, study == "1" & condition == "control") - -cohens_d(rt ~ congruency, data = stroop) -paired_d(rt ~ congruency | pno, data = stroop, type = "d") -paired_d(rt ~ congruency | pno, data = stroop, type = "r") - -paired_d(rt ~ congruency | pno, data = stroop, type = "a") -paired_d(rt ~ congruency | pno, data = stroop, type = "z") -paired_d(rt ~ congruency | pno, data = stroop, type = "t") -paired_d(rt ~ congruency | pno, data = stroop, type = "rm") -paired_d(rt ~ congruency | pno, data = stroop, type = "av") - - -set.seed(1) -dat <- expand.grid( - t = 1:100, - id = letters[1:10], - cond = LETTERS[1:2] -) |> - as.data.frame() |> - dplyr::select(-t) |> - dplyr::mutate( - dplyr::across(.fns = factor), - dplyr::across(.fns = `contrasts<-`, value = contr.sum), - rt = model.matrix(~ id * cond) %*% - c(0, c(scale(seq(0, 1, length = 9))), 0.9, c(scale(seq(0, 1, length = 9)))) + - rnorm(2000, sd = 0.85) - ) - - -cohens_d(rt ~ cond, data = dat) -paired_d(rt ~ cond | id, data = dat, type = "d") -paired_d(rt ~ cond | id, data = dat, type = "r") - -paired_d(rt ~ cond | id, data = dat, type = "a") -paired_d(rt ~ cond | id, data = dat, type = "z") -paired_d(rt ~ cond | id, data = dat, type = "t") -paired_d(rt ~ cond | id, data = dat, type = "rm") -paired_d(rt ~ cond | id, data = dat, type = "av") diff --git a/WIP/paired_d2.R b/WIP/paired_d2.R deleted file mode 100644 index 11ae9ff1a..000000000 --- a/WIP/paired_d2.R +++ /dev/null @@ -1,202 +0,0 @@ -paired_d <- function(x, group, block, data = NULL, - mu = 0, ci = 0.95, alternative = "two.sided", - type = c("d", "a", "r", "z", "t", "av", "rm")) { - type <- match.arg(type) - alternative <- .match.alt(alternative) - - data <- effectsize:::.kendalls_w_data(x, group, block, data, wide = FALSE) - if (!is.factor(data$groups)) data$groups <- factor(data$groups) - if (!is.factor(data$blocks)) data$blocks <- factor(data$blocks) - contrasts(data$groups) <- contr.treatment - contrasts(data$blocks) <- contr.treatment - - stopifnot(nlevels(data$groups) == 2L) - - - if (type %in% c("a", "z", "t", "av", "rm")) { - data <- aggregate(data$x, data[-1], mean) - xtab <- table(data[-3]) - data <- data[data$blocks %in% colnames(xtab)[colSums(xtab) %in% 2], ] - } - - if (type %in% c("z", "t")) { - out <- .paired_d_z_t(data, type, mu = mu, ci = ci, alternative = alternative) - } else if (type %in% c("av", "rm")) { - out <- .paired_d_av_rm(data, type, mu = mu, ci = ci, alternative = alternative) - } else if (type %in% c("d", "a", "r")) { - out <- .paired_d_d_a_r(data, type, mu = mu, ci = ci, alternative = alternative) - } - - attr(out, "paired_type") <- type - out -} - -.paired_d_z_t <- function(data, type, - mu = 0, ci = 0.95, alternative = "two.sided") { - data <- data[order(data$groups), ] - data <- aggregate(data$x, data[2], diff) - - out <- cohens_d(-data$x, mu = mu, ci = ci, alternative = alternative) - colnames(out)[1] <- "d_z" - - if (type == "t") { - colnames(out)[1] <- "d_t" - out[colnames(out) %in% c("d_t", "CI_low", "CI_high")] <- - sqrt(2) * out[colnames(out) %in% c("d_t", "CI_low", "CI_high")] - } - - out -} - -.paired_d_d_a_r <- function(data, type, - mu = 0, ci = 0.95, alternative = "two.sided") { - # Use ANOVA decomp - mod <- stats::aov(x ~ groups + Error(blocks / groups), data = data) - pars <- as.data.frame(parameters::model_parameters(mod)) - - # Look in: - # d/r = groups - # a = blocks:groups - is_d <- - pars$Paramete == "groups" & - pars$df == 1 & - pars$Group == "blocks:groups" - - d <- -unname(coef(mod[["blocks:groups"]])) - - if (type %in% c("d", "a")) { - ss <- sum(pars[!is_d, "Sum_Squares"]) - df <- sum(pars[!is_d, "df"]) - s <- sqrt(ss / df) - } else if (type == "r") { - is_r <- pars$Group == "Within" & pars$Parameter == "Residuals" - ss <- pars[is_r, "Sum_Squares"] - df <- pars[is_r, "df"] - s <- sqrt(ss / df) - } - - out <- data.frame(d = (d - mu) / s) - if (type != "d") names(out) <- paste0("d_", type) - - if (.test_ci(ci)) { - out$CI <- ci - ci.level <- .adjust_ci(ci, alternative) - - is_mse <- - pars$Paramete == "Residuals" & - pars$Group == "blocks:groups" - - # Delta method to get se - beta <- c(d - mu, s) - V <- matrix(c( - vcov(mod[["blocks:groups"]]), 0, - 0, 2 / df - ), nrow = 2) - se <- .deltamethod(~ x1 / x2, beta, V, ses = TRUE) - - # Critical value - tc <- pt(0.5 + ci.level / 2, df = pars[is_mse, "df"]) - - out$CI_low <- out[[1]] - tc * se - out$CI_high <- out[[1]] + tc * se - - ci_method <- list(method = "delta") - out <- .limit_ci(out, alternative, -Inf, Inf) - } else { - ci_method <- alternative <- NULL - } - - class(out) <- c("effectsize_difference", "effectsize_table", "see_effectsize_table", class(out)) - attr(out, "mu") <- mu - attr(out, "ci") <- ci - attr(out, "ci_method") <- ci_method - attr(out, "approximate") <- FALSE - attr(out, "alternative") <- alternative - return(out) -} - -.paired_d_av_rm <- function(data, type, - mu = 0, ci = 0.95, alternative = "two.sided") { - data <- data[order(data[[1]], data[[2]]), ] - - d <- -diff(tapply(data$x, data$groups, mean)) - ss <- tapply(data$x, data$groups, sd) - - r <- cor( - data$x[data$groups == data$groups[1]], - data$x[data$groups != data$groups[1]] - ) - co <- cov( - data$x[data$groups == data$groups[1]], - data$x[data$groups != data$groups[1]] - ) - n <- nrow(data) / 2 - - Sdiff <- sqrt(sum(ss^2) - 2 * co) - - if (type == "av") { - out <- data.frame(d_av = (d - mu) / mean(ss)) - } else if (type == "rm") { - out <- data.frame(d_rm = sqrt(2 * (1 - r)) * (d - mu) / Sdiff) - } - - - if (.test_ci(ci)) { - out$CI <- ci - ci.level <- .adjust_ci(ci, alternative) - - tc <- qt(0.5 + ci.level / 2, df = n - 1, lower.tail = TRUE) - se <- sqrt((2 * Sdiff^2) / (n * sum(ss))) - - out$CI_low <- out[[1]] - tc * se - out$CI_high <- out[[1]] + tc * se - ci_method <- list(method = "normal") - out <- .limit_ci(out, alternative, -Inf, Inf) - } else { - ci_method <- alternative <- NULL - } - - class(out) <- c("effectsize_difference", "effectsize_table", "see_effectsize_table", class(out)) - attr(out, "mu") <- mu - attr(out, "ci") <- ci - attr(out, "ci_method") <- ci_method - attr(out, "approximate") <- FALSE - attr(out, "alternative") <- alternative - return(out) -} - -# .sample_within <- function(.data) { -# .data |> -# tidyr::nest(data = -id) |> -# dplyr::slice_sample(prop = 1, replace = TRUE) |> -# dplyr::mutate(id = seq_along(id)) |> -# tidyr::unnest(cols = data) -# } - - -#' @keywords internal -.deltamethod <- function(g, mean, cov, ses = TRUE) { - cov <- as.matrix(cov) - n <- length(mean) - if (!is.list(g)) { - g <- list(g) - } - if ((dim(cov)[1] != n) || (dim(cov)[2] != n)) { - insight::format_error( - "Covariances should be a ", n, " by ", n, - " matrix." - ) - } - syms <- paste("x", 1:n, sep = "") - for (i in 1:n) assign(syms[i], mean[i]) - gdashmu <- t(sapply(g, function(form) { - as.numeric(attr(eval(stats::deriv(form, syms)), "gradient")) - })) - new.covar <- gdashmu %*% cov %*% t(gdashmu) - if (ses) { - new.se <- sqrt(diag(new.covar)) - new.se - } else { - new.covar - } -} diff --git a/_pkgdown.yml b/_pkgdown.yml index 9c371bc05..4defa8127 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -14,6 +14,7 @@ reference: Effect sizes for comparing two groups contents: - cohens_d + - repeated_measures_d - mahalanobis_d - rank_biserial - p_superiority @@ -88,6 +89,7 @@ reference: - subtitle: "Datasets" contents: - hardlyworking + - rouder2016 - screening_test - RCT_table - Music_preferences diff --git a/data-raw/df data.R b/data-raw/df data.R index da5839e35..56bb54112 100644 --- a/data-raw/df data.R +++ b/data-raw/df data.R @@ -246,4 +246,16 @@ hardlyworking <- data.frame( hardlyworking$is_senior <- hardlyworking$seniority > 4 save(hardlyworking, file = "data/hardlyworking.rdata") + + +# rouder2016 -------------------------------------------------------------- + +rouder2016 <- read.table("data-raw/effectSizePuzzler.txt", + header = TRUE, stringsAsFactors = FALSE +) +rouder2016[["id"]] <- factor(rouder2016[["id"]]) +rouder2016[["cond"]] <- factor(rouder2016[["cond"]]) + +save(rouder2016, file = "data/rouder2016.rdata") + # styler: on diff --git a/data-raw/effectSizePuzzler.txt b/data-raw/effectSizePuzzler.txt new file mode 100644 index 000000000..e21eaedf2 --- /dev/null +++ b/data-raw/effectSizePuzzler.txt @@ -0,0 +1,2501 @@ +id cond rt +1 1 0.56 +1 1 0.93 +1 1 0.795 +1 1 0.615 +1 1 1.028 +1 1 0.845 +1 1 0.723 +1 1 0.942 +1 1 0.938 +1 1 0.926 +1 1 0.897 +1 1 0.87 +1 1 0.759 +1 1 0.722 +1 1 0.711 +1 1 0.668 +1 1 0.737 +1 1 0.602 +1 1 1.303 +1 1 1.017 +1 1 0.617 +1 1 0.708 +1 1 0.699 +1 1 0.917 +1 1 0.756 +1 1 0.813 +1 1 0.765 +1 1 0.763 +1 1 1.058 +1 1 0.734 +1 1 1.098 +1 1 0.573 +1 1 0.876 +1 1 0.79 +1 1 0.806 +1 1 0.836 +1 1 0.694 +1 1 0.718 +1 1 0.629 +1 1 0.623 +1 1 0.822 +1 1 0.849 +1 1 0.778 +1 1 0.948 +1 1 1.262 +1 1 0.695 +1 1 0.509 +1 1 0.968 +1 1 0.666 +1 1 0.669 +1 2 1.043 +1 2 0.77 +1 2 0.638 +1 2 0.853 +1 2 0.794 +1 2 0.82 +1 2 0.894 +1 2 0.756 +1 2 0.95 +1 2 0.78 +1 2 0.883 +1 2 1.062 +1 2 0.904 +1 2 0.763 +1 2 1.076 +1 2 1.035 +1 2 0.929 +1 2 0.864 +1 2 0.717 +1 2 1.135 +1 2 0.721 +1 2 1.416 +1 2 1.187 +1 2 0.778 +1 2 0.662 +1 2 0.705 +1 2 0.868 +1 2 0.776 +1 2 0.759 +1 2 0.672 +1 2 0.811 +1 2 0.694 +1 2 0.589 +1 2 0.754 +1 2 1.016 +1 2 0.724 +1 2 0.942 +1 2 0.595 +1 2 0.809 +1 2 0.922 +1 2 0.877 +1 2 0.838 +1 2 0.715 +1 2 0.685 +1 2 0.663 +1 2 0.841 +1 2 0.672 +1 2 0.737 +1 2 0.774 +1 2 1.289 +2 1 0.686 +2 1 0.827 +2 1 0.799 +2 1 0.647 +2 1 0.773 +2 1 1.105 +2 1 0.868 +2 1 0.792 +2 1 0.719 +2 1 0.537 +2 1 1.021 +2 1 0.591 +2 1 0.929 +2 1 1.247 +2 1 0.593 +2 1 0.92 +2 1 0.743 +2 1 0.58 +2 1 0.586 +2 1 0.577 +2 1 0.703 +2 1 0.591 +2 1 0.917 +2 1 1.312 +2 1 0.609 +2 1 0.939 +2 1 0.935 +2 1 0.845 +2 1 0.641 +2 1 0.765 +2 1 0.74 +2 1 0.891 +2 1 0.726 +2 1 0.983 +2 1 0.726 +2 1 1.001 +2 1 0.636 +2 1 0.612 +2 1 1.809 +2 1 0.719 +2 1 0.839 +2 1 0.906 +2 1 0.71 +2 1 0.882 +2 1 0.852 +2 1 0.75 +2 1 0.797 +2 1 0.78 +2 1 1.322 +2 1 0.674 +2 2 0.665 +2 2 0.843 +2 2 0.898 +2 2 0.925 +2 2 0.757 +2 2 0.67 +2 2 1.135 +2 2 0.775 +2 2 0.696 +2 2 0.794 +2 2 0.801 +2 2 1.091 +2 2 0.852 +2 2 0.998 +2 2 0.75 +2 2 0.878 +2 2 0.779 +2 2 0.854 +2 2 0.692 +2 2 0.639 +2 2 1.379 +2 2 0.962 +2 2 0.646 +2 2 0.733 +2 2 0.654 +2 2 1.458 +2 2 1.149 +2 2 0.789 +2 2 0.949 +2 2 0.764 +2 2 0.754 +2 2 0.707 +2 2 0.736 +2 2 1.256 +2 2 0.826 +2 2 0.859 +2 2 0.884 +2 2 1.126 +2 2 0.748 +2 2 0.679 +2 2 1.264 +2 2 0.76 +2 2 0.716 +2 2 0.648 +2 2 0.642 +2 2 0.739 +2 2 0.966 +2 2 1.091 +2 2 0.987 +2 2 0.772 +3 1 0.893 +3 1 0.754 +3 1 0.752 +3 1 1.091 +3 1 0.707 +3 1 1.451 +3 1 0.862 +3 1 0.926 +3 1 0.748 +3 1 0.775 +3 1 0.666 +3 1 0.844 +3 1 0.972 +3 1 0.95 +3 1 0.741 +3 1 0.74 +3 1 0.787 +3 1 1.28 +3 1 0.69 +3 1 0.845 +3 1 1.429 +3 1 0.86 +3 1 0.661 +3 1 0.76 +3 1 0.988 +3 1 0.809 +3 1 0.777 +3 1 0.815 +3 1 0.899 +3 1 1.315 +3 1 0.863 +3 1 1.147 +3 1 1.024 +3 1 0.858 +3 1 0.639 +3 1 0.784 +3 1 0.789 +3 1 0.89 +3 1 1.215 +3 1 1.595 +3 1 1.298 +3 1 0.854 +3 1 0.614 +3 1 0.807 +3 1 0.899 +3 1 1.08 +3 1 1.113 +3 1 1.037 +3 1 0.656 +3 1 1.081 +3 2 0.849 +3 2 0.982 +3 2 0.958 +3 2 1.045 +3 2 0.947 +3 2 0.658 +3 2 1.13 +3 2 1.034 +3 2 0.884 +3 2 0.968 +3 2 0.972 +3 2 0.993 +3 2 1.439 +3 2 0.894 +3 2 0.98 +3 2 1.265 +3 2 1.228 +3 2 1.258 +3 2 0.824 +3 2 1.593 +3 2 0.957 +3 2 1.533 +3 2 0.7 +3 2 0.946 +3 2 1.293 +3 2 0.799 +3 2 0.793 +3 2 0.762 +3 2 0.744 +3 2 0.85 +3 2 1.02 +3 2 0.617 +3 2 0.991 +3 2 1.289 +3 2 1.609 +3 2 1.311 +3 2 1.136 +3 2 0.65 +3 2 0.82 +3 2 0.867 +3 2 1.12 +3 2 0.918 +3 2 0.713 +3 2 1.457 +3 2 1.182 +3 2 0.997 +3 2 1.282 +3 2 0.701 +3 2 1.108 +3 2 0.834 +4 1 0.935 +4 1 0.79 +4 1 0.924 +4 1 1.098 +4 1 0.801 +4 1 1.014 +4 1 0.63 +4 1 0.688 +4 1 1.151 +4 1 0.871 +4 1 0.544 +4 1 0.61 +4 1 0.766 +4 1 0.977 +4 1 0.783 +4 1 0.922 +4 1 1 +4 1 1.198 +4 1 0.81 +4 1 0.791 +4 1 0.571 +4 1 0.818 +4 1 0.709 +4 1 0.656 +4 1 0.77 +4 1 1.013 +4 1 0.549 +4 1 0.731 +4 1 0.821 +4 1 0.666 +4 1 0.862 +4 1 0.878 +4 1 0.794 +4 1 0.511 +4 1 1.53 +4 1 0.765 +4 1 0.928 +4 1 0.85 +4 1 1.016 +4 1 0.966 +4 1 0.765 +4 1 0.871 +4 1 0.659 +4 1 0.975 +4 1 0.726 +4 1 1.465 +4 1 0.581 +4 1 0.725 +4 1 0.968 +4 1 0.898 +4 2 0.75 +4 2 0.69 +4 2 0.881 +4 2 0.85 +4 2 0.595 +4 2 0.859 +4 2 0.891 +4 2 0.888 +4 2 0.682 +4 2 0.953 +4 2 1.195 +4 2 0.948 +4 2 0.671 +4 2 0.775 +4 2 0.924 +4 2 0.741 +4 2 0.56 +4 2 1.053 +4 2 0.713 +4 2 0.752 +4 2 1.236 +4 2 0.722 +4 2 1.043 +4 2 0.656 +4 2 0.788 +4 2 0.839 +4 2 0.667 +4 2 0.743 +4 2 0.847 +4 2 0.999 +4 2 0.61 +4 2 0.789 +4 2 1.02 +4 2 0.758 +4 2 0.898 +4 2 0.957 +4 2 0.907 +4 2 0.995 +4 2 0.829 +4 2 0.778 +4 2 0.519 +4 2 0.835 +4 2 0.943 +4 2 0.967 +4 2 0.755 +4 2 1.33 +4 2 0.911 +4 2 0.878 +4 2 1.163 +4 2 0.73 +5 1 0.73 +5 1 1.464 +5 1 0.805 +5 1 1.191 +5 1 0.604 +5 1 0.771 +5 1 0.874 +5 1 0.859 +5 1 0.654 +5 1 0.806 +5 1 0.645 +5 1 0.946 +5 1 1.035 +5 1 0.531 +5 1 1.075 +5 1 0.626 +5 1 0.89 +5 1 0.934 +5 1 0.769 +5 1 0.701 +5 1 0.833 +5 1 0.887 +5 1 0.985 +5 1 0.545 +5 1 0.584 +5 1 1.13 +5 1 1.026 +5 1 0.886 +5 1 0.946 +5 1 0.993 +5 1 0.498 +5 1 1.042 +5 1 0.725 +5 1 0.845 +5 1 0.754 +5 1 0.983 +5 1 0.745 +5 1 0.903 +5 1 0.739 +5 1 0.643 +5 1 1.068 +5 1 0.952 +5 1 1.22 +5 1 0.815 +5 1 1.046 +5 1 1.304 +5 1 0.756 +5 1 0.617 +5 1 0.763 +5 1 0.767 +5 2 0.886 +5 2 1.312 +5 2 0.796 +5 2 0.933 +5 2 0.813 +5 2 0.86 +5 2 0.921 +5 2 1.185 +5 2 0.88 +5 2 1.013 +5 2 1.03 +5 2 1.066 +5 2 0.755 +5 2 1.282 +5 2 0.787 +5 2 0.836 +5 2 1.209 +5 2 1.174 +5 2 0.68 +5 2 0.71 +5 2 0.646 +5 2 0.892 +5 2 0.889 +5 2 0.932 +5 2 0.974 +5 2 0.75 +5 2 0.693 +5 2 1.096 +5 2 1.023 +5 2 0.628 +5 2 0.838 +5 2 0.706 +5 2 0.569 +5 2 0.886 +5 2 0.841 +5 2 0.837 +5 2 0.9 +5 2 1.057 +5 2 0.897 +5 2 0.748 +5 2 0.73 +5 2 0.831 +5 2 0.92 +5 2 0.686 +5 2 0.821 +5 2 1.08 +5 2 0.835 +5 2 0.735 +5 2 0.805 +5 2 1.121 +6 1 1.015 +6 1 1.209 +6 1 0.919 +6 1 0.981 +6 1 0.785 +6 1 1.029 +6 1 0.794 +6 1 0.659 +6 1 0.917 +6 1 1.465 +6 1 1.08 +6 1 1.186 +6 1 0.968 +6 1 0.776 +6 1 0.849 +6 1 0.836 +6 1 0.8 +6 1 1.054 +6 1 0.688 +6 1 1.098 +6 1 1.098 +6 1 0.688 +6 1 1.037 +6 1 1.68 +6 1 0.785 +6 1 1.092 +6 1 0.748 +6 1 1.17 +6 1 0.943 +6 1 1.351 +6 1 0.654 +6 1 0.879 +6 1 0.79 +6 1 0.85 +6 1 0.773 +6 1 0.74 +6 1 1.022 +6 1 0.703 +6 1 1.291 +6 1 0.689 +6 1 0.911 +6 1 1.01 +6 1 1.024 +6 1 0.83 +6 1 0.906 +6 1 1.125 +6 1 0.654 +6 1 0.748 +6 1 0.959 +6 1 0.805 +6 2 1.352 +6 2 1.125 +6 2 0.968 +6 2 0.684 +6 2 0.957 +6 2 0.883 +6 2 0.929 +6 2 0.731 +6 2 1.076 +6 2 0.753 +6 2 0.902 +6 2 1.045 +6 2 0.795 +6 2 1.099 +6 2 0.711 +6 2 0.544 +6 2 1.067 +6 2 1.174 +6 2 0.889 +6 2 1.077 +6 2 0.735 +6 2 0.923 +6 2 0.63 +6 2 1.285 +6 2 1.549 +6 2 1.249 +6 2 0.945 +6 2 0.944 +6 2 0.683 +6 2 1.159 +6 2 0.905 +6 2 0.818 +6 2 0.697 +6 2 0.887 +6 2 0.784 +6 2 0.867 +6 2 0.725 +6 2 1.476 +6 2 0.948 +6 2 1.249 +6 2 0.562 +6 2 0.856 +6 2 0.814 +6 2 0.725 +6 2 1.419 +6 2 0.697 +6 2 1.028 +6 2 1.176 +6 2 0.993 +6 2 0.78 +7 1 1.023 +7 1 0.852 +7 1 0.658 +7 1 0.62 +7 1 1.379 +7 1 0.71 +7 1 0.572 +7 1 0.927 +7 1 0.88 +7 1 0.624 +7 1 0.563 +7 1 0.799 +7 1 1.075 +7 1 0.95 +7 1 0.738 +7 1 0.688 +7 1 0.872 +7 1 0.849 +7 1 0.948 +7 1 0.753 +7 1 1.012 +7 1 0.689 +7 1 0.763 +7 1 0.974 +7 1 1.035 +7 1 0.564 +7 1 0.84 +7 1 0.943 +7 1 0.613 +7 1 0.915 +7 1 0.689 +7 1 1.043 +7 1 0.928 +7 1 0.981 +7 1 0.842 +7 1 1.004 +7 1 1.143 +7 1 1.335 +7 1 0.815 +7 1 0.537 +7 1 0.826 +7 1 0.859 +7 1 0.792 +7 1 0.934 +7 1 1.041 +7 1 0.734 +7 1 0.769 +7 1 0.898 +7 1 0.729 +7 1 0.837 +7 2 0.589 +7 2 0.688 +7 2 0.661 +7 2 0.726 +7 2 0.751 +7 2 0.957 +7 2 1.11 +7 2 0.746 +7 2 0.705 +7 2 0.699 +7 2 0.797 +7 2 0.829 +7 2 0.981 +7 2 0.814 +7 2 0.578 +7 2 0.857 +7 2 1.171 +7 2 1.172 +7 2 0.736 +7 2 0.634 +7 2 1.659 +7 2 0.843 +7 2 0.855 +7 2 0.966 +7 2 0.627 +7 2 0.745 +7 2 0.635 +7 2 0.751 +7 2 0.899 +7 2 0.656 +7 2 1.007 +7 2 0.936 +7 2 0.719 +7 2 0.922 +7 2 1.047 +7 2 1.133 +7 2 0.833 +7 2 0.856 +7 2 0.858 +7 2 1.252 +7 2 1.152 +7 2 1.07 +7 2 0.82 +7 2 0.955 +7 2 0.962 +7 2 0.699 +7 2 0.614 +7 2 1.019 +7 2 0.636 +7 2 0.875 +8 1 0.778 +8 1 0.833 +8 1 0.768 +8 1 0.639 +8 1 0.918 +8 1 1.104 +8 1 0.896 +8 1 0.522 +8 1 1.014 +8 1 0.729 +8 1 0.826 +8 1 0.844 +8 1 0.723 +8 1 0.726 +8 1 0.925 +8 1 0.861 +8 1 0.919 +8 1 1.308 +8 1 0.852 +8 1 0.771 +8 1 0.502 +8 1 1.423 +8 1 0.67 +8 1 1.305 +8 1 0.799 +8 1 1.05 +8 1 0.721 +8 1 0.823 +8 1 0.772 +8 1 0.71 +8 1 0.72 +8 1 0.924 +8 1 0.708 +8 1 0.514 +8 1 0.709 +8 1 0.829 +8 1 0.843 +8 1 0.843 +8 1 0.542 +8 1 0.798 +8 1 0.914 +8 1 0.984 +8 1 0.704 +8 1 0.691 +8 1 1.037 +8 1 0.544 +8 1 0.676 +8 1 0.814 +8 1 0.548 +8 1 0.783 +8 2 1.233 +8 2 0.783 +8 2 0.739 +8 2 0.871 +8 2 0.739 +8 2 0.943 +8 2 0.964 +8 2 0.784 +8 2 0.62 +8 2 0.605 +8 2 0.693 +8 2 0.939 +8 2 0.544 +8 2 0.55 +8 2 0.685 +8 2 0.855 +8 2 0.651 +8 2 0.96 +8 2 0.843 +8 2 0.756 +8 2 0.944 +8 2 0.854 +8 2 0.714 +8 2 0.824 +8 2 0.907 +8 2 0.848 +8 2 0.684 +8 2 0.952 +8 2 1.024 +8 2 0.833 +8 2 0.809 +8 2 0.771 +8 2 1.33 +8 2 0.833 +8 2 0.758 +8 2 0.501 +8 2 0.58 +8 2 0.771 +8 2 0.82 +8 2 0.833 +8 2 0.945 +8 2 0.752 +8 2 1.04 +8 2 0.65 +8 2 0.617 +8 2 0.615 +8 2 0.927 +8 2 0.77 +8 2 0.938 +8 2 0.74 +9 1 0.677 +9 1 0.708 +9 1 0.542 +9 1 0.608 +9 1 0.58 +9 1 0.971 +9 1 0.676 +9 1 0.911 +9 1 1.088 +9 1 0.734 +9 1 0.812 +9 1 0.551 +9 1 0.648 +9 1 0.773 +9 1 0.815 +9 1 0.655 +9 1 1.487 +9 1 0.695 +9 1 0.774 +9 1 0.882 +9 1 0.759 +9 1 0.67 +9 1 0.968 +9 1 1.116 +9 1 0.759 +9 1 0.864 +9 1 0.748 +9 1 0.962 +9 1 0.609 +9 1 1.345 +9 1 0.675 +9 1 0.578 +9 1 0.71 +9 1 0.788 +9 1 1.118 +9 1 0.938 +9 1 0.787 +9 1 0.585 +9 1 0.642 +9 1 0.738 +9 1 1.433 +9 1 0.542 +9 1 0.989 +9 1 0.685 +9 1 1.131 +9 1 0.611 +9 1 0.788 +9 1 0.616 +9 1 0.936 +9 1 1.079 +9 2 1.314 +9 2 0.977 +9 2 1.277 +9 2 1.093 +9 2 0.789 +9 2 0.905 +9 2 0.665 +9 2 0.78 +9 2 1.086 +9 2 0.919 +9 2 0.901 +9 2 0.656 +9 2 0.715 +9 2 0.692 +9 2 0.888 +9 2 0.662 +9 2 0.924 +9 2 0.647 +9 2 1.272 +9 2 0.902 +9 2 0.701 +9 2 0.857 +9 2 0.753 +9 2 0.883 +9 2 0.858 +9 2 0.659 +9 2 0.688 +9 2 0.869 +9 2 1.209 +9 2 1.049 +9 2 0.712 +9 2 0.984 +9 2 0.804 +9 2 0.869 +9 2 0.861 +9 2 1.562 +9 2 0.638 +9 2 0.831 +9 2 0.575 +9 2 0.93 +9 2 1.052 +9 2 1.15 +9 2 0.561 +9 2 0.892 +9 2 1.195 +9 2 0.743 +9 2 0.776 +9 2 0.806 +9 2 0.882 +9 2 0.947 +10 1 1.053 +10 1 0.759 +10 1 0.809 +10 1 1.435 +10 1 0.852 +10 1 0.807 +10 1 0.597 +10 1 0.775 +10 1 0.74 +10 1 0.773 +10 1 0.688 +10 1 0.673 +10 1 0.669 +10 1 0.741 +10 1 1.067 +10 1 0.986 +10 1 0.719 +10 1 0.563 +10 1 0.653 +10 1 0.705 +10 1 0.792 +10 1 0.677 +10 1 1.259 +10 1 0.732 +10 1 0.611 +10 1 0.752 +10 1 0.634 +10 1 0.802 +10 1 0.815 +10 1 0.838 +10 1 0.569 +10 1 0.813 +10 1 0.829 +10 1 0.589 +10 1 0.964 +10 1 0.925 +10 1 1.362 +10 1 0.802 +10 1 0.783 +10 1 0.791 +10 1 0.787 +10 1 0.549 +10 1 0.565 +10 1 0.762 +10 1 0.688 +10 1 0.784 +10 1 0.527 +10 1 0.581 +10 1 0.623 +10 1 0.971 +10 2 0.657 +10 2 0.697 +10 2 0.84 +10 2 0.769 +10 2 0.852 +10 2 1.476 +10 2 0.654 +10 2 0.772 +10 2 0.738 +10 2 1.191 +10 2 0.701 +10 2 0.81 +10 2 0.991 +10 2 0.662 +10 2 1.237 +10 2 0.965 +10 2 0.66 +10 2 0.915 +10 2 0.787 +10 2 0.886 +10 2 0.809 +10 2 1.063 +10 2 0.627 +10 2 0.737 +10 2 0.781 +10 2 0.67 +10 2 0.665 +10 2 0.822 +10 2 0.801 +10 2 0.515 +10 2 1.056 +10 2 0.873 +10 2 1.523 +10 2 0.967 +10 2 0.749 +10 2 1.697 +10 2 1.714 +10 2 0.643 +10 2 0.919 +10 2 0.787 +10 2 0.86 +10 2 0.868 +10 2 0.637 +10 2 0.88 +10 2 1.268 +10 2 0.796 +10 2 0.796 +10 2 1.156 +10 2 1.019 +10 2 0.595 +11 1 0.908 +11 1 1.301 +11 1 1.221 +11 1 0.95 +11 1 1.022 +11 1 0.669 +11 1 0.923 +11 1 0.702 +11 1 0.778 +11 1 1.079 +11 1 0.677 +11 1 0.916 +11 1 0.952 +11 1 0.872 +11 1 1.362 +11 1 0.692 +11 1 0.994 +11 1 0.844 +11 1 0.812 +11 1 0.96 +11 1 0.693 +11 1 0.654 +11 1 0.772 +11 1 1.336 +11 1 0.872 +11 1 0.93 +11 1 0.825 +11 1 0.962 +11 1 0.702 +11 1 1.142 +11 1 0.989 +11 1 0.723 +11 1 0.872 +11 1 1.021 +11 1 0.982 +11 1 1.243 +11 1 0.753 +11 1 1.129 +11 1 1.107 +11 1 0.83 +11 1 0.699 +11 1 0.683 +11 1 0.959 +11 1 0.847 +11 1 1.346 +11 1 0.977 +11 1 0.793 +11 1 0.692 +11 1 0.758 +11 1 0.933 +11 2 0.83 +11 2 1.043 +11 2 0.852 +11 2 0.898 +11 2 0.78 +11 2 1.508 +11 2 0.997 +11 2 0.972 +11 2 0.643 +11 2 1.081 +11 2 0.734 +11 2 0.754 +11 2 1.155 +11 2 0.829 +11 2 0.636 +11 2 1.452 +11 2 0.57 +11 2 1.058 +11 2 1.186 +11 2 0.797 +11 2 1.025 +11 2 1.023 +11 2 1.193 +11 2 1.035 +11 2 0.869 +11 2 1.155 +11 2 1.121 +11 2 0.747 +11 2 0.68 +11 2 0.956 +11 2 0.864 +11 2 0.739 +11 2 0.939 +11 2 0.691 +11 2 0.956 +11 2 0.798 +11 2 1.167 +11 2 1.749 +11 2 0.75 +11 2 1.198 +11 2 1.128 +11 2 0.905 +11 2 0.829 +11 2 1.377 +11 2 0.607 +11 2 0.795 +11 2 0.675 +11 2 1.311 +11 2 0.88 +11 2 0.816 +12 1 1.869 +12 1 0.806 +12 1 0.741 +12 1 0.872 +12 1 0.597 +12 1 0.911 +12 1 0.798 +12 1 0.907 +12 1 0.665 +12 1 0.66 +12 1 0.704 +12 1 0.693 +12 1 1.111 +12 1 1.195 +12 1 0.787 +12 1 0.754 +12 1 0.759 +12 1 0.827 +12 1 0.833 +12 1 0.87 +12 1 0.696 +12 1 0.683 +12 1 1.083 +12 1 0.725 +12 1 0.872 +12 1 0.805 +12 1 0.668 +12 1 0.933 +12 1 0.847 +12 1 1.14 +12 1 0.836 +12 1 0.758 +12 1 0.867 +12 1 0.64 +12 1 0.684 +12 1 0.915 +12 1 0.758 +12 1 0.803 +12 1 0.794 +12 1 0.71 +12 1 0.554 +12 1 0.882 +12 1 0.972 +12 1 0.628 +12 1 1.165 +12 1 0.889 +12 1 1.123 +12 1 0.668 +12 1 0.846 +12 1 0.797 +12 2 1.045 +12 2 0.765 +12 2 0.867 +12 2 0.605 +12 2 0.733 +12 2 0.894 +12 2 0.744 +12 2 0.86 +12 2 0.783 +12 2 1.004 +12 2 1.156 +12 2 0.727 +12 2 0.811 +12 2 1.242 +12 2 0.564 +12 2 0.809 +12 2 1.472 +12 2 1.526 +12 2 0.901 +12 2 0.721 +12 2 0.903 +12 2 0.753 +12 2 1.246 +12 2 0.729 +12 2 0.948 +12 2 1.007 +12 2 0.736 +12 2 1.066 +12 2 0.738 +12 2 1.009 +12 2 1.135 +12 2 0.703 +12 2 1.138 +12 2 0.779 +12 2 0.931 +12 2 0.911 +12 2 0.79 +12 2 0.925 +12 2 0.67 +12 2 0.842 +12 2 1.06 +12 2 0.566 +12 2 0.638 +12 2 0.679 +12 2 0.626 +12 2 0.959 +12 2 0.702 +12 2 0.567 +12 2 0.755 +12 2 0.796 +13 1 0.998 +13 1 0.651 +13 1 1.076 +13 1 0.894 +13 1 0.887 +13 1 0.684 +13 1 1.324 +13 1 0.788 +13 1 0.573 +13 1 0.781 +13 1 0.563 +13 1 0.764 +13 1 0.746 +13 1 0.956 +13 1 1.036 +13 1 0.701 +13 1 0.985 +13 1 1.151 +13 1 0.693 +13 1 0.711 +13 1 0.949 +13 1 0.851 +13 1 0.926 +13 1 1.145 +13 1 0.892 +13 1 1.047 +13 1 0.943 +13 1 0.902 +13 1 0.892 +13 1 1.112 +13 1 0.664 +13 1 0.651 +13 1 0.936 +13 1 0.796 +13 1 0.83 +13 1 0.97 +13 1 0.973 +13 1 0.771 +13 1 0.763 +13 1 0.83 +13 1 1.05 +13 1 0.9 +13 1 1.154 +13 1 0.816 +13 1 1.066 +13 1 1.004 +13 1 0.94 +13 1 0.898 +13 1 0.769 +13 1 0.798 +13 2 0.919 +13 2 0.881 +13 2 1.095 +13 2 0.85 +13 2 0.857 +13 2 0.782 +13 2 0.844 +13 2 0.858 +13 2 0.554 +13 2 0.654 +13 2 0.857 +13 2 0.821 +13 2 0.675 +13 2 0.585 +13 2 0.805 +13 2 1.018 +13 2 1.363 +13 2 0.864 +13 2 1.263 +13 2 0.888 +13 2 0.895 +13 2 0.94 +13 2 0.721 +13 2 0.861 +13 2 1.085 +13 2 0.739 +13 2 0.81 +13 2 0.682 +13 2 0.947 +13 2 0.963 +13 2 1.017 +13 2 0.673 +13 2 0.893 +13 2 0.711 +13 2 0.871 +13 2 1.214 +13 2 0.779 +13 2 1.034 +13 2 0.739 +13 2 0.783 +13 2 0.966 +13 2 0.75 +13 2 0.615 +13 2 1.189 +13 2 0.948 +13 2 0.766 +13 2 0.584 +13 2 1.412 +13 2 2.171 +13 2 0.914 +14 1 0.976 +14 1 1.071 +14 1 0.693 +14 1 0.744 +14 1 0.574 +14 1 0.688 +14 1 0.924 +14 1 0.754 +14 1 0.766 +14 1 0.783 +14 1 0.562 +14 1 0.973 +14 1 0.603 +14 1 0.767 +14 1 0.731 +14 1 0.765 +14 1 1.137 +14 1 0.71 +14 1 0.682 +14 1 0.595 +14 1 0.679 +14 1 0.634 +14 1 0.879 +14 1 0.671 +14 1 0.858 +14 1 0.777 +14 1 0.604 +14 1 0.681 +14 1 0.984 +14 1 0.989 +14 1 1.313 +14 1 0.801 +14 1 0.597 +14 1 0.684 +14 1 0.879 +14 1 1.276 +14 1 0.822 +14 1 1.048 +14 1 0.957 +14 1 0.634 +14 1 0.773 +14 1 1.093 +14 1 0.982 +14 1 0.891 +14 1 0.893 +14 1 0.723 +14 1 0.616 +14 1 1.09 +14 1 0.605 +14 1 0.661 +14 2 0.992 +14 2 0.657 +14 2 0.757 +14 2 0.667 +14 2 0.99 +14 2 0.949 +14 2 0.943 +14 2 0.948 +14 2 0.974 +14 2 0.994 +14 2 0.579 +14 2 0.827 +14 2 0.877 +14 2 1.015 +14 2 0.666 +14 2 0.766 +14 2 0.681 +14 2 1.103 +14 2 1.168 +14 2 1.031 +14 2 0.662 +14 2 0.95 +14 2 1.13 +14 2 0.889 +14 2 0.755 +14 2 0.679 +14 2 0.74 +14 2 1.013 +14 2 0.777 +14 2 0.901 +14 2 1.173 +14 2 0.979 +14 2 1.195 +14 2 0.606 +14 2 0.803 +14 2 0.868 +14 2 0.979 +14 2 0.669 +14 2 1.036 +14 2 0.918 +14 2 0.909 +14 2 0.963 +14 2 0.833 +14 2 1.067 +14 2 0.996 +14 2 0.826 +14 2 1.099 +14 2 0.915 +14 2 1.001 +14 2 0.751 +15 1 1.117 +15 1 0.769 +15 1 0.932 +15 1 0.754 +15 1 0.726 +15 1 0.918 +15 1 0.57 +15 1 0.855 +15 1 0.839 +15 1 0.483 +15 1 0.834 +15 1 0.52 +15 1 0.892 +15 1 0.701 +15 1 0.668 +15 1 0.769 +15 1 1.06 +15 1 0.676 +15 1 0.871 +15 1 0.829 +15 1 0.611 +15 1 0.555 +15 1 0.534 +15 1 0.87 +15 1 0.764 +15 1 1.198 +15 1 0.874 +15 1 0.932 +15 1 1.049 +15 1 0.694 +15 1 0.862 +15 1 0.937 +15 1 1.059 +15 1 0.913 +15 1 0.844 +15 1 0.647 +15 1 0.906 +15 1 0.86 +15 1 0.886 +15 1 0.845 +15 1 0.738 +15 1 0.757 +15 1 0.897 +15 1 0.799 +15 1 0.651 +15 1 0.724 +15 1 0.596 +15 1 0.635 +15 1 0.747 +15 1 0.55 +15 2 0.587 +15 2 1.064 +15 2 0.724 +15 2 0.572 +15 2 0.799 +15 2 1.124 +15 2 0.955 +15 2 0.906 +15 2 1.086 +15 2 0.696 +15 2 0.97 +15 2 0.723 +15 2 0.819 +15 2 1.427 +15 2 1.029 +15 2 0.979 +15 2 0.652 +15 2 0.694 +15 2 1.455 +15 2 0.654 +15 2 0.86 +15 2 1.01 +15 2 1.042 +15 2 1.06 +15 2 0.79 +15 2 0.689 +15 2 0.766 +15 2 0.679 +15 2 0.947 +15 2 1.068 +15 2 1.393 +15 2 0.89 +15 2 0.682 +15 2 1.043 +15 2 1.013 +15 2 0.778 +15 2 0.601 +15 2 0.978 +15 2 1.071 +15 2 0.768 +15 2 0.926 +15 2 0.771 +15 2 0.959 +15 2 0.798 +15 2 0.76 +15 2 0.84 +15 2 0.77 +15 2 0.722 +15 2 0.765 +15 2 0.818 +16 1 0.938 +16 1 1.315 +16 1 0.669 +16 1 0.854 +16 1 1.041 +16 1 1.4 +16 1 0.989 +16 1 0.891 +16 1 0.833 +16 1 0.986 +16 1 1.139 +16 1 0.857 +16 1 0.929 +16 1 0.941 +16 1 1.066 +16 1 1.176 +16 1 0.955 +16 1 0.878 +16 1 1.267 +16 1 0.929 +16 1 1.331 +16 1 0.881 +16 1 1.036 +16 1 0.646 +16 1 0.871 +16 1 0.889 +16 1 0.755 +16 1 0.713 +16 1 1.127 +16 1 1.118 +16 1 0.677 +16 1 0.989 +16 1 0.702 +16 1 0.711 +16 1 1.014 +16 1 0.767 +16 1 1.141 +16 1 0.902 +16 1 1.016 +16 1 0.794 +16 1 0.697 +16 1 1.118 +16 1 0.945 +16 1 0.846 +16 1 0.908 +16 1 1.244 +16 1 0.765 +16 1 0.757 +16 1 0.778 +16 1 0.641 +16 2 1.174 +16 2 1.002 +16 2 1.006 +16 2 0.946 +16 2 0.849 +16 2 0.792 +16 2 1.184 +16 2 0.698 +16 2 1.066 +16 2 0.797 +16 2 1.024 +16 2 0.806 +16 2 0.846 +16 2 1.519 +16 2 1.129 +16 2 0.61 +16 2 0.986 +16 2 0.86 +16 2 0.741 +16 2 1.006 +16 2 0.987 +16 2 0.885 +16 2 1.609 +16 2 0.599 +16 2 1.18 +16 2 0.893 +16 2 1.126 +16 2 0.86 +16 2 0.833 +16 2 0.661 +16 2 0.91 +16 2 1.862 +16 2 1.228 +16 2 1.48 +16 2 1.204 +16 2 1.279 +16 2 1.2 +16 2 1.075 +16 2 0.835 +16 2 0.845 +16 2 0.675 +16 2 0.955 +16 2 1.199 +16 2 1.242 +16 2 0.978 +16 2 0.842 +16 2 2.376 +16 2 1.149 +16 2 1.379 +16 2 0.883 +17 1 0.815 +17 1 0.911 +17 1 1.239 +17 1 0.768 +17 1 1.004 +17 1 0.551 +17 1 0.737 +17 1 0.632 +17 1 1.071 +17 1 0.793 +17 1 0.755 +17 1 1.143 +17 1 1.071 +17 1 0.681 +17 1 0.906 +17 1 0.64 +17 1 0.742 +17 1 1.219 +17 1 1.167 +17 1 1.069 +17 1 0.727 +17 1 0.57 +17 1 0.646 +17 1 1.028 +17 1 0.771 +17 1 0.545 +17 1 0.79 +17 1 1.155 +17 1 0.954 +17 1 0.692 +17 1 0.604 +17 1 0.691 +17 1 0.828 +17 1 1.012 +17 1 0.565 +17 1 1.047 +17 1 0.823 +17 1 0.937 +17 1 0.593 +17 1 0.713 +17 1 0.746 +17 1 1.052 +17 1 1.048 +17 1 0.908 +17 1 1.215 +17 1 0.736 +17 1 1.044 +17 1 0.815 +17 1 0.713 +17 1 1.021 +17 2 1.235 +17 2 1.084 +17 2 0.783 +17 2 0.789 +17 2 1.234 +17 2 0.953 +17 2 1.071 +17 2 0.812 +17 2 1.197 +17 2 0.735 +17 2 1.018 +17 2 0.733 +17 2 0.544 +17 2 0.661 +17 2 0.905 +17 2 1.086 +17 2 0.612 +17 2 0.672 +17 2 1.37 +17 2 0.796 +17 2 0.989 +17 2 0.78 +17 2 0.82 +17 2 0.895 +17 2 0.879 +17 2 0.839 +17 2 0.789 +17 2 0.498 +17 2 1.409 +17 2 1.379 +17 2 0.692 +17 2 0.844 +17 2 1.233 +17 2 1.118 +17 2 1.202 +17 2 0.696 +17 2 1.722 +17 2 0.688 +17 2 1.051 +17 2 0.906 +17 2 0.801 +17 2 0.805 +17 2 0.708 +17 2 1.318 +17 2 0.895 +17 2 0.932 +17 2 0.921 +17 2 0.806 +17 2 0.688 +17 2 0.93 +18 1 0.496 +18 1 0.548 +18 1 0.58 +18 1 0.58 +18 1 0.724 +18 1 1.014 +18 1 0.54 +18 1 0.775 +18 1 0.859 +18 1 0.589 +18 1 0.7 +18 1 0.844 +18 1 0.673 +18 1 0.678 +18 1 0.754 +18 1 0.699 +18 1 0.636 +18 1 0.689 +18 1 1.088 +18 1 0.854 +18 1 0.596 +18 1 0.564 +18 1 0.66 +18 1 0.949 +18 1 0.752 +18 1 0.619 +18 1 0.856 +18 1 0.689 +18 1 0.576 +18 1 0.779 +18 1 0.995 +18 1 0.775 +18 1 0.736 +18 1 0.624 +18 1 0.798 +18 1 0.58 +18 1 0.529 +18 1 0.702 +18 1 0.703 +18 1 1.233 +18 1 0.566 +18 1 0.733 +18 1 0.841 +18 1 0.889 +18 1 0.706 +18 1 0.614 +18 1 0.699 +18 1 1.104 +18 1 0.783 +18 1 0.499 +18 2 1.042 +18 2 0.845 +18 2 0.746 +18 2 0.748 +18 2 0.728 +18 2 0.793 +18 2 0.678 +18 2 0.797 +18 2 0.625 +18 2 0.784 +18 2 0.964 +18 2 0.839 +18 2 0.947 +18 2 0.608 +18 2 0.76 +18 2 0.86 +18 2 0.61 +18 2 1.08 +18 2 0.614 +18 2 0.778 +18 2 0.775 +18 2 0.77 +18 2 0.719 +18 2 0.828 +18 2 0.614 +18 2 0.587 +18 2 0.659 +18 2 0.742 +18 2 1 +18 2 1.086 +18 2 0.804 +18 2 0.815 +18 2 0.714 +18 2 0.758 +18 2 0.576 +18 2 0.799 +18 2 0.674 +18 2 0.807 +18 2 0.699 +18 2 0.658 +18 2 0.718 +18 2 0.697 +18 2 0.961 +18 2 0.785 +18 2 0.825 +18 2 0.592 +18 2 1.061 +18 2 0.777 +18 2 0.634 +18 2 0.802 +19 1 1.022 +19 1 0.628 +19 1 1.262 +19 1 0.804 +19 1 1.089 +19 1 0.846 +19 1 0.774 +19 1 0.58 +19 1 0.662 +19 1 0.825 +19 1 1.012 +19 1 0.576 +19 1 1.162 +19 1 1.169 +19 1 0.657 +19 1 0.928 +19 1 0.671 +19 1 0.81 +19 1 1.037 +19 1 1.022 +19 1 0.696 +19 1 0.765 +19 1 0.679 +19 1 0.9 +19 1 0.609 +19 1 0.512 +19 1 1.191 +19 1 1.48 +19 1 0.754 +19 1 0.995 +19 1 0.831 +19 1 1.192 +19 1 0.947 +19 1 0.872 +19 1 0.584 +19 1 1.078 +19 1 0.771 +19 1 0.626 +19 1 0.796 +19 1 0.81 +19 1 1.072 +19 1 0.654 +19 1 0.738 +19 1 1.197 +19 1 1.157 +19 1 1.1 +19 1 1.253 +19 1 0.872 +19 1 0.735 +19 1 0.947 +19 2 1.153 +19 2 1.67 +19 2 0.596 +19 2 0.948 +19 2 1.04 +19 2 0.878 +19 2 0.641 +19 2 1.063 +19 2 0.748 +19 2 1.003 +19 2 1.109 +19 2 1.223 +19 2 0.641 +19 2 1.16 +19 2 0.752 +19 2 0.675 +19 2 1.233 +19 2 1.179 +19 2 0.841 +19 2 1.068 +19 2 0.736 +19 2 0.858 +19 2 0.87 +19 2 0.834 +19 2 1.061 +19 2 1.308 +19 2 0.802 +19 2 0.882 +19 2 1.344 +19 2 0.825 +19 2 0.537 +19 2 1.005 +19 2 0.732 +19 2 0.715 +19 2 1.268 +19 2 1.687 +19 2 0.709 +19 2 1.145 +19 2 0.87 +19 2 0.919 +19 2 1.203 +19 2 0.934 +19 2 0.737 +19 2 0.799 +19 2 1.048 +19 2 0.56 +19 2 1.164 +19 2 0.64 +19 2 0.893 +19 2 0.851 +20 1 1.045 +20 1 0.806 +20 1 0.791 +20 1 0.905 +20 1 0.655 +20 1 0.742 +20 1 1.015 +20 1 0.902 +20 1 0.603 +20 1 0.892 +20 1 0.592 +20 1 0.684 +20 1 1.024 +20 1 0.515 +20 1 0.554 +20 1 1.047 +20 1 0.656 +20 1 1.032 +20 1 0.747 +20 1 0.85 +20 1 0.93 +20 1 0.677 +20 1 0.726 +20 1 0.71 +20 1 1.569 +20 1 0.795 +20 1 0.859 +20 1 0.72 +20 1 0.735 +20 1 1.067 +20 1 0.721 +20 1 0.777 +20 1 0.84 +20 1 0.707 +20 1 1.24 +20 1 0.587 +20 1 1.258 +20 1 0.719 +20 1 1.062 +20 1 0.535 +20 1 0.962 +20 1 0.944 +20 1 0.604 +20 1 0.662 +20 1 0.807 +20 1 1.007 +20 1 0.662 +20 1 0.738 +20 1 1.121 +20 1 0.619 +20 2 1.029 +20 2 0.912 +20 2 0.655 +20 2 0.714 +20 2 0.989 +20 2 0.871 +20 2 1.162 +20 2 0.724 +20 2 0.587 +20 2 1.055 +20 2 0.723 +20 2 0.846 +20 2 1.255 +20 2 0.78 +20 2 1.2 +20 2 0.657 +20 2 1.024 +20 2 0.871 +20 2 0.704 +20 2 0.634 +20 2 0.838 +20 2 0.872 +20 2 0.877 +20 2 0.932 +20 2 0.746 +20 2 0.738 +20 2 0.869 +20 2 0.733 +20 2 1.102 +20 2 0.856 +20 2 0.722 +20 2 0.578 +20 2 0.718 +20 2 1.371 +20 2 0.73 +20 2 0.691 +20 2 0.958 +20 2 0.911 +20 2 0.981 +20 2 0.775 +20 2 1.075 +20 2 0.647 +20 2 0.815 +20 2 0.709 +20 2 0.964 +20 2 0.848 +20 2 1.072 +20 2 1.376 +20 2 0.85 +20 2 0.734 +21 1 0.635 +21 1 0.707 +21 1 0.736 +21 1 1.196 +21 1 0.601 +21 1 0.604 +21 1 0.687 +21 1 0.848 +21 1 0.895 +21 1 0.625 +21 1 0.767 +21 1 0.74 +21 1 0.978 +21 1 0.953 +21 1 0.7 +21 1 0.754 +21 1 0.861 +21 1 0.55 +21 1 0.7 +21 1 0.846 +21 1 0.672 +21 1 0.737 +21 1 0.743 +21 1 0.646 +21 1 0.615 +21 1 0.716 +21 1 0.695 +21 1 0.898 +21 1 1.062 +21 1 0.744 +21 1 0.813 +21 1 0.735 +21 1 0.851 +21 1 0.782 +21 1 0.785 +21 1 0.959 +21 1 0.616 +21 1 1.041 +21 1 0.804 +21 1 0.775 +21 1 0.667 +21 1 0.721 +21 1 0.809 +21 1 0.517 +21 1 0.662 +21 1 0.848 +21 1 0.703 +21 1 0.637 +21 1 0.657 +21 1 0.785 +21 2 0.578 +21 2 0.969 +21 2 0.531 +21 2 0.714 +21 2 0.674 +21 2 0.619 +21 2 0.638 +21 2 0.838 +21 2 0.773 +21 2 0.744 +21 2 0.519 +21 2 0.61 +21 2 0.771 +21 2 0.663 +21 2 0.673 +21 2 1.012 +21 2 0.824 +21 2 0.642 +21 2 0.719 +21 2 0.746 +21 2 0.689 +21 2 0.652 +21 2 0.784 +21 2 0.939 +21 2 0.834 +21 2 0.76 +21 2 0.865 +21 2 0.951 +21 2 0.77 +21 2 0.879 +21 2 0.63 +21 2 0.752 +21 2 0.726 +21 2 0.828 +21 2 0.859 +21 2 0.772 +21 2 0.677 +21 2 0.656 +21 2 0.844 +21 2 1.093 +21 2 0.674 +21 2 0.731 +21 2 0.854 +21 2 0.706 +21 2 0.815 +21 2 0.785 +21 2 0.676 +21 2 0.96 +21 2 0.963 +21 2 1.006 +22 1 1.057 +22 1 0.707 +22 1 0.713 +22 1 0.832 +22 1 0.906 +22 1 0.731 +22 1 0.719 +22 1 0.691 +22 1 1.116 +22 1 0.502 +22 1 0.758 +22 1 0.792 +22 1 0.635 +22 1 0.856 +22 1 0.544 +22 1 0.979 +22 1 0.571 +22 1 0.525 +22 1 0.672 +22 1 0.814 +22 1 0.687 +22 1 0.699 +22 1 0.846 +22 1 0.635 +22 1 0.771 +22 1 0.878 +22 1 1.161 +22 1 0.875 +22 1 1.185 +22 1 0.869 +22 1 0.785 +22 1 0.521 +22 1 0.617 +22 1 0.735 +22 1 0.923 +22 1 0.734 +22 1 0.888 +22 1 0.635 +22 1 0.741 +22 1 0.824 +22 1 0.728 +22 1 0.805 +22 1 0.684 +22 1 0.854 +22 1 0.772 +22 1 0.778 +22 1 0.546 +22 1 0.684 +22 1 0.588 +22 1 0.577 +22 2 0.752 +22 2 0.808 +22 2 0.893 +22 2 1.087 +22 2 0.927 +22 2 1.065 +22 2 0.747 +22 2 0.782 +22 2 1.085 +22 2 0.837 +22 2 0.598 +22 2 0.699 +22 2 1.064 +22 2 0.734 +22 2 0.903 +22 2 0.84 +22 2 0.751 +22 2 0.775 +22 2 0.916 +22 2 0.878 +22 2 1.127 +22 2 0.801 +22 2 0.689 +22 2 0.869 +22 2 0.987 +22 2 1.494 +22 2 0.757 +22 2 0.779 +22 2 1.031 +22 2 1.141 +22 2 0.726 +22 2 0.978 +22 2 0.741 +22 2 0.683 +22 2 0.968 +22 2 0.857 +22 2 0.915 +22 2 0.738 +22 2 1.306 +22 2 0.978 +22 2 0.771 +22 2 0.987 +22 2 0.651 +22 2 0.812 +22 2 1.178 +22 2 0.803 +22 2 1.039 +22 2 0.797 +22 2 0.54 +22 2 0.695 +23 1 0.784 +23 1 1.044 +23 1 0.664 +23 1 0.794 +23 1 0.62 +23 1 0.614 +23 1 0.641 +23 1 1.024 +23 1 0.923 +23 1 0.852 +23 1 0.962 +23 1 0.686 +23 1 0.885 +23 1 0.782 +23 1 0.61 +23 1 0.635 +23 1 0.756 +23 1 0.782 +23 1 0.7 +23 1 0.616 +23 1 0.516 +23 1 0.82 +23 1 0.704 +23 1 0.843 +23 1 0.561 +23 1 0.589 +23 1 0.731 +23 1 0.573 +23 1 0.524 +23 1 0.89 +23 1 0.914 +23 1 0.613 +23 1 0.707 +23 1 0.601 +23 1 0.801 +23 1 0.744 +23 1 0.631 +23 1 0.642 +23 1 0.609 +23 1 0.822 +23 1 0.847 +23 1 0.811 +23 1 0.634 +23 1 0.54 +23 1 0.84 +23 1 0.721 +23 1 0.742 +23 1 0.943 +23 1 0.628 +23 1 0.969 +23 2 0.729 +23 2 0.686 +23 2 0.761 +23 2 0.868 +23 2 0.761 +23 2 0.661 +23 2 0.749 +23 2 0.503 +23 2 0.715 +23 2 0.881 +23 2 0.767 +23 2 0.93 +23 2 0.887 +23 2 0.921 +23 2 0.923 +23 2 0.57 +23 2 0.796 +23 2 1.176 +23 2 0.719 +23 2 0.88 +23 2 0.821 +23 2 0.902 +23 2 0.75 +23 2 0.695 +23 2 0.808 +23 2 0.833 +23 2 0.764 +23 2 0.801 +23 2 0.872 +23 2 0.677 +23 2 1.038 +23 2 1.37 +23 2 1.131 +23 2 0.722 +23 2 0.562 +23 2 0.805 +23 2 0.974 +23 2 0.95 +23 2 0.622 +23 2 0.635 +23 2 0.819 +23 2 0.917 +23 2 0.972 +23 2 0.959 +23 2 0.653 +23 2 0.613 +23 2 0.545 +23 2 0.891 +23 2 0.962 +23 2 0.857 +24 1 0.619 +24 1 1.099 +24 1 0.706 +24 1 1.161 +24 1 0.86 +24 1 1 +24 1 0.818 +24 1 0.751 +24 1 0.624 +24 1 0.68 +24 1 0.754 +24 1 0.81 +24 1 0.756 +24 1 0.734 +24 1 0.792 +24 1 0.684 +24 1 0.683 +24 1 0.577 +24 1 0.921 +24 1 0.769 +24 1 0.748 +24 1 0.656 +24 1 0.723 +24 1 0.616 +24 1 0.62 +24 1 0.536 +24 1 0.951 +24 1 0.782 +24 1 0.612 +24 1 0.994 +24 1 0.874 +24 1 0.899 +24 1 0.727 +24 1 0.698 +24 1 0.746 +24 1 0.832 +24 1 0.911 +24 1 1.105 +24 1 0.686 +24 1 0.624 +24 1 0.778 +24 1 1.63 +24 1 0.697 +24 1 0.989 +24 1 0.724 +24 1 0.69 +24 1 0.66 +24 1 0.729 +24 1 1.12 +24 1 0.813 +24 2 0.905 +24 2 0.984 +24 2 1.354 +24 2 0.969 +24 2 0.61 +24 2 0.655 +24 2 0.593 +24 2 0.488 +24 2 1.102 +24 2 0.729 +24 2 0.886 +24 2 1.072 +24 2 0.727 +24 2 0.787 +24 2 0.877 +24 2 0.852 +24 2 0.689 +24 2 0.959 +24 2 0.918 +24 2 0.761 +24 2 0.633 +24 2 0.937 +24 2 1.141 +24 2 1.127 +24 2 0.992 +24 2 0.731 +24 2 0.724 +24 2 0.715 +24 2 0.742 +24 2 0.954 +24 2 0.858 +24 2 0.566 +24 2 0.566 +24 2 0.806 +24 2 0.838 +24 2 0.528 +24 2 0.683 +24 2 0.815 +24 2 1.151 +24 2 0.552 +24 2 0.629 +24 2 0.65 +24 2 0.843 +24 2 0.873 +24 2 0.756 +24 2 0.59 +24 2 0.709 +24 2 0.719 +24 2 0.775 +24 2 1.2 +25 1 0.668 +25 1 0.779 +25 1 0.664 +25 1 0.602 +25 1 0.883 +25 1 0.623 +25 1 1.515 +25 1 0.782 +25 1 0.776 +25 1 0.756 +25 1 1.189 +25 1 0.889 +25 1 0.727 +25 1 0.61 +25 1 0.624 +25 1 0.654 +25 1 1.014 +25 1 0.737 +25 1 0.658 +25 1 0.916 +25 1 1.047 +25 1 0.666 +25 1 0.699 +25 1 0.826 +25 1 0.766 +25 1 0.838 +25 1 1.15 +25 1 0.757 +25 1 0.723 +25 1 0.853 +25 1 0.759 +25 1 0.881 +25 1 0.731 +25 1 0.845 +25 1 0.57 +25 1 0.769 +25 1 0.689 +25 1 0.608 +25 1 0.704 +25 1 0.831 +25 1 0.782 +25 1 0.895 +25 1 0.948 +25 1 0.923 +25 1 0.716 +25 1 0.593 +25 1 0.723 +25 1 1.002 +25 1 0.747 +25 1 0.563 +25 2 0.912 +25 2 0.869 +25 2 0.748 +25 2 0.848 +25 2 1.133 +25 2 1.112 +25 2 0.739 +25 2 0.817 +25 2 0.61 +25 2 0.7 +25 2 1.341 +25 2 1.171 +25 2 0.776 +25 2 0.705 +25 2 0.62 +25 2 1.385 +25 2 0.837 +25 2 0.719 +25 2 1.052 +25 2 0.651 +25 2 0.965 +25 2 1.154 +25 2 0.779 +25 2 1.157 +25 2 0.945 +25 2 0.707 +25 2 0.93 +25 2 0.703 +25 2 0.728 +25 2 0.976 +25 2 0.736 +25 2 0.811 +25 2 1.036 +25 2 0.638 +25 2 1.201 +25 2 1.354 +25 2 0.939 +25 2 0.898 +25 2 0.733 +25 2 0.912 +25 2 0.732 +25 2 0.87 +25 2 0.705 +25 2 0.979 +25 2 0.957 +25 2 1.097 +25 2 1.332 +25 2 0.711 +25 2 1.023 +25 2 0.613 \ No newline at end of file diff --git a/data-raw/es_info.R b/data-raw/es_info.R index b4d6cd570..88044de67 100644 --- a/data-raw/es_info.R +++ b/data-raw/es_info.R @@ -4,6 +4,11 @@ es_info <- tibble::tribble( "Cohens_d", "Cohen's d", NA, "twotail", -Inf, Inf, 0, "Hedges_g", "Hedges' g", NA, "twotail", -Inf, Inf, 0, "Glass_delta", "Glass' delta", "Glass' \u0394", "twotail", -Inf, Inf, 0, + "d_rm", "d (rm)", "d\u1D63\u2098", "twotail", -Inf, Inf, 0, + "d_av", "d (av)", "d\u2090\u1D65", "twotail", -Inf, Inf, 0, + "d_z", "d (z)", NA, "twotail", -Inf, Inf, 0, + "Beckers_d", "Becker's d", NA, "twotail", -Inf, Inf, 0, + "d_r", "d (r)", "d\u1D63", "twotail", -Inf, Inf, 0, "Mahalanobis_D", "Mahalanobis' D", NA, "onetail", 0, Inf, 0, "Means_ratio", "Means Ratio", NA, "twotail", 0, Inf, 1, "Means_ratio_adjusted", "Means Ratio (adj.)", NA, "twotail", 0, Inf, 1, diff --git a/data/rouder2016.rdata b/data/rouder2016.rdata new file mode 100644 index 0000000000000000000000000000000000000000..ebab872aa26563bc3861e20d96e99fd69e083ec2 GIT binary patch literal 6442 zcma);Yfuts)W_THVwR94oyY2}ug7razvUdTuR6{xJV%v)wy zB2;dfdB5TtwZ;!BlYme;NaK==Txz*vaQ&ffOW#pRkm$DAL*=LgPc;dc^XEN_>ac5@d zx+5tuh@Z^&-92!BT}aBAlDBW)rfg}S8O0%3P{p_+|6biViZ8{cfR!L|8uXN>AZ{GR zR_VyonncR9LM{W*HJoi|;Ly+zv>r7xan9MOJdiNjpmygfyZoZLL(rQ+I-rlpdKlWQ zmokSO#E@9-P$@z}AJ1<;9I-zj`+)(@!1(}h|92pK5Pq?+g73okD?couKid4S z=F|^i^=w3OS=hi2^}v8*fFa_>{PR8q>?Ze{5xVTsL$H+Uvsw0GAAEE+*+TQR9vChC z@C$r&KG|7$ePSk+*Vn7O`KRmHCQ6_+C7n??!s~mWyqS>r5N)0Mf76+^CB0Y-!$}Um zHr?N7n0hZ@kpc+u62sSjzWRi=%@xOpsMZmw|Q_UM!O z&8z*hR=Lwdm37yhy|IB^vcH^n2k8n|a2aa=!^t9(z9;ksN^h*I4$ocQ3AW2L`+;7_i)1^LEQICri*!DF_RQa6sBEqT4j5P{#s)sn!kdjlxl z@Wcj6r|?)g_4%qVo%o%fF#5+b+3v-$XPcOzozli~nBlQET%K0sXD?jjo*D}MV*KBW zW{rsO#Az;6``nAT{)F4S)nfBUH6J{u^I!(Y5oBJQO8&Yx|K{W_zLz1qi+mwbYc4i0 z4ji`WvW1^Ab-JeI1k6R#A92U~b+E7;PD%<6jqbr-zE zS+m9nyp1^E711#c-cu<1Tk;h;f%LE-#ff02>@XvCmnh8CVNcPZh$Q z?ogY>C01A{U`HrsoIXvvu*>}4le=h5dRW?`rq%QN@4W(u(C41Z%)0xJ%?D_2-X-l| z64ZXvaC-hK7iy}uW~3FKW6+{zZ`-MR*Nt`!QH0MXxn&V&qZAhZEi+gWub}%1ijrY* zEgu8skmrj8pNgbe>x1w+WLSK%SiGov)vWt~`0GQL7WlWrLR5=%Dal4YNbp+uTlmNL z<2lZ>Khk=oD-63odr@#VE33ClEdRNN!OaGPH%|>>(YtOTy>MDWCp(Aj4{z1mPW#z3 zY!F&k5X9)Q1m#$+*b3xNQJVr7gKSd$mNFSUaM#|sn<b*;XjR?Xj>KWC^}^q+-9uCpplz1bI6k@Dj{}Tn?+v z(p0RmL#8SOgE;+A*UPi#i**0YPWV6Sczd+mEK zM_#sslH``~T27WGo1*#Ve~x88Z7*0UM1%mg&8c2N?!x>rH5aeWz8tW`H~gW0Q0<0k zTLx7O8I+t^%9EGw*fwj;Iyy+A@Q{0to{e&etpHEX-??(&N6p9#4NyPpcT zLxw&8P}<0L*LFWu#}nK~w|2@}`rIuan3lR%Pbt3zKG<67D0i69p{_@y1g0fhDr;Np z@0TU(YBDve8(4TdJph4U#UteW*5tGfoLpo(38&3-;@$%Cz~zM z&1@Zdu^6hb%8)MnmHSKl43Fr*n}2oo1K5ZwJl~DK zJn>AukvcVE8FNOn9&Dj}mIxjB%s8!YQ#47|(!d;q9Rz!L@B!ps`r6Fu8@-@HrNUb8 z+U7Nl{#A?rgB%2Q;OUoX0>Z@;rSj7YI@kKIl!S>dnJ$-ZZ>F|({1kJuht{95_|N!w zYhZ^NHp-23l)V{4uXiyw_)_#PKf`S&*w$FbTJVw?5A(G9gR6j*tQhe-wVP=bTBuEah1J|Y@3nc@^ivovd|r;d!pmJfE>!U5_e&oj0njS zURUsK?2ePtpB8%+8z){Vui|$QP6ORAvG;Yq5hZC5KDXP$J`3GIvvxk?*|7>=GI35V zT>;-4{gBP~lhD_~o*C^aHOm#>f0frovS=La&wh-RaMPvuu8pWZ1Dj z+;s=O1~Xr?#s>swzGmigaj;U`hcQ(dY5p5$EF98x>fUjC)Bw!}WXG;a?^H_0f|c&o zC(Rq>ZFZIglhU4K8UqRCu1v&lw>PyYagXF@aP~Y(w$xwJ^(c2DXUr%a?m}=EBhiEG z`1|~6iWLSsWV4@Jk+%^KzYpI~Qrv>&8dtt26eF4cilMC45CE_;6e3TkXS6}bbUb^pJVz(10?O5AXXXEe_ zWh#n>UWVN3b&&m0X2gqF4nF|;1r`CC>x-{Y*P1vSpYJSw9cw0p(TuR-tv*6Wk4YnZ zt|__{p1$O;*algX@fhs~j;=sRtwblC7uY-G@D=dF1wK^HbwC~ycRDXNcqD#y&2wQi zM;>-rpiiUt;4|nfpGhxXNj;}CdK%18_`93IE-3n0&h08o$qnuq_zsh!xKu?RBMk;vZ#Z=3VkH*!0fd0Ug9=ePYp^aYxQgS zMM$?3A_ni(7jbia__KYG6Qrvj>7{`6#JI(XX~(e5!vTk_Ba@71g{NHqjOI_Yb!q$X znV7eUrG;DI!dA&`YZo*0j=?5O6uhM|YDzZeJz7DdZ}6I?^MH#xFxGK@lDp|iwx_9& z8DTsK;UUOP1L8Dfj;!P$;Y{tTm7q!jv66d-j@*inZWo&C(rAxV)p23@pPlZ-y@89j zA{R&FFXyR~WB}dY8bIJO`(Z_u>sESxHFC13xx~#S+m`9GG`T%qQ~(rtHfI{GZ9otX z01g-&*atnC5$&OqqiY&eE-_>3=lamGk`7Ht*lxh$``h`xj4JkT$|M3aV>(r`Usg%Y z^0Ks*`3dcYt78uf3)LU)=swLA1j8j~6k)Uy+|{4QxU5&Km};wHr_2^O>{7&EXk&4`O{$|)jPt*iPtXOPG2`b?JFrOkvL|F<^;;`uDOb&r}o|CQ>ozgx}HDit_LlcR>$l=yCq@@NPgBjnfY}XhIFLYY+ z=v-=fI5#+WlsX@VSgqL~QJz*x)(_8F2R;uJSTIw-t^n8m`D)#R;0Ttqvc%;qFd5w+m5RMZLi(KV;bd(5g zTRvSlZcEuSagJD--FlqxVnUOpsAdN!eMg*1^~NT{h~A9j&4yn%QHiF4TC2%>iMugi zh^=dib1S`6_?6LlQ0Jn~Qda9UO!`ExJgJs$J#H22JCHG&@7FtC(|3gY7p*YhqQ$ot zUaBhPH=LUUBScH8b|kjcTgSaav_=$|tgvZh?TgtqmmxTgI7W+v+2}(EAaxYSwzcUk z=vFFDXGW|1ol;pA>_3>zzF?b7$Q|$%Yy@u{hR0XZLdK);NZgR}>1}}APzu=Cj@Br> z=l0LBY4=oSao;ye`>I1T9V#CX*`fZYUPD>;A6v6kd#ig ztX#lFxG^a?>>?4ggj&i*4hnl{l*MIGqxoELCO{xrxp+wH0N63#rIGnemMYvS{o3wk zkMZbyPeOG@H2er*U&dviIt_cI4Cw4WF`A9@PF5`)APZCX*XN2M3|$90xQ|Xz{~lqjmB}rP^00(`hFfBTch%upyPIM!gRh(*USVW zf^VS(&{#;F@ql(2+QhvSoUx{5_#SGz+@VRCgrziJ+n(`({U}3CXCr2f_~HG(mJ~OV zbG@XnnSJWv89&#sK(e#ZLzpik-wf2_7Bc?*M#QCBonbr%I#FKfOFn$1vcyA*8)b)J zyQ$V#^Fgmwv^*-4F6!O{>_Esi;{KStQ-9ee&0jEciriag;A?+&Y1f31`&^EW2hleg zvNMj3r_z1HY5{*BuFtdLZ?bf}T-<39e733?fxia(483EhV?S`QlC06TVYZYn;5yxe zA-sFdz1pT~dyb~7* z2lHK~ZA;42$aBWb?ow*q1!Ouw3DbD?`t0`_nQ^;Fe@xtDBx9T27`z-H$JI8a$L^jV z`4GL;W=rx+@_L^ylh+H_8}P~W-{2(YL370vb@mj!zkDJ#N^r6@AZCnq_xpT6oewV? zm2gJU;+ao0rHXtmGH&9%=ryz`LWD*0y5tUbU0?h^Uq^RCt`X36t>8JI`}nWb9!s-| z^UTAvErAfh3wRWdh;q9JIh0s|pKzU`bfPrS&Zai#@0!p2ZTu~>BaIcx+rSHk3lm2B z2;zj#O{h+JsRJi}i-q9QT*1Wwy9Ke$qMPctYbfw}{Y0aEMYPa_b-2h~*OJ&D3*kDo zvPi(lJYXog^OPVGN0x^)lh%XCK{%HC{KwQ1lrw!fyGA^hn1b0(=r7yI`Bq`3dzd)= z+Njk{@JN*GS6-(N*H`bwSHQ8=y0t>g=A~joCuxT~oI6CZqIN)~UtJ{uFT8|iP<>=z z_~?HilJPoQ5@S8Rgwj)Dfr)ORZPYtel_h^a01r|s*;kumToDEbdeyu=z?gnL9oW>J z0_qwQT!8yQ457fY3CRFZCQ+Kag}|X!aP3(M`c7@T>uVI&3TGxz!YnFp1okJIYiiRs z3QkWM%Ns;~Rnda+xYqpK?n9u?C`|$H(;ZB(OY26KD9WO`t1OcJ% zz#p|~Rj{`qHT5wjN$@l=?^<7@iRvxNe4oW(QVhM<=(c-jGaYq}1vbr)rYW}rD_J4= zf3i$d2>hId^OS)*1J4Ga3QL{Ulqj+1x|_+bG>e$dh6_tq^N(s!WEO@$nvYsL@64Sk zB%y6s^*cdT$mo0~>g-_kje~(VUBb2ksPrfTLrue4#T-fmr$gKYjcKT^J(vfApv+W7 zx0%T7VG=7sm?2-j95lzc&7JiM{06nu#GFA;x!dr*M%P(vtl3=k<@epHWy;noh93QW z*$H-2!@M>5l7Ah&RF_+>8gB`fp9=!6tPdamHkysCi!~AK3$b4}nn`4amRbw}k?Vk> zR7*;z%>ec)nH~fmPK^x_T0-l?607VXqZg1SCXCUSI;fs@3p~vkTJ+=EvYOI=rZ=wm zZhRHJ+p_?KeWr8L?KDF^V)NZ35W#^K3+w|t0+Ze;bsKKbc1zE9eM$T&0Tp<{xmy4J zhE0#YPB2@N9E_B!M1p`SgSfd4|4CD-+4DJ1ij?H%y0zi+CqX6DAcW+I@b$ida7u3c z{g?r0<^o}|NVZkFoc9JF4m+Wbp!cf_wA=apE^I;bR_%X~u<@YxE%5`#Fu6LL$!DnZ z!xWjZFe@g#3u`=8b7-7L5!`J*$u4qC3mp~spY3OtB;_I3hiMaZO#QP(b|SV5*M;!U z;pU6^osJCq$=@i9gb{Av7qvrbEWBWQ;~OT*b-70EXheh&$00@7Y|ZR+(=+h zIu@vnsNGj?qdTH}thyzA+F1*MSAGm#w3{rF2J=SBu#W|CF7&U^_B3hQ_o)U$XU0^) zczcRNnfqo7tt0R;sGHs%E97&KcPLO~WsK`!gQawxaD-fNGre1XM;`fpxM98SIH`gX zWL-BO4C6T6i#f>hh}Sb*f%TscnW&Q_k10^a=P^uq+S6k^_j$_Yf0cwX&EfQM3`JaA|i!EK8%w#Mv;zi zoWEwp&`!I)Oq_l;n4^D{Sc(++mREa*A=s`BbaZe*U~yt-AOjjNd^vTjvv9jmp&3pR zR?wn#uPUOK(b*L!DOeg2bKXEL3n2`tFZXyPM4Q-LvgVLUW{;7Wz;34(YBNR~?Gu{R zy$zo-@~e6w zM_fVvSUyR5!9}O{sBW^Q-NmF2`wiP^zP6}w-|@?IUu~r!oKW>iT4SqmCXb|Y2@}vD z&CVHaW1()1$cJ#ilY!kY4VP{Z-etDZ9za6J7!3~CY*n!wC>66Nhcgb5d4=)SgsZf0 zm$5lFA^p@`2gF9tq=lF~mc@HA)RnsB*t?4kd?gHUYpfAD*|r^Pk2gbQ&h$yAINYV> z1j?;ub~Br1=)(URw@Jw(nL=X5p{sRyf)VzUFoyM0R71Pn;wQ`t*pLMWejnyN#-o{ku&d;Cow%!|k zJdm${K^a~s$?;#xN)+v?-NJdjeig3~+l*Q#Ss_?H z$KLHO(5DHrD4PhPfmy2LALT>HCc#9dh47^*on#kFXKfz>#jq^(?>0BtXb6&R0!~l& zw(?{1d=R++Meb1*Wa&0fMOp_|MzdGG1F-?^&@+?Em6o#A>iX?jo`{dceRwmm4GcDu$qnnMqveZe{jY+>k+2|mL)x?r|>-~&*e zp_^mmNfWsmh^0n4c$0o=m+R(6MbC1)>vj2PClNq_Nm&-^Tf#0se2lKVkUXp#H%uzN fY=*{4Mn77N6XJB{_^`2T!}8Oi3*fipWy}5tkHkTJ literal 0 HcmV?d00001 diff --git a/man/Music_preferences.Rd b/man/Music_preferences.Rd index 827c24bb8..4afd2b17e 100644 --- a/man/Music_preferences.Rd +++ b/man/Music_preferences.Rd @@ -25,6 +25,7 @@ Other effect size datasets: \code{\link{Smoking_FASD}}, \code{\link{food_class}}, \code{\link{hardlyworking}}, +\code{\link{rouder2016}}, \code{\link{screening_test}} } \concept{effect size datasets} diff --git a/man/Music_preferences2.Rd b/man/Music_preferences2.Rd index c09e87a18..a86781c94 100644 --- a/man/Music_preferences2.Rd +++ b/man/Music_preferences2.Rd @@ -25,6 +25,7 @@ Other effect size datasets: \code{\link{Smoking_FASD}}, \code{\link{food_class}}, \code{\link{hardlyworking}}, +\code{\link{rouder2016}}, \code{\link{screening_test}} } \concept{effect size datasets} diff --git a/man/RCT_table.Rd b/man/RCT_table.Rd index 7edfc6748..bf1e74266 100644 --- a/man/RCT_table.Rd +++ b/man/RCT_table.Rd @@ -25,6 +25,7 @@ Other effect size datasets: \code{\link{Smoking_FASD}}, \code{\link{food_class}}, \code{\link{hardlyworking}}, +\code{\link{rouder2016}}, \code{\link{screening_test}} } \concept{effect size datasets} diff --git a/man/Smoking_FASD.Rd b/man/Smoking_FASD.Rd index 945fc86d9..ec24a35fa 100644 --- a/man/Smoking_FASD.Rd +++ b/man/Smoking_FASD.Rd @@ -23,6 +23,7 @@ Other effect size datasets: \code{\link{RCT_table}}, \code{\link{food_class}}, \code{\link{hardlyworking}}, +\code{\link{rouder2016}}, \code{\link{screening_test}} } \concept{effect size datasets} diff --git a/man/cohens_d.Rd b/man/cohens_d.Rd index 0feecee3e..90d7b1c81 100644 --- a/man/cohens_d.Rd +++ b/man/cohens_d.Rd @@ -59,7 +59,7 @@ variance). Else the mean SD from both groups is used instead.} \item{paired}{If \code{TRUE}, the values of \code{x} and \code{y} are considered as paired. This produces an effect size that is equivalent to the one-sample effect -size on \code{x - y}.} +size on \code{x - y}. See also \code{\link[=repeated_measures_d]{repeated_measures_d()}} for more options.} \item{ci}{Confidence Interval (CI) level} @@ -182,10 +182,12 @@ cohens_d(Pair(extra[group == 1], extra[group == 2]) ~ 1, data = sleep) # same as: # cohens_d(sleep$extra[sleep$group == 1], sleep$extra[sleep$group == 2], paired = TRUE) +# cohens_d(sleep$extra[sleep$group == 1] - sleep$extra[sleep$group == 2]) +# rm_d(sleep$extra[sleep$group == 1], sleep$extra[sleep$group == 2], method = "z", adjust = FALSE) # More options: -cohens_d(Pair(extra[group == 1], extra[group == 2]) ~ 1, data = sleep, mu = -1) -hedges_g(Pair(extra[group == 1], extra[group == 2]) ~ 1, data = sleep) +cohens_d(Pair(extra[group == 1], extra[group == 2]) ~ 1, data = sleep, mu = -1, verbose = FALSE) +hedges_g(Pair(extra[group == 1], extra[group == 2]) ~ 1, data = sleep, verbose = FALSE) # Interpretation ----------------------- @@ -219,12 +221,13 @@ Correcting error and bias in research findings. Sage. } } \seealso{ -\code{\link[=sd_pooled]{sd_pooled()}}, \code{\link[=t_to_d]{t_to_d()}}, \code{\link[=r_to_d]{r_to_d()}} +\code{\link[=rm_d]{rm_d()}}, \code{\link[=sd_pooled]{sd_pooled()}}, \code{\link[=t_to_d]{t_to_d()}}, \code{\link[=r_to_d]{r_to_d()}} Other standardized differences: \code{\link{mahalanobis_d}()}, \code{\link{means_ratio}()}, \code{\link{p_superiority}()}, -\code{\link{rank_biserial}()} +\code{\link{rank_biserial}()}, +\code{\link{repeated_measures_d}()} } \concept{standardized differences} diff --git a/man/effectsize.Rd b/man/effectsize.Rd index 5d931c82e..17acf96cd 100644 --- a/man/effectsize.Rd +++ b/man/effectsize.Rd @@ -49,6 +49,9 @@ input model. See details. \item For an object of class \code{htest}, data is extracted via \code{\link[insight:get_data]{insight::get_data()}}, and passed to the relevant function according to: \itemize{ \item A \strong{t-test} depending on \code{type}: \code{"cohens_d"} (default), \code{"hedges_g"}, or one of \code{"p_superiority"}, \code{"u1"}, \code{"u2"}, \code{"u3"}, \code{"overlap"}. +\itemize{ +\item For a \strong{Paired t-test}: depending on \code{type}: \code{"rm"}, \code{"av"}, \code{"b"}, \code{"d"}, \code{"z"}. +} \item A \strong{Chi-squared tests of independence} or \strong{Fisher's Exact Test}, depending on \code{type}: \code{"cramers_v"} (default), \code{"tschuprows_t"}, \code{"phi"}, \code{"cohens_w"}, \code{"pearsons_c"}, \code{"cohens_h"}, \code{"oddsratio"}, \code{"riskratio"}, \code{"arr"}, or \code{"nnt"}. \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"}. @@ -89,6 +92,13 @@ effectsize(Xsq, type = "cohens_w") Tt <- t.test(1:10, y = c(7:20), alternative = "less") effectsize(Tt) +Tt <- t.test( + 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), + paired = TRUE +) +effectsize(Tt, type = "rm_b") + Aov <- oneway.test(extra ~ group, data = sleep, var.equal = TRUE) effectsize(Aov) effectsize(Aov, type = "omega") diff --git a/man/food_class.Rd b/man/food_class.Rd index bd7aeb992..1bc5576eb 100644 --- a/man/food_class.Rd +++ b/man/food_class.Rd @@ -24,6 +24,7 @@ Other effect size datasets: \code{\link{RCT_table}}, \code{\link{Smoking_FASD}}, \code{\link{hardlyworking}}, +\code{\link{rouder2016}}, \code{\link{screening_test}} } \concept{effect size datasets} diff --git a/man/hardlyworking.Rd b/man/hardlyworking.Rd index 7a588b6ec..5dbd45728 100644 --- a/man/hardlyworking.Rd +++ b/man/hardlyworking.Rd @@ -35,6 +35,7 @@ Other effect size datasets: \code{\link{RCT_table}}, \code{\link{Smoking_FASD}}, \code{\link{food_class}}, +\code{\link{rouder2016}}, \code{\link{screening_test}} } \concept{effect size datasets} diff --git a/man/mahalanobis_d.Rd b/man/mahalanobis_d.Rd index 942f6090a..889ee70ff 100644 --- a/man/mahalanobis_d.Rd +++ b/man/mahalanobis_d.Rd @@ -159,6 +159,7 @@ Other standardized differences: \code{\link{cohens_d}()}, \code{\link{means_ratio}()}, \code{\link{p_superiority}()}, -\code{\link{rank_biserial}()} +\code{\link{rank_biserial}()}, +\code{\link{repeated_measures_d}()} } \concept{standardized differences} diff --git a/man/means_ratio.Rd b/man/means_ratio.Rd index 5eb6c6190..2a0d6d0a3 100644 --- a/man/means_ratio.Rd +++ b/man/means_ratio.Rd @@ -129,6 +129,7 @@ Other standardized differences: \code{\link{cohens_d}()}, \code{\link{mahalanobis_d}()}, \code{\link{p_superiority}()}, -\code{\link{rank_biserial}()} +\code{\link{rank_biserial}()}, +\code{\link{repeated_measures_d}()} } \concept{standardized differences} diff --git a/man/p_superiority.Rd b/man/p_superiority.Rd index 595ae4428..eebe89aae 100644 --- a/man/p_superiority.Rd +++ b/man/p_superiority.Rd @@ -273,7 +273,8 @@ Other standardized differences: \code{\link{cohens_d}()}, \code{\link{mahalanobis_d}()}, \code{\link{means_ratio}()}, -\code{\link{rank_biserial}()} +\code{\link{rank_biserial}()}, +\code{\link{repeated_measures_d}()} Other rank-based effect sizes: \code{\link{rank_biserial}()}, diff --git a/man/rank_biserial.Rd b/man/rank_biserial.Rd index b5577eb4f..2c62bb460 100644 --- a/man/rank_biserial.Rd +++ b/man/rank_biserial.Rd @@ -187,7 +187,8 @@ Other standardized differences: \code{\link{cohens_d}()}, \code{\link{mahalanobis_d}()}, \code{\link{means_ratio}()}, -\code{\link{p_superiority}()} +\code{\link{p_superiority}()}, +\code{\link{repeated_measures_d}()} Other rank-based effect sizes: \code{\link{p_superiority}()}, diff --git a/man/repeated_measures_d.Rd b/man/repeated_measures_d.Rd new file mode 100644 index 000000000..e6d9e785e --- /dev/null +++ b/man/repeated_measures_d.Rd @@ -0,0 +1,241 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/repeated_measures_d.R +\name{repeated_measures_d} +\alias{repeated_measures_d} +\alias{rm_d} +\title{Standardized Mean Differences for Repeated Measures} +\usage{ +repeated_measures_d( + x, + y, + data = NULL, + mu = 0, + method = c("rm", "av", "z", "b", "d", "r"), + adjust = TRUE, + ci = 0.95, + alternative = "two.sided", + verbose = TRUE, + ... +) + +rm_d( + x, + y, + data = NULL, + mu = 0, + method = c("rm", "av", "z", "b", "d", "r"), + adjust = TRUE, + ci = 0.95, + alternative = "two.sided", + verbose = TRUE, + ... +) +} +\arguments{ +\item{x, y}{Paired numeric vectors, or names of ones in \code{data}. \code{x} can also +be a formula: +\itemize{ +\item \code{Pair(x,y) ~ 1} for wide data. +\item \code{y ~ condition | id} for long data, possibly with repetitions. +}} + +\item{data}{An optional data frame containing the variables.} + +\item{mu}{a number indicating the true value of the mean (or + difference in means if you are performing a two sample test).} + +\item{method}{Method of repeated measures standardized differences. See +details.} + +\item{adjust}{Apply Hedges' small-sample bias correction? See \code{\link[=hedges_g]{hedges_g()}}.} + +\item{ci}{Confidence Interval (CI) level} + +\item{alternative}{a character string specifying the alternative hypothesis; +Controls the type of CI returned: \code{"two.sided"} (default, two-sided CI), +\code{"greater"} or \code{"less"} (one-sided CI). Partial matching is allowed (e.g., +\code{"g"}, \code{"l"}, \code{"two"}...). See \emph{One-Sided CIs} in \link{effectsize_CIs}.} + +\item{verbose}{Toggle warnings and messages on or off.} + +\item{...}{Arguments passed to or from other methods. When \code{x} is a formula, +these can be \code{subset} and \code{na.action}.} +} +\value{ +A data frame with the effect size and their CIs (\code{CI_low} and +\code{CI_high}). +} +\description{ +Compute effect size indices for standardized mean differences in repeated +measures data. Pair with any reported \code{stats::t.test(paired = TRUE)}. +\cr\cr +In a repeated-measures design, the same subjects are measured in multiple +conditions or time points. Unlike the case of independent groups, there are +multiple sources of variation that can be used to standardized the +differences between the means of the conditions / times. +} +\note{ +\code{rm_d()} is an alias for \code{repeated_measures_d()}. +} +\section{Standardized Mean Differences for Repeated Measures}{ +Unlike \link[=cohens_d]{Cohen's d} for independent groups, where standardization +naturally is done by the (pooled) population standard deviation (cf. Glass’s +\eqn{\Delta}), when measured across two conditions are dependent, there are +many more options for what error term to standardize by. Additionally, some +options allow for data to be replicated (many measurements per condition per +individual), others require a single observation per condition per individual +(aka, paired data; so replications are aggregated). + +(It should be noted that all of these have awful and confusing notations.) + +Standardize by... +\itemize{ +\item \strong{Difference Score Variance: \eqn{d_{z}}} (\emph{Requires paired data}) - This +is akin to computing difference scores for each individual and then +computing a one-sample Cohen's \emph{d} (Cohen, 1988, pp. 48; see examples). +\item \strong{Within-Subject Variance: \eqn{d_{rm}}} (\emph{Requires paired data}) - Cohen +suggested adjusting \eqn{d_{z}} to estimate the "standard" between-subjects +\emph{d} by a factor of \eqn{\sqrt{2(1-r)}}, where \emph{r} is the Pearson correlation +between the paired measures (Cohen, 1988, pp. 48). +\item \strong{Control Variance: \eqn{d_{b}} (aka Becker's \emph{d})} (\emph{Requires paired +data}) - Standardized by the variance of the control condition (or in a pre- +post-treatment setting, the pre-treatment condition). This is akin to Glass' +\emph{delta} (\code{\link[=glass_delta]{glass_delta()}}) (Becker, 1988). Note that this is taken here as the +\emph{second} condition (\code{y}). +\item \strong{Average Variance: \eqn{d_{av}}} (\emph{Requires paired data}) - Instead of +standardizing by the variance in the of the control (or pre) condition, +Cumming suggests standardizing by the average variance of the two paired +conditions (Cumming, 2013, pp. 291). +\item \strong{All Variance: \eqn{d_{d}}} - This is the same as computing a standard +independent-groups Cohen's \emph{d} (Cohen, 1988). Note that CIs \emph{do} account for +the dependence, and so are typically more narrow (see examples). +\item \strong{Residual Variance: \eqn{d_{r}}} (\emph{Requires data with replications}) - +Divide by the pooled variance after all individual differences have been +partialled out (i.e., the residual/level-1 variance in an ANOVA or MLM +setting). In between-subjects designs where each subject contributes a single +response, this is equivalent to classical Cohen’s d. Priors in the +\code{BayesFactor} package are defined on this scale (Rouder et al., 2012). +\cr\cr +Note that for paired data, when the two conditions have equal variance, +\eqn{d_{rm}}, \eqn{d_{av}}, \eqn{d_{b}} are equal to \eqn{d}. +} +} + +\section{Confidence (Compatibility) Intervals (CIs)}{ +Confidence intervals are estimated using the standard normal parametric +method (see Algina & Keselman, 2003; Becker, 1988; Cooper et al., 2009; +Hedges & Olkin, 1985; Pustejovsky et al., 2014). +} + +\section{CIs and Significance Tests}{ +"Confidence intervals on measures of effect size convey all the information +in a hypothesis test, and more." (Steiger, 2004). Confidence (compatibility) +intervals and p values are complementary summaries of parameter uncertainty +given the observed data. A dichotomous hypothesis test could be performed +with either a CI or a p value. The 100 (1 - \eqn{\alpha})\% confidence +interval contains all of the parameter values for which \emph{p} > \eqn{\alpha} +for the current data and model. For example, a 95\% confidence interval +contains all of the values for which p > .05. +\cr\cr +Note that a confidence interval including 0 \emph{does not} indicate that the null +(no effect) is true. Rather, it suggests that the observed data together with +the model and its assumptions combined do not provided clear evidence against +a parameter value of 0 (same as with any other value in the interval), with +the level of this evidence defined by the chosen \eqn{\alpha} level (Rafi & +Greenland, 2020; Schweder & Hjort, 2016; Xie & Singh, 2013). To infer no +effect, additional judgments about what parameter values are "close enough" +to 0 to be negligible are needed ("equivalence testing"; Bauer & Kiesser, +1996). +} + +\section{Plotting with \code{see}}{ + +The \code{see} package contains relevant plotting functions. See the \href{https://easystats.github.io/see/articles/effectsize.html}{plotting vignette in the \code{see} package}. +} + +\examples{ +# Paired data ------- + +data("sleep") +sleep2 <- reshape(sleep, + direction = "wide", + idvar = "ID", timevar = "group" +) + +repeated_measures_d(Pair(extra.1, extra.2) ~ 1, data = sleep2) + +# Same as: +# repeated_measures_d(sleep$extra[sleep$group==1], +# sleep$extra[sleep$group==2]) +# repeated_measures_d(extra ~ group | ID, data = sleep) + + +# More options: +repeated_measures_d(Pair(extra.1, extra.2) ~ 1, data = sleep2, mu = -1) +repeated_measures_d(Pair(extra.1, extra.2) ~ 1, data = sleep2, alternative = "less") + +# Other methods +repeated_measures_d(Pair(extra.1, extra.2) ~ 1, data = sleep2, method = "av") +repeated_measures_d(Pair(extra.1, extra.2) ~ 1, data = sleep2, method = "b") +repeated_measures_d(Pair(extra.1, extra.2) ~ 1, data = sleep2, method = "d") +repeated_measures_d(Pair(extra.1, extra.2) ~ 1, data = sleep2, method = "z", adjust = FALSE) + +# d_z is the same as Cohen's d for one sample (of individual difference): +cohens_d(extra.1 - extra.2 ~ 1, data = sleep2) + + + +# Repetition data ----------- + +data("rouder2016") + +# For rm, ad, z, b, data is aggregated +repeated_measures_d(rt ~ cond | id, data = rouder2016) + +# same as: +rouder2016_wide <- tapply(rouder2016[["rt"]], rouder2016[1:2], mean) +repeated_measures_d(rouder2016_wide[, 1], rouder2016_wide[, 2]) + +# For r or d, data is not aggragated: +repeated_measures_d(rt ~ cond | id, data = rouder2016, method = "r") +repeated_measures_d(rt ~ cond | id, data = rouder2016, method = "d", adjust = FALSE) + +# d is the same as Cohen's d for two independent groups: +cohens_d(rt ~ cond, data = rouder2016, ci = NULL) + +} +\references{ +\itemize{ +\item Algina, J., & Keselman, H. J. (2003). Approximate confidence intervals for +effect sizes. Educational and Psychological Measurement, 63(4), 537-553. +\item Becker, B. J. (1988). Synthesizing standardized mean‐change measures. +British Journal of Mathematical and Statistical Psychology, 41(2), 257-278. +\item Cohen, J. (1988). Statistical power analysis for the behavioral +sciences (2nd Ed.). New York: Routledge. +\item Cooper, H., Hedges, L., & Valentine, J. (2009). Handbook of research +synthesis and meta-analysis. Russell Sage Foundation, New York. +\item Cumming, G. (2013). Understanding the new statistics: Effect sizes, +confidence intervals, and meta-analysis. Routledge. +\item Hedges, L. V. & Olkin, I. (1985). Statistical methods for +meta-analysis. Orlando, FL: Academic Press. +\item Pustejovsky, J. E., Hedges, L. V., & Shadish, W. R. (2014). +Design-comparable effect sizes in multiple baseline designs: A general +modeling framework. Journal of Educational and Behavioral Statistics, 39(5), +368-393. +\item Rouder, J. N., Morey, R. D., Speckman, P. L., & Province, J. M. (2012). +Default Bayes factors for ANOVA designs. Journal of mathematical psychology, +56(5), 356-374. +} +} +\seealso{ +\code{\link[=cohens_d]{cohens_d()}}, and \code{lmeInfo::g_mlm()} and \code{emmeans::effsize()} for +more flexible methods. + +Other standardized differences: +\code{\link{cohens_d}()}, +\code{\link{mahalanobis_d}()}, +\code{\link{means_ratio}()}, +\code{\link{p_superiority}()}, +\code{\link{rank_biserial}()} +} +\concept{standardized differences} diff --git a/man/rouder2016.Rd b/man/rouder2016.Rd new file mode 100644 index 000000000..866741c0f --- /dev/null +++ b/man/rouder2016.Rd @@ -0,0 +1,43 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/datasets.R +\docType{data} +\name{rouder2016} +\alias{rouder2016} +\title{Jeff Rouder's Example Dataset for Repeated Measures} +\format{ +A data frame with 2500 rows and 3 variables: +\describe{ +\item{id}{participant: 1...25} +\item{cond}{condition: 1,2} +\item{rt}{response time in seconds} +} + +\if{html}{\out{
}}\preformatted{data("rouder2016") +head(rouder2016, n = 5) +#> id cond rt +#> 1 1 1 0.560 +#> 2 1 1 0.930 +#> 3 1 1 0.795 +#> 4 1 1 0.615 +#> 5 1 1 1.028 +}\if{html}{\out{
}} +} +\description{ +A dataset "with 25 people each observing 50 trials in 2 conditions", +published as \code{effectSizePuzzler.txt} by Jeff Rouder on March 24, 2016 +(\emph{http://jeffrouder.blogspot.com/2016/03/the-effect-size-puzzler.html}). +\cr\cr +The data is used in examples and tests of \code{\link[=rm_d]{rm_d()}}. +} +\seealso{ +Other effect size datasets: +\code{\link{Music_preferences2}}, +\code{\link{Music_preferences}}, +\code{\link{RCT_table}}, +\code{\link{Smoking_FASD}}, +\code{\link{food_class}}, +\code{\link{hardlyworking}}, +\code{\link{screening_test}} +} +\concept{effect size datasets} +\keyword{data} diff --git a/man/screening_test.Rd b/man/screening_test.Rd index f105b3e10..7b3b0a67f 100644 --- a/man/screening_test.Rd +++ b/man/screening_test.Rd @@ -32,7 +32,8 @@ Other effect size datasets: \code{\link{RCT_table}}, \code{\link{Smoking_FASD}}, \code{\link{food_class}}, -\code{\link{hardlyworking}} +\code{\link{hardlyworking}}, +\code{\link{rouder2016}} } \concept{effect size datasets} \keyword{data} diff --git a/tests/testthat/test-effectsize.R b/tests/testthat/test-effectsize.R index 32b7d160b..3e48ca7a7 100644 --- a/tests/testthat/test-effectsize.R +++ b/tests/testthat/test-effectsize.R @@ -16,9 +16,6 @@ test_that("t-test", { model <- t.test(x, y, alternative = "less", conf.level = 0.8) expect_equal(effectsize(model), cohens_d(x, y, pooled_sd = FALSE, alternative = "less", ci = 0.8), ignore_attr = TRUE) - model <- t.test(x, y, paired = TRUE) - expect_equal(effectsize(model), cohens_d(x, y, paired = TRUE), ignore_attr = TRUE) - model <- t.test(x, y, var.equal = TRUE) expect_equal(effectsize(model), cohens_d(x, y), ignore_attr = TRUE) @@ -36,7 +33,6 @@ test_that("t-test", { ignore_attr = TRUE ) - # one sample z <<- mtcars$wt model <- t.test(z, mu = 3, var.equal = TRUE) @@ -45,6 +41,23 @@ test_that("t-test", { ignore_attr = TRUE ) + ## Paired sample + model <- t.test(x, y, paired = TRUE) + expect_equal(effectsize(model, verbose = FALSE), cohens_d(x, y, paired = TRUE, verbose = FALSE), ignore_attr = TRUE) + + sleep2 <<- reshape(sleep, + direction = "wide", + idvar = "ID", timevar = "group" + ) + tt <- t.test(sleep2$extra.1, sleep2$extra.2, paired = TRUE) + + es1 <- effectsize(tt, type = "rm_b") + es2 <- rm_d(tt, method = "b") + es <- rm_d(sleep2$extra.1, sleep2$extra.2, method = "b") + expect_equal(es1, es, ignore_attr = TRUE) + expect_equal(es2, es, ignore_attr = TRUE) + + ## Missing y <<- rnorm(12) g <<- c(rep(letters[1:2], each = 5), NA, NA) diff --git a/tests/testthat/test-rm_d.R b/tests/testthat/test-rm_d.R new file mode 100644 index 000000000..af94290d6 --- /dev/null +++ b/tests/testthat/test-rm_d.R @@ -0,0 +1,126 @@ +test_that("rm_d | paired data", { + data("sleep") + sleep2 <- reshape(sleep, + direction = "wide", + idvar = "ID", timevar = "group" + ) + + d1 <- rm_d( + sleep$extra[sleep$group == 1], + sleep$extra[sleep$group == 2] + ) + d2 <- rm_d(Pair(extra.1, extra.2) ~ 1, data = sleep2) + expect_no_message(d3 <- rm_d(extra ~ group | ID, data = sleep)) + + expect_equal(d1, d2) + expect_equal(d1, d3) + + d_z <- rm_d(Pair(extra.1, extra.2) ~ 1, data = sleep2, method = "z") + d_z2 <- hedges_g(sleep$extra[sleep$group == 1] - sleep$extra[sleep$group == 2]) + + expect_equal(d_z[[1]], d_z2[[1]]) + expect_equal(d_z$CI_low, d_z2$CI_low, tolerance = 0.01) + expect_equal(d_z$CI_high, d_z2$CI_high, tolerance = 0.1) + + expect_error( + rm_d(Pair(extra.1, extra.2) ~ 1, data = sleep2, method = "r"), + regexp = "replications" + ) + + + # equal with equal variance: + dat <- data.frame( + V1 = c( + -0.32150435528124, -4.02978032779713, 0.159645811226589, + 1.95179927058772, 0.168527299289471, 3.4499229496418, + -1.87888939495506, 0.431333839911973, -0.26004200470096, + 0.328986912076835 + ), + V2 = c( + 2.50107579495566, -0.32926747002329, 4.01118960037018, + 1.44969284040984, -1.46241877172319, 1.25068499614667, + 0.028928469929524, 3.05532100575796, -1.67014771817319, + 3.16494125234984 + ) + ) + + d_rm <- rm_d("V1", "V2", data = dat, adjust = FALSE) + d_av <- rm_d("V1", "V2", data = dat, adjust = FALSE, method = "av") + d_b <- rm_d("V1", "V2", data = dat, adjust = FALSE, method = "b") + d_d <- rm_d("V1", "V2", data = dat, adjust = FALSE, method = "d") + + expect_equal(d_rm[[1]], d_d[[1]]) + expect_equal(d_av[[1]], d_d[[1]]) + expect_equal(d_b[[1]], d_d[[1]]) +}) + +test_that("rm_d | replication data", { + data("rouder2016") + + expect_message( + rm_d(rt ~ cond | id, data = rouder2016), + regexp = "requires paired data" + ) + expect_no_message( + rm_d(rt ~ cond | id, data = rouder2016, verbose = FALSE), + ) + expect_no_message( + rm_d(rt ~ cond | id, data = rouder2016, method = "d"), + ) + + d_av <- rm_d(rt ~ cond | id, + data = rouder2016, method = "av", + adjust = FALSE, verbose = FALSE + ) + d_z <- rm_d(rt ~ cond | id, + data = rouder2016, method = "z", + adjust = FALSE, verbose = FALSE + ) + d_d <- rm_d(rt ~ cond | id, + data = rouder2016, method = "d", + adjust = FALSE + ) + d_r <- rm_d(rt ~ cond | id, + data = rouder2016, method = "r", + adjust = FALSE + ) + + # values takes from + # https://jakewestfall.org/blog/index.php/2016/03/25/five-different-cohens-d-statistics-for-within-subject-designs/ + expect_equal(d_av[[1]], -0.8357347, tolerance = 0.001) + expect_equal(d_z[[1]], -1.353713, tolerance = 0.001) + expect_equal(d_d[[1]], -0.2497971, tolerance = 0.001) + expect_equal(d_r[[1]], -0.052298 / 0.20195, tolerance = 0.001) + + # also: + expect_equal(d_d[[1]], cohens_d(rt ~ cond, data = rouder2016)[[1]], tolerance = 0.001) + + rouder2016_wide <- tapply(rouder2016[["rt"]], rouder2016[1:2], mean, na.rm = TRUE) + d_z2 <- cohens_d(rouder2016_wide[, 1] - rouder2016_wide[, 2]) + expect_equal(d_z[[1]], d_z2[[1]]) + expect_equal(d_z$CI_low, d_z2$CI_low, tolerance = 0.02) + expect_equal(d_z$CI_high, d_z2$CI_high, tolerance = 0.02) + + d_rm <- rm_d(rt ~ cond | id, data = rouder2016, verbose = FALSE) + d_rm2 <- rm_d(rouder2016_wide[, 1], rouder2016_wide[, 2]) + expect_equal(d_rm2, d_rm) + + + # # compare CIs to lmeInfo::g_mlm + # mod1 <- nlme::lme(rt ~ cond, random = ~ cond | id, + # data = rouder2016, + # control = nlme::nlmeControl(opt = "nlm")) + # g_r <- lmeInfo::g_mlm(mod1, p_const = c(0, -1), r_const = c(0, 0, 0, 1)) + # g_r_ci <- lmeInfo::CI_g(g_r) + # g_d <- lmeInfo::g_mlm(mod1, p_const = c(0, -1), r_const = c(1, 1, 1, 1)) + # g_d_ci <- lmeInfo::CI_g(g_d) + + d_r2 <- rm_d(rt ~ cond | id, data = rouder2016, method = "r") + expect_equal(d_r2$CI_low, -0.342050038016442, tolerance = 0.05) + expect_equal(d_r2$CI_high, -0.17575096606632, tolerance = 0.05) + + + d_d2 <- rm_d(rt ~ cond | id, data = rouder2016, method = "d") + expect_equal(d_d2$CI_low, -0.329333102235032, tolerance = 0.05) + expect_equal(d_d2$CI_high, -0.168904897964021, tolerance = 0.05) +}) diff --git a/vignettes/standardized_differences.Rmd b/vignettes/standardized_differences.Rmd index a1aa33e1d..a12288a8c 100644 --- a/vignettes/standardized_differences.Rmd +++ b/vignettes/standardized_differences.Rmd @@ -105,7 +105,9 @@ hedges_g(mtcars$wt, mu = 2.7) ## Paired Samples -For paired-samples, the difference is standardized by the variation in the differences. This effect size, known as Cohen's $d_z$, represents the difference in terms of its homogeneity (a small but stable difference will have a large $d_z$). +In a repeated-measures design, the same subjects are measured in multiple conditions or time points. Unlike the case of independent groups, there are multiple sources of variation that can be used to standardized the differences between the means of the conditions / times, and each provides a unique standardized mean difference. + +The most basic option is compute from the paired samples difference scores and compute a one-sample effect size. This effect size, known as Cohen's $d_z$, represents the difference in terms of its homogeneity (a small but stable difference will have a large $d_z$). ```{r} sleep_wide <- datawizard::data_to_wide(sleep, @@ -117,9 +119,35 @@ sleep_wide <- datawizard::data_to_wide(sleep, t.test(sleep_wide[["extra_1"]], sleep_wide[["extra_2"]], paired = TRUE) -cohens_d(sleep_wide[["extra_1"]], sleep_wide[["extra_2"]], paired = TRUE) +repeated_measures_d(sleep_wide[["extra_1"]], sleep_wide[["extra_2"]], method = "z") + +# same as: +hedges_g(sleep_wide[["extra_1"]] - sleep_wide[["extra_2"]]) +``` + +Other options try to get close to the value that would have been reached if the samples were independant (see more info in the documentation of `repeated_measures_d()`): + +```{r} +repeated_measures_d(sleep_wide[["extra_1"]], sleep_wide[["extra_2"]]) + +repeated_measures_d(sleep_wide[["extra_1"]], sleep_wide[["extra_2"]], method = "av") + +repeated_measures_d(sleep_wide[["extra_1"]], sleep_wide[["extra_2"]], method = "b") + +repeated_measures_d(sleep_wide[["extra_1"]], sleep_wide[["extra_2"]], method = "d") + +# all closer to: +cohens_d(sleep_wide[["extra_1"]], sleep_wide[["extra_2"]], ci = NULL) +``` + +For data containing repetition in each condition/subject, another effect size (residual _d_) is also available: + +```{r} +data("rouder2016") + +head(rouder2016) -hedges_g(sleep_wide[["extra_1"]], sleep_wide[["extra_2"]], paired = TRUE) +repeated_measures_d(rt ~ cond | id, data = rouder2016, method = "r") ``` ## For a Bayesian *t*-test From 9b662516609c50f246f6e38a96ac87bc135e05b3 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Tue, 7 Nov 2023 10:05:57 +0200 Subject: [PATCH 18/30] quick typo fix --- R/repeated_measures_d.R | 2 +- man/repeated_measures_d.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/repeated_measures_d.R b/R/repeated_measures_d.R index 53fcace62..6db41967a 100644 --- a/R/repeated_measures_d.R +++ b/R/repeated_measures_d.R @@ -49,7 +49,7 @@ #' standardizing by the variance in the of the control (or pre) condition, #' Cumming suggests standardizing by the average variance of the two paired #' conditions (Cumming, 2013, pp. 291). -#' - **All Variance: \eqn{d_{d}}** - This is the same as computing a standard +#' - **All Variance: Just \eqn{d}** - This is the same as computing a standard #' independent-groups Cohen's _d_ (Cohen, 1988). Note that CIs _do_ account for #' the dependence, and so are typically more narrow (see examples). #' - **Residual Variance: \eqn{d_{r}}** (_Requires data with replications_) - diff --git a/man/repeated_measures_d.Rd b/man/repeated_measures_d.Rd index e6d9e785e..58a130a1d 100644 --- a/man/repeated_measures_d.Rd +++ b/man/repeated_measures_d.Rd @@ -106,7 +106,7 @@ post-treatment setting, the pre-treatment condition). This is akin to Glass' standardizing by the variance in the of the control (or pre) condition, Cumming suggests standardizing by the average variance of the two paired conditions (Cumming, 2013, pp. 291). -\item \strong{All Variance: \eqn{d_{d}}} - This is the same as computing a standard +\item \strong{All Variance: Just \eqn{d}} - This is the same as computing a standard independent-groups Cohen's \emph{d} (Cohen, 1988). Note that CIs \emph{do} account for the dependence, and so are typically more narrow (see examples). \item \strong{Residual Variance: \eqn{d_{r}}} (\emph{Requires data with replications}) - From 3efc17eb5256ac99cb5291ed4803d07e8f5a2909 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Tue, 7 Nov 2023 10:14:19 +0200 Subject: [PATCH 19/30] another typo --- R/effectsize.R | 2 +- man/effectsize.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/effectsize.R b/R/effectsize.R index b0377c17b..af80dc8b8 100644 --- a/R/effectsize.R +++ b/R/effectsize.R @@ -14,7 +14,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 one of `"p_superiority"`, `"u1"`, `"u2"`, `"u3"`, `"overlap"`. -#' - For a **Paired t-test**: depending on `type`: `"rm"`, `"av"`, `"b"`, `"d"`, `"z"`. +#' - For a **Paired t-test**: depending on `type`: `"rm_rm"`, `"rm_av"`, `"rm_b"`, `"rm_d"`, `"rm_z"`. #' - A **Chi-squared tests of independence** or **Fisher's Exact Test**, depending on `type`: `"cramers_v"` (default), `"tschuprows_t"`, `"phi"`, `"cohens_w"`, `"pearsons_c"`, `"cohens_h"`, `"oddsratio"`, `"riskratio"`, `"arr"`, or `"nnt"`. #' - 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"`. diff --git a/man/effectsize.Rd b/man/effectsize.Rd index 17acf96cd..3fdaf561a 100644 --- a/man/effectsize.Rd +++ b/man/effectsize.Rd @@ -50,7 +50,7 @@ input model. See details. \itemize{ \item A \strong{t-test} depending on \code{type}: \code{"cohens_d"} (default), \code{"hedges_g"}, or one of \code{"p_superiority"}, \code{"u1"}, \code{"u2"}, \code{"u3"}, \code{"overlap"}. \itemize{ -\item For a \strong{Paired t-test}: depending on \code{type}: \code{"rm"}, \code{"av"}, \code{"b"}, \code{"d"}, \code{"z"}. +\item For a \strong{Paired t-test}: depending on \code{type}: \code{"rm_rm"}, \code{"rm_av"}, \code{"rm_b"}, \code{"rm_d"}, \code{"rm_z"}. } \item A \strong{Chi-squared tests of independence} or \strong{Fisher's Exact Test}, depending on \code{type}: \code{"cramers_v"} (default), \code{"tschuprows_t"}, \code{"phi"}, \code{"cohens_w"}, \code{"pearsons_c"}, \code{"cohens_h"}, \code{"oddsratio"}, \code{"riskratio"}, \code{"arr"}, or \code{"nnt"}. \item A \strong{Chi-squared tests of goodness-of-fit}, depending on \code{type}: \code{"fei"} (default) \code{"cohens_w"}, \code{"pearsons_c"} From 8fdbfad67a82be3de5e39498032cf8ce50aea210 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Wed, 8 Nov 2023 20:36:57 +0200 Subject: [PATCH 20/30] fix nnt bug --- DESCRIPTION | 2 +- NEWS.md | 4 ++++ R/xtab_diff.R | 2 +- tests/testthat/test-xtab.R | 8 ++++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5c10ce472..904a59c83 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: effectsize Title: Indices of Effect Size -Version: 0.8.6.2 +Version: 0.8.6.3 Authors@R: c(person(given = "Mattan S.", family = "Ben-Shachar", diff --git a/NEWS.md b/NEWS.md index 05d6febf2..bfd8f3f00 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,10 @@ - `repeated_measures_d()` to compute standardized mean differences (SMD) for repeated measures data. - Also supported in `effectsize()` + +## Bug fixes + +- `nnt()` now properly accepts the `y` argument. # effectsize 0.8.7 diff --git a/R/xtab_diff.R b/R/xtab_diff.R index a80f64553..2346f85d6 100644 --- a/R/xtab_diff.R +++ b/R/xtab_diff.R @@ -304,7 +304,7 @@ nnt <- function(x, y = NULL, ci = 0.95, alternative = "two.sided", ...) { return(effectsize(x, type = "nnt", ci = ci, ...)) } - out <- arr(x, y = t, ci = ci, alternative = alternative2, ...) + out <- arr(x, y = y, ci = ci, alternative = alternative2, ...) out[[1]] <- 1 / out[[1]] colnames(out)[1] <- "NNT" diff --git a/tests/testthat/test-xtab.R b/tests/testthat/test-xtab.R index aaa9bbb68..667127cb5 100644 --- a/tests/testthat/test-xtab.R +++ b/tests/testthat/test-xtab.R @@ -200,6 +200,14 @@ test_that("oddsratio & riskratio", { expect_equal(ARR[[1]], -0.4891775, tolerance = 0.001) expect_equal(ARR$CI_low, -0.8092576, tolerance = 0.001) expect_equal(ARR$CI_high, -0.1690974, tolerance = 0.001) + + # fix + set.seed(111) + x <- rbinom(10, 1, 0.5) + y <- rbinom(10, 1, 0.5) + + expect_no_error(NNT <- nnt(x, y)) + expect_equal(NNT[[1]], arr_to_nnt(arr(x, y)[[1]])) }) From 8b5636fbb2df90b9040e51eb55a05927f425b7d1 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Tue, 5 Dec 2023 13:10:07 +0200 Subject: [PATCH 21/30] fix #622 --- DESCRIPTION | 2 +- R/utils_validate_input_data.R | 2 +- tests/testthat/test-rm_d.R | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 904a59c83..74feca8e5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: effectsize Title: Indices of Effect Size -Version: 0.8.6.3 +Version: 0.8.6.4 Authors@R: c(person(given = "Mattan S.", family = "Ben-Shachar", diff --git a/R/utils_validate_input_data.R b/R/utils_validate_input_data.R index 3002ece00..0aa5e2f14 100644 --- a/R/utils_validate_input_data.R +++ b/R/utils_validate_input_data.R @@ -126,7 +126,7 @@ return(mf) } - if (verbose && any(tapply(mf[[1]], mf[3:2], length) > 1L)) { + if (verbose && any(tapply(mf[[1]], mf[3:2], length) > 1L, na.rm = TRUE)) { insight::format_alert( paste0("The ", method, " standardized difference requires paired data,"), "but data contains more than one observation per design cell.", diff --git a/tests/testthat/test-rm_d.R b/tests/testthat/test-rm_d.R index af94290d6..ed0c09e28 100644 --- a/tests/testthat/test-rm_d.R +++ b/tests/testthat/test-rm_d.R @@ -27,6 +27,12 @@ test_that("rm_d | paired data", { regexp = "replications" ) + sleep[1, "extra"] <- NA + sleep2[1, "extra.1"] <- NA + expect_no_error(d1NA <- rm_d(extra ~ group | ID, data = sleep)) + expect_no_error(d2NA <- rm_d(Pair(extra.1, extra.2) ~ 1, data = sleep2)) + expect_equal(d1NA, d2NA) + # equal with equal variance: dat <- data.frame( From 37b48bde40a097a5385761ac98e189819b8be58f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 12 Dec 2023 18:46:24 +0530 Subject: [PATCH 22/30] [create-pull-request] automated change (#621) Co-authored-by: IndrajeetPatil --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 74feca8e5..a41a3817f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -67,8 +67,8 @@ Depends: R (>= 3.6) Imports: bayestestR (>= 0.13.1), - insight (>= 0.19.6), - parameters (>= 0.21.2), + insight (>= 0.19.7), + parameters (>= 0.21.3), performance (>= 0.10.8), datawizard (>= 0.9.0), stats, From 250a9d2c0c1ce155c720b9845c15da437d87f48c Mon Sep 17 00:00:00 2001 From: Philip Waggoner <31326382+pdwaggoner@users.noreply.github.com> Date: Tue, 12 Dec 2023 12:40:25 -0700 Subject: [PATCH 23/30] Adding power vignette plus a few other changes (#605) * adding power vignette # Description Adding a vignette on the value of statistical power as well as the role of `effectsize` in making this an easy thing to do via #599 # Proposed Changes In addition to adding new vignette (`statistical_power.Rmd`), other changes include: - adding three new refs to `bibliography.bib` - adding myself as ctb in `DESCRIPTION - fixing a few typos here and there # Question **Note**: Need to change version number? Didn't think so with only the inclusion of a new vignette, but feel free to bump if needed. * Update bibliography.bib updating bib for pwaggoner's new power vignette * Update DESCRIPTION adding pwaggoner * Update standardized_differences.Rmd small typo and grammatical fixes * Update statistical_power.Rmd fixing some linting issues * Update vignettes/statistical_power.Rmd Co-authored-by: Dominique Makowski * Update statistical_power.Rmd fixed warning issues * fix vignette * evaluate vignette conditionally * suppress warnings * Update standardized_differences.Rmd reverting two small changes back to fix lint issues * Update statistical_power.Rmd * Update statistical_power.Rmd * Update statistical_power.Rmd * Update statistical_power.Rmd * Update README.md cleaning up CRAN links for lint link rot fail * Update statistical_power.Rmd update per Dom's disclaimer suggestion * Update _pkgdown.yml * Update statistical_power.Rmd made changes responding to recent code review * update vignette --------- Co-authored-by: Dominique Makowski Co-authored-by: Indrajeet Patil Co-authored-by: Mattan S. Ben-Shachar Co-authored-by: Mattan S. Ben-Shachar <35330040+mattansb@users.noreply.github.com> --- DESCRIPTION | 7 +- README.md | 8 +- _pkgdown.yml | 3 + vignettes/bibliography.bib | 32 ++++- vignettes/statistical_power.Rmd | 208 ++++++++++++++++++++++++++++++++ 5 files changed, 252 insertions(+), 6 deletions(-) create mode 100644 vignettes/statistical_power.Rmd diff --git a/DESCRIPTION b/DESCRIPTION index a41a3817f..d3cadf728 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -53,7 +53,12 @@ Authors@R: family = "Karreth", role = "rev", email = "jkarreth@ursinus.edu", - comment = c(ORCID = "0000-0003-4586-7153"))) + comment = c(ORCID = "0000-0003-4586-7153")), + person(given = "Philip", + family = "Waggoner", + role = c("aut", "ctb"), + email = "philip.waggoner@gmail.com", + comment = c(ORCID = "0000-0002-7825-7573"))) Maintainer: Mattan S. Ben-Shachar Description: Provide utilities to work with indices of effect size for a wide variety of models and hypothesis tests (see list of supported models using diff --git a/README.md b/README.md index d610f50ce..9658912bc 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ # effectsize: Indices of Effect Size [![DOI](https://joss.theoj.org/papers/10.21105/joss.02815/status.svg/)](https://doi.org/10.21105/joss.02815) -[![downloads](https://cranlogs.r-pkg.org/badges/effectsize)](https://cran.r-project.org/package=effectsize/) -[![total](https://cranlogs.r-pkg.org/badges/grand-total/effectsize)](https://cran.r-project.org/package=effectsize/) -[![status](https://tinyverse.netlify.com/badge/effectsize/)](https://CRAN.R-project.org/package=effectsize/) +[![downloads](https://cranlogs.r-pkg.org/badges/effectsize)](https://CRAN.R-project.org/package=effectsize) +[![total](https://cranlogs.r-pkg.org/badges/grand-total/effectsize)](https://CRAN.R-project.org/package=effectsize) +[![status](https://tinyverse.netlify.com/badge/effectsize/)](https://CRAN.R-project.org/package=effectsize) [![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html) ***Significant is just not enough!*** @@ -15,7 +15,7 @@ conversion of indices such as Cohen’s *d*, *r*, odds-ratios, etc. ## Installation -[![CRAN](https://www.r-pkg.org/badges/version/effectsize)](https://cran.r-project.org/package=effectsize/) +[![CRAN](https://www.r-pkg.org/badges/version/effectsize)](https://CRAN.R-project.org/package=effectsize) [![effectsize status badge](https://easystats.r-universe.dev/badges/effectsize/)](https://easystats.r-universe.dev/) [![R-CMD-check](https://github.com/easystats/effectsize/workflows/R-CMD-check/badge.svg?branch=main)](https://github.com/easystats/effectsize/actions) diff --git a/_pkgdown.yml b/_pkgdown.yml index 4defa8127..0c8e1e3c8 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -126,8 +126,11 @@ navbar: href: https://easystats.github.io/parameters/articles/standardize_parameters_effsize.html - text: "Correlation Vignettes" href: https://easystats.github.io/correlation/articles/index.html + - text: ------- - text: "Confidence Intervals" href: reference/effectsize_CIs.html + - text: "Statistical Power" + href: articles/statistical_power.html - text: ------- - text: "Plotting Functions" href: https://easystats.github.io/see/articles/effectsize.html diff --git a/vignettes/bibliography.bib b/vignettes/bibliography.bib index 0226c5128..9f9aa0f2c 100644 --- a/vignettes/bibliography.bib +++ b/vignettes/bibliography.bib @@ -555,4 +555,34 @@ @article{kelley1935unbiased year={1935}, publisher={National Academy of Sciences}, doi={10.1073/pnas.21.9.554} -} \ No newline at end of file +} + + + + +@article{champley2017, + title={pwr: Basic functions for power analysis}, + author={Champely, Stephane, Claus Ekstrom, Peter Dalgaard, Jeffrey Gill, Stephan Weibelzahl, Aditya Anandkumar, Clay Ford, Robert Volcic, and Helios De Rosario}, + journal={R package v1.3-0}, + year={2017} +} + + + +@book{cohen1988, + title={Statistical power analysis for the behavioral sciences}, + author={Cohen, Jacob}, + publisher={Academic press}, + year={1988/2013} +} + + + +@book{greene2000, + title={Econometric analysis 4th edition. International edition}, + author={Greene, William H.}, + publisher={New Jersey: Prentice Hall}, + year={2000} +} + + diff --git a/vignettes/statistical_power.Rmd b/vignettes/statistical_power.Rmd new file mode 100644 index 000000000..c28c5179f --- /dev/null +++ b/vignettes/statistical_power.Rmd @@ -0,0 +1,208 @@ +--- +title: "Statistical Power" +output: + rmarkdown::html_vignette: + toc: true + fig_width: 10.08 + fig_height: 6 +tags: [r, effect size, power analysis, statistical power] +vignette: > + \usepackage[utf8]{inputenc} + %\VignetteIndexEntry{Statistical Power} + %\VignetteEngine{knitr::rmarkdown} +editor_options: + chunk_output_type: console +bibliography: bibliography.bib +--- + +```{r setup, include=FALSE} +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) +``` + +# Overview + +In this vignette, we focus on statistical power and the role of the `effectsize` _easystats_ package in power analysis. +As such, we are interested in accomplishing several things with this vignette: + + 1. Reviewing statistical power and its value in a research task + 2. Demonstrating the role of the `effectsize` package in the context of exploring statistical power + 3. Highlighting the ease of calculating and understanding of statistical power via the _easystats_ ecosystem, and the `effectsize` package specifically + 4. Encouraging wider adoption of power analysis in applied research + +*Disclaimer:* This vignette is an initial look at power analysis via _easystats_. +There's much more we could do, so please give us a feedback about what features would you like to see in _easystats_ to make power analysis easier. + +## What is statistical power and power analysis? + +Statistical power allows for the ability to check whether an effect observed from a statistical test actually exists, or that the null hypothesis really can be rejected (or not). +Power involves many related concepts including, but not limited to, sample size, estimation, significance threshold, and of course, the *effect size*. + +## What is `effectsize`? + +The goal of the `effectsize` package is to provide utilities to work with indices of effect size and standardized parameters, allowing computation and conversion of indices such as Cohen’s d, r, odds-ratios, among many others. +Please explore the breadth of effect size operations included in the package by visiting the [package docs](https://easystats.github.io/effectsize/reference/index.html). + +## Putting the Pieces Together: Hypothesis Testing + +Let's take a closer looks at the key ingredients involved in statistical power before walking through a simple applied example below. + + 1. *Statistical test*: In research we often start with a statistical test to test expectations or explore data. For example, we might use a t-test to check for differences between two group means. This would help assess whether the difference of means between the groups is likely the same/indistinguishable from zero (null, $H_0$) or not (alternative, $H_A$) + + 2. *Significance threshold*: This is the threshold against which we compare the p-value from our statistical test, which helps determine which hypothesis has the most support (and which we should reject). That is, we need to assess the probability that the result is likely indistinguishable from 0, or whether we have picked up on a likely real difference or result. To this end, if the p-value associated with our test is less than the significance threshold (e.g., $p < 0.05$), then, this tells us that the chance of observing the result we observed due to chance alone is extremely low, and very unlikely. In the case of comparing group mean differences, for example, we would have evidence allowing us to "reject the null hypothesis of no difference," and conclude that there is a greater chance of the group means being significantly different from each other in line with $H_A$. + + 3. *Effect size*: This is the magnitude of difference. A common way to calculate this is via Cohen's $d$, which measures the estimated standardized difference between the means of two populations. There are many other extensions (e.g., correcting for small-sample bias via Hedges' $g$). This is where the `effectsize` package comes in, which allows for easy calculation of many different effect size metrics. + + 4. *Statistical power*: This brings us to statistical power, which can be thought of in many ways, such as the probability that we are *correctly* observing an effect or group difference, or that we are correctly rejecting the null hypothesis, and so on (see, e.g., [@cohen1988], [@greene2000] for more). But regardless of the interpretation, all of these interpretations are all pointing to a common idea: *the ability for us to trust the result we get from the hypothesis test*, regardless of the test. + +Let's put these pieces together with a simple example. +Say we find a "statistically significant" ($p < 0.05$) difference between two group means from a two-sample t-test. +In this case, we might be tempted to stop and conclude that the signal is sufficiently strong to conclude that the groups are different from each other. +But our test could be incorrect for a variety of reasons. +Recall, that the p-value is a *probability*, meaning in part that we could be erroneously rejecting the null hypothesis, or that an insignificant result is insignificant due to a small sample size, and so on. + +> This is where statistical power comes in. + +Statistical power helps us go the next step and more thoroughly assess the probability that the "significant" result we observed is indeed significant, or detect a cause of an insignificant result (e.g., sample size). +In general, *before* beginning a broader analysis, it is a good idea to check for statistical power to ensure that you can trust the results you get from your test(s) downstream, and that your inferences are reliable. + +So this is where we focus in this vignette, and pay special attention to the ease and role of effect size calculation via the `effectsize` package from _easystats_. +The following section walks through a simple applied example to ensure 1) the concepts surrounding and involved in power are clear and digestible, and 2) that the role and value of the `effectsize` package are likewise clear and digestible. +Understanding both of these realities will allow for more complex extensions and applications to a wide array of research problems and questions. + +# Example: Comparing Means of Independant Samples + +In addition to relying on the _easystats_ `effectsize` package for effect size calculation, we will also leverage the simple, but excellent `pwr` package for the following implementation of power analysis [@champley2017]. + +```{r} +library(pwr) +library(effectsize) +``` + +First, let's fit a simple two sample t-test using the mtcars data to explore mean MPG for both transmission groups (`AM`). + +```{r} +t <- t.test(mpg ~ am, data = mtcars) +``` + +There are many power tests supported by `pwr` for different contexts, and we encourage you to take a look and select the appropriate one for your application. +For present purposes of calculating statistical power for our t-test, we will rely on the `pwr.t2n.test()` function. +Here's the basic anatomy: + +```{r, eval = FALSE} +pwr.t2n.test( + n1 = ..., n2 = ..., + d = ..., + sig.level = ..., + power = ..., + alternative = ... +) +``` + +But, before we can get to the power part, we need to collect a few ingredients first, as we can see above. +The ingredients we need include: + + - `d`: effect size + - `n1` and `n2`: sample size (for each sample) + - `sig.level`: significance threshold (e.g., `0.05`) + - `alternative`: direction of the t-test (e.g., greater, lesser, two.sided) + +(By omitting the `power` argument, we are implying that we want the function to estimate that value for us.) + +## Calculate Effect Size + +Given the simplicity of this example and the prevalence of Cohen's $d$, we will rely on this effect size index here. +We have three ways of easily calculating Cohen's $d$ via `effectsize`. + +### Approach 1: `effectsize()` + +The first approach is the simplest. +As previously hinted at, there is a vast literature on different effect size calculations for different applications. +So, if you don't want to track down a specific one, or are unaware of options, you can simply pass the statistical test object to `effectsize()`, and either select the `type`, or leave it blank for "cohens_d", which is the default option. + +*Note*, when using the formula interface to `t.test()`, this method (currently) only gives an approximate effect size. +So for this first simple approach, we update our test (`t_alt`) and then make a call to `effectsize()`. + +```{r eval = FALSE} +t_alt <- t.test(mtcars$mpg[mtcars$am == 0], mtcars$mpg[mtcars$am == 1]) + +effectsize(t_alt, type = "cohens_d") +``` + +*Note*, users can easily store the value and/or CIs as you'd like via, e.g., `cohens_d <- effectsize(t, type = "cohens_d")[[1]]`. + +### Approach 2: `cohens_d()` + +Alternatively, if you knew the index one you wanted to use, you could simply call the associated function directly. For present purposes, we picked Cohen's $d$, so we would call `cohens_d()`. +But there are many other indices supported by `effectsize`. For example, see [here](https://easystats.github.io/effectsize/reference/index.html#standardized-differences) for options for standardized differences. Or see [here](https://easystats.github.io/effectsize/reference/index.html#for-contingency-tables) for options for contingency tables. Or see [here](https://easystats.github.io/effectsize/reference/index.html#comparing-multiple-groups) for options for comparing multiple groups, and so on. + +In our simple case here with a t-test, users are encouraged to use `effectsize()` when working with `htest` objects to ensure proper estimation. +Therefore, with this second approach of using the "named" function, `cohens_d`, users should pass the data directly to the function instead of the `htest` object (e.g., `cohens_d(t)`). + +```{r eval = FALSE} +cohens_d(mpg ~ am, data = mtcars) +``` + +### Approach 3: `t_to_d()` + +When the original underlying data is not available, you may get a warning message like: + +> *Warning: ... Returning an approximate effect size using t_to_d()* + +In these cases, the default behavior of `effectsize` is to make a back-up call to `t_to_d()` (or which ever conversion function is appropriate based on the input). +This step makes the calculation from the t-test to Cohen's $d$. +Given the prevalence of calculating effect sizes for different applications and the many effect size indices available for different contexts, we have anticipated this and baked in this conversion "fail safe" in the architecture of `effectsize` by detecting the input and making the appropriate conversion. +There are many conversions available in the package. +Take a look [here](https://easystats.github.io/effectsize/reference/index.html#effect-size-conversion). + +This can also be dne directly by the user using the `t_to_d()` function: + +```{r} +t_to_d( + t = t$statistic, + df_error = t$parameter +) +``` + +## Statistical Power + +Now we are ready to calculate the statistical power of our t-test given that we have collected the essential ingredients. + +For the present application, the effect size obtained from `cohens_d()` (or any of the three approaches previously described) can be passed to the `d` argument. + +```{r} +(result <- cohens_d(mpg ~ am, data = mtcars)) +(Ns <- table(mtcars$am)) + +pwr.t2n.test( + n1 = Ns[1], n2 = Ns[2], + d = result[["Cohens_d"]], + sig.level = 0.05, + alternative = "two.sided" +) +``` + +The results tell us that we are sufficiently powered, with a very high power for each group, `0.999` and `0.990`. + +Notice, though, if you were to change the group sample sizes to something very small, say `n = c(2, 2)`, then you would get a much lower power, suggesting that your sample size is too small to detect any reliable signal or to be able to trust your results. + +# Example: Contingency Table + + +_To be added._ + +# Example: ANOVA (and Model Comparisons) + + +_To be added._ + +# References From bd6e08feab809cd98fa476462b8de357d6c648bf Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Sat, 6 Jan 2024 21:55:11 +0200 Subject: [PATCH 24/30] close #624 --- R/cohens_g.R | 7 +++---- R/convert_stat_chisq.R | 4 ++-- R/xtab_diff.R | 7 +++---- man/F_to_eta2.Rd | 4 ++-- man/cohens_g.Rd | 7 +++---- man/convert_chisq.Rd | 4 ++-- man/eta_squared.Rd | 4 ++-- man/oddsratio.Rd | 7 +++---- man/phi.Rd | 4 ++-- man/r2_semipartial.Rd | 4 ++-- 10 files changed, 24 insertions(+), 28 deletions(-) diff --git a/R/cohens_g.R b/R/cohens_g.R index a66182002..e219c210e 100644 --- a/R/cohens_g.R +++ b/R/cohens_g.R @@ -8,10 +8,9 @@ #' @inheritParams oddsratio_to_d #' @inheritParams phi #' @param alternative a character string specifying the alternative hypothesis; -#' Controls the type of CI returned: `"two.sided"` (two-sided CI; default), -#' `"greater"` (one-sided CI) or `"less"` (one-sided CI). Partial matching is -#' allowed (e.g., `"g"`, `"l"`, `"two"`...). See *One-Sided CIs* in -#' [effectsize_CIs]. +#' Controls the type of CI returned: `"two.sided"` (default, two-sided CI), +#' `"greater"` or `"less"` (one-sided CI). Partial matching is allowed (e.g., +#' `"g"`, `"l"`, `"two"`...). See *One-Sided CIs* in [effectsize_CIs]. #' @param ... Ignored #' #' @details diff --git a/R/convert_stat_chisq.R b/R/convert_stat_chisq.R index fcf0d57a2..d66df0793 100644 --- a/R/convert_stat_chisq.R +++ b/R/convert_stat_chisq.R @@ -14,8 +14,8 @@ #' @param ci Confidence Interval (CI) level #' @param alternative a character string specifying the alternative hypothesis; #' Controls the type of CI returned: `"greater"` (default) or `"less"` -#' (one-sided CI), or `"two.sided"` (default, two-sided CI). Partial matching -#' is allowed (e.g., `"g"`, `"l"`, `"two"`...). See *One-Sided CIs* in +#' (one-sided CI), or `"two.sided"` (two-sided CI). Partial matching is +#' allowed (e.g., `"g"`, `"l"`, `"two"`...). See *One-Sided CIs* in #' [effectsize_CIs]. #' @param adjust Should the effect size be corrected for small-sample bias? #' Defaults to `TRUE`; Advisable for small samples and large tables. diff --git a/R/xtab_diff.R b/R/xtab_diff.R index 2346f85d6..a3d54b580 100644 --- a/R/xtab_diff.R +++ b/R/xtab_diff.R @@ -14,10 +14,9 @@ #' @inheritParams oddsratio_to_d #' @inheritParams phi #' @param alternative a character string specifying the alternative hypothesis; -#' Controls the type of CI returned: `"two.sided"` (two-sided CI; default), -#' `"greater"` (one-sided CI) or `"less"` (one-sided CI). Partial matching is -#' allowed (e.g., `"g"`, `"l"`, `"two"`...). See *One-Sided CIs* in -#' [effectsize_CIs]. +#' Controls the type of CI returned: `"two.sided"` (default, two-sided CI), +#' `"greater"` or `"less"` (one-sided CI). Partial matching is allowed (e.g., +#' `"g"`, `"l"`, `"two"`...). See *One-Sided CIs* in [effectsize_CIs]. #' @param ... Ignored #' #' @details diff --git a/man/F_to_eta2.Rd b/man/F_to_eta2.Rd index e76aa02eb..5650144f7 100644 --- a/man/F_to_eta2.Rd +++ b/man/F_to_eta2.Rd @@ -63,8 +63,8 @@ t_to_f2(t, df_error, squared = TRUE, ci = 0.95, alternative = "greater", ...) \item{alternative}{a character string specifying the alternative hypothesis; Controls the type of CI returned: \code{"greater"} (default) or \code{"less"} -(one-sided CI), or \code{"two.sided"} (default, two-sided CI). Partial matching -is allowed (e.g., \code{"g"}, \code{"l"}, \code{"two"}...). See \emph{One-Sided CIs} in +(one-sided CI), or \code{"two.sided"} (two-sided CI). Partial matching is +allowed (e.g., \code{"g"}, \code{"l"}, \code{"two"}...). See \emph{One-Sided CIs} in \link{effectsize_CIs}.} \item{...}{Arguments passed to or from other methods.} diff --git a/man/cohens_g.Rd b/man/cohens_g.Rd index 80663d606..a45a4f832 100644 --- a/man/cohens_g.Rd +++ b/man/cohens_g.Rd @@ -16,10 +16,9 @@ cohens_g(x, y = NULL, ci = 0.95, alternative = "two.sided", ...) \item{ci}{Confidence Interval (CI) level} \item{alternative}{a character string specifying the alternative hypothesis; -Controls the type of CI returned: \code{"two.sided"} (two-sided CI; default), -\code{"greater"} (one-sided CI) or \code{"less"} (one-sided CI). Partial matching is -allowed (e.g., \code{"g"}, \code{"l"}, \code{"two"}...). See \emph{One-Sided CIs} in -\link{effectsize_CIs}.} +Controls the type of CI returned: \code{"two.sided"} (default, two-sided CI), +\code{"greater"} or \code{"less"} (one-sided CI). Partial matching is allowed (e.g., +\code{"g"}, \code{"l"}, \code{"two"}...). See \emph{One-Sided CIs} in \link{effectsize_CIs}.} \item{...}{Ignored} } diff --git a/man/convert_chisq.Rd b/man/convert_chisq.Rd index 68da11c29..8d6486892 100644 --- a/man/convert_chisq.Rd +++ b/man/convert_chisq.Rd @@ -82,8 +82,8 @@ Defaults to \code{TRUE}; Advisable for small samples and large tables.} \item{alternative}{a character string specifying the alternative hypothesis; Controls the type of CI returned: \code{"greater"} (default) or \code{"less"} -(one-sided CI), or \code{"two.sided"} (default, two-sided CI). Partial matching -is allowed (e.g., \code{"g"}, \code{"l"}, \code{"two"}...). See \emph{One-Sided CIs} in +(one-sided CI), or \code{"two.sided"} (two-sided CI). Partial matching is +allowed (e.g., \code{"g"}, \code{"l"}, \code{"two"}...). See \emph{One-Sided CIs} in \link{effectsize_CIs}.} \item{...}{Arguments passed to or from other methods.} diff --git a/man/eta_squared.Rd b/man/eta_squared.Rd index 87c37b170..e82300543 100644 --- a/man/eta_squared.Rd +++ b/man/eta_squared.Rd @@ -91,8 +91,8 @@ from the fitted model, if they were provided during fitting.} \item{alternative}{a character string specifying the alternative hypothesis; Controls the type of CI returned: \code{"greater"} (default) or \code{"less"} -(one-sided CI), or \code{"two.sided"} (default, two-sided CI). Partial matching -is allowed (e.g., \code{"g"}, \code{"l"}, \code{"two"}...). See \emph{One-Sided CIs} in +(one-sided CI), or \code{"two.sided"} (two-sided CI). Partial matching is +allowed (e.g., \code{"g"}, \code{"l"}, \code{"two"}...). See \emph{One-Sided CIs} in \link{effectsize_CIs}.} \item{verbose}{Toggle warnings and messages on or off.} diff --git a/man/oddsratio.Rd b/man/oddsratio.Rd index cf4810cc4..e8c8c1de3 100644 --- a/man/oddsratio.Rd +++ b/man/oddsratio.Rd @@ -28,10 +28,9 @@ nnt(x, y = NULL, ci = 0.95, alternative = "two.sided", ...) \item{ci}{Confidence Interval (CI) level} \item{alternative}{a character string specifying the alternative hypothesis; -Controls the type of CI returned: \code{"two.sided"} (two-sided CI; default), -\code{"greater"} (one-sided CI) or \code{"less"} (one-sided CI). Partial matching is -allowed (e.g., \code{"g"}, \code{"l"}, \code{"two"}...). See \emph{One-Sided CIs} in -\link{effectsize_CIs}.} +Controls the type of CI returned: \code{"two.sided"} (default, two-sided CI), +\code{"greater"} or \code{"less"} (one-sided CI). Partial matching is allowed (e.g., +\code{"g"}, \code{"l"}, \code{"two"}...). See \emph{One-Sided CIs} in \link{effectsize_CIs}.} \item{log}{Take in or output the log of the ratio (such as in logistic models), e.g. when the desired input or output are log odds ratios instead odds ratios.} diff --git a/man/phi.Rd b/man/phi.Rd index ee63c9008..712b9bd85 100644 --- a/man/phi.Rd +++ b/man/phi.Rd @@ -56,8 +56,8 @@ Defaults to \code{TRUE}; Advisable for small samples and large tables.} \item{alternative}{a character string specifying the alternative hypothesis; Controls the type of CI returned: \code{"greater"} (default) or \code{"less"} -(one-sided CI), or \code{"two.sided"} (default, two-sided CI). Partial matching -is allowed (e.g., \code{"g"}, \code{"l"}, \code{"two"}...). See \emph{One-Sided CIs} in +(one-sided CI), or \code{"two.sided"} (two-sided CI). Partial matching is +allowed (e.g., \code{"g"}, \code{"l"}, \code{"two"}...). See \emph{One-Sided CIs} in \link{effectsize_CIs}.} \item{...}{Ignored.} diff --git a/man/r2_semipartial.Rd b/man/r2_semipartial.Rd index a8246d49a..6ab6019e2 100644 --- a/man/r2_semipartial.Rd +++ b/man/r2_semipartial.Rd @@ -23,8 +23,8 @@ r2_semipartial( \item{alternative}{a character string specifying the alternative hypothesis; Controls the type of CI returned: \code{"greater"} (default) or \code{"less"} -(one-sided CI), or \code{"two.sided"} (default, two-sided CI). Partial matching -is allowed (e.g., \code{"g"}, \code{"l"}, \code{"two"}...). See \emph{One-Sided CIs} in +(one-sided CI), or \code{"two.sided"} (two-sided CI). Partial matching is +allowed (e.g., \code{"g"}, \code{"l"}, \code{"two"}...). See \emph{One-Sided CIs} in \link{effectsize_CIs}.} \item{...}{Arguments passed to or from other methods.} From 20426e53c2789b57bba436cc5b69d296e261abc5 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" <35330040+mattansb@users.noreply.github.com> Date: Fri, 19 Jan 2024 13:07:55 +0200 Subject: [PATCH 25/30] Add adjust argument to d and delta (#626) --- DESCRIPTION | 2 +- NEWS.md | 2 ++ R/cohens_d.R | 41 +++++++++++++++++---------------- R/sysdata.rda | Bin 1342 -> 1341 bytes data-raw/es_info.R | 1 + man/cohens_d.Rd | 6 +++++ tests/testthat/test-cohens_d.R | 9 ++++++++ 7 files changed, 40 insertions(+), 21 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d3cadf728..45c7a283d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: effectsize Title: Indices of Effect Size -Version: 0.8.6.4 +Version: 0.8.6.5 Authors@R: c(person(given = "Mattan S.", family = "Ben-Shachar", diff --git a/NEWS.md b/NEWS.md index bfd8f3f00..4fa674822 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,8 @@ ## New features +- `cohens_d()` and `glass_delta()` gain an `adjust` argument for applying Hedges' small-sample bias correction (`hedges_g()` is now an alias for `cohens_d(adjust = TRUE)`). + - `repeated_measures_d()` to compute standardized mean differences (SMD) for repeated measures data. - Also supported in `effectsize()` diff --git a/R/cohens_d.R b/R/cohens_d.R index f778e6242..0bf528bab 100644 --- a/R/cohens_d.R +++ b/R/cohens_d.R @@ -26,6 +26,9 @@ #' @param paired If `TRUE`, the values of `x` and `y` are considered as paired. #' This produces an effect size that is equivalent to the one-sample effect #' size on `x - y`. See also [repeated_measures_d()] for more options. +#' @param adjust Should the effect size be adjusted for small-sample bias using +#' Hedges' method? Note that `hedges_g()` is an alias for +#' `cohens_d(adjust = TRUE)`. #' @param ... Arguments passed to or from other methods. When `x` is a formula, #' these can be `subset` and `na.action`. #' @inheritParams chisq_to_phi @@ -133,6 +136,7 @@ #' @export cohens_d <- function(x, y = NULL, data = NULL, pooled_sd = TRUE, mu = 0, paired = FALSE, + adjust = FALSE, ci = 0.95, alternative = "two.sided", verbose = TRUE, ...) { var.equal <- eval.parent(match.call()[["var.equal"]]) @@ -141,7 +145,7 @@ cohens_d <- function(x, y = NULL, data = NULL, .effect_size_difference( x, y = y, data = data, - type = "d", + type = "d", adjust = adjust, pooled_sd = pooled_sd, mu = mu, paired = paired, ci = ci, alternative = alternative, verbose = verbose, @@ -155,31 +159,23 @@ hedges_g <- function(x, y = NULL, data = NULL, pooled_sd = TRUE, mu = 0, paired = FALSE, ci = 0.95, alternative = "two.sided", verbose = TRUE, ...) { - var.equal <- eval.parent(match.call()[["var.equal"]]) - if (!is.null(var.equal)) pooled_sd <- var.equal - - .effect_size_difference( - x, - y = y, data = data, - type = "g", - pooled_sd = pooled_sd, mu = mu, paired = paired, - ci = ci, alternative = alternative, - verbose = verbose, - ... - ) + cl <- match.call() + cl[[1]] <- quote(cohens_d) + cl$adjust <- TRUE + eval.parent(cl) } #' @rdname cohens_d #' @export glass_delta <- function(x, y = NULL, data = NULL, - mu = 0, + mu = 0, adjust = FALSE, ci = 0.95, alternative = "two.sided", verbose = TRUE, ...) { .effect_size_difference( x, y = y, data = data, type = "delta", - mu = mu, + mu = mu, adjust = adjust, ci = ci, alternative = alternative, verbose = verbose, pooled_sd = NULL, paired = FALSE, @@ -191,10 +187,12 @@ glass_delta <- function(x, y = NULL, data = NULL, #' @keywords internal .effect_size_difference <- function(x, y = NULL, data = NULL, - type = "d", + type = "d", adjust = FALSE, mu = 0, pooled_sd = TRUE, paired = FALSE, ci = 0.95, alternative = "two.sided", verbose = TRUE, ...) { + if (type == "d" && adjust) type <- "g" + if (type != "delta") { if (.is_htest_of_type(x, "t-test")) { return(effectsize(x, type = type, verbose = verbose, ...)) @@ -294,16 +292,19 @@ glass_delta <- function(x, y = NULL, data = NULL, } - if (type == "g") { + if (adjust) { J <- .J(df) + col_to_adjust <- intersect(colnames(out), c(types[type], "CI_low", "CI_high")) + out[, col_to_adjust] <- out[, col_to_adjust] * J - out[, colnames(out) %in% c("Hedges_g", "CI_low", "CI_high")] <- - out[, colnames(out) %in% c("Hedges_g", "CI_low", "CI_high")] * J + if (type == "delta") { + colnames(out)[1] <- "Glass_delta_adjusted" + } } class(out) <- c("effectsize_difference", "effectsize_table", "see_effectsize_table", class(out)) .someattributes(out) <- .nlist( - paired, pooled_sd, mu, ci, ci_method, alternative, + paired, pooled_sd, mu, ci, ci_method, alternative, adjust, approximate = FALSE ) return(out) diff --git a/R/sysdata.rda b/R/sysdata.rda index 50806d5790d96ab6b2573e8cdf00627330d48495..24b21355fd2b123f7cea6848f426817b807133af 100644 GIT binary patch delta 1336 zcmV-81;_fn3cU&)LRx4!F+o`-Q&~12$p z0Gc#S22CbMq|u1Uqf<39e`wK&^$#hADD^y}WHM@K0MkD;7D6h?A&ALDG1@v80}lub z+E_rKz^WxkXrz{v6P1ODB<|j_NlJ+=Qc2%&?%Lk{=_V>7j$T-$qqqO9AfHW0ej0OJ zAs#N{PwuaFy#2dh=eOTJ>sve=>V!`j;yhjL)>nP6xNO+^mRoXof7Wqm+q>`6!GA4u zuZgzYVSGt?px&sRER?h8c$!QpnP-*tvaV!(*=}@SBjssnD_$&Ev0PxM^D;8r+;bW3 z}gCKcrq_9S>$9{ST9-QT%31w6?RrvlKNcav^26WaL&a5 z_hLjTB#GFlmMTb#f30E&`6@&ndO|3IMF@-l5s-p{l0}e%83AO1gi?RJbcCNKNidKD zpddk>p!um(>+JTpcbuljFPEyhRcfnR%eYos+hX;OhXUpfH+96Z_NgQ1Sz`45&J23%*E;K3e=;|2T_%qW_a*ZKs?7UU zLj+Jm8(H%Lkk*bVsI51aRjWr}loFy~7?=;w?0PGqQ9i0X6qA{ak0I19bKFle>0Xzg zsc!ep-@u@s(9r9)^2|H=-u%0}wR^nTD`wUBHas`9wYFlXGUc6vQ^386 zt(>ysLYOt5e_6xfMMJYQzlaisyCi#L%H&H)fwr49<3Vh5If2GLKToif>8qzL?Oar8%l8PwO z)rMWo^9I}US-Lijqvfo7n5yN}T&0wkDE4rwS-m259>SF59+uP0lSY+OFzjv#$qgMg z>wu4p@|?|w#H6y6v*Ix~45{`{2BhF~(mcneStE$wW;omiQ`9;|>=QA+m6jx@0ZLK8 zdZqs!e+CMrZiXpyqS#=$%`qf!?W&#;nr|lxaH=ILXf>Fb(n-jMoM9Oa)?QHQ67!^9 zCRXx_6q*iO4J~&_lE%tflJyggjOI@;{I{OH9|OwwlgjNHp{cDkPTqG>DHpdaDP)R= zPiH>yd`X`ai<0Feu%yR_0UPHF#%%=>I56d}e}|_MS#jHeb7VCijh!)3#*Sgvc9tG# zH(HNy%J^5Otj~`NiGj)A7@3~~p0PS*6j8Hy%s5IfW$B*f7p5qkt+mfs?mZ&PEDIFU z!Ge}xoaH&HUQ#epvL%N&z_aBV*^N-5U|ex@HN$cz5inWW(78%&nDdaKc*BfY1r`iY ze^nwX3k90Eo^+H=q>O?(zN8Jq&~HNm%X5&_X-VwTKb1+_ z=Y%a&MD}>JN|eqox58U6WV&6=#kqe&Cd$~^Wh;nd@wW8SR<)(xCp$hCyaH8e?I^K0000z zHV8;So`EqiCPqdkBLE4bCYb=hm;fUq6C+Gw8~_7A0MHo#00Te(X`lcA00Te{00E!? zXbgY=0iXah&;S4c0iXjHq^k0002c00000000lw4gdk50B8(=00E!?G|&J5 z00E!@Qb-^O&=mB_dJ_?&e?!zYJw|BKG|8qW#WN8PC~XX;ngBEYf2vhTl~qwAilnt2 zTD5=NhW^mo%@DGIRU)J`QcFsS=3!|PPUY()l&F%`B%TLTcGmXqi7`|Zab=2HK0p6x z6TMO&hMd<(5#jB$_iNeve7`05d2RQ~tnhQ{NKX;rJU#u^SAn(Le>XQD&1JUdiS)Vp zc4PPIVtlX=;fuI=Y^=knU;9pTPo&9^viS5ez(NZ(pJ_iSg~AS zr}8o~+}Pu1yNO3|rghm_T?UM0?0>D+eT^xDse>Z&^`BEB%E5Zi;<-Hgx=On%D(g5I z+8D2K&b>(_p3EW@e+d(>Q7lwMU26d!4I&RMB2_4)swF52REVl7l1ix&Qjrx+`o94Yv;tir}kNTGn08S#QY2=p7Cv%pE6n$g%dRBj;IS z`h`_dVvBo?>ytySQf(e`mJOXWs&_bk97Wh|x2V8puGebkxZ|u!6@Mv~r-Oa1r_Ux^9zkQk7+b~kfdj@yV zy@92evg3VBe;QA$-fy(CG8TO^W~a*W8rZbf`+`jzJ^ZJRZIf-8k+xZ#sNh`MHw?$% z-fy^^jVx56l$7OYDWjvk)_W>X%uPf1gzvCN|fs>H=9Lgnsf ztnV;J4Kiz$R8o$|1E4rjz+nG~_0o74SMHFdj z!!FJP2HUk}=+6aE6Yvb;d`) zc+Pg?-cnggS??H|45{`{2C2sAqHq}quGfm{=PDMneO$O14o+O*_(~Kh_y36JcsV_RE*g)EU!>uz*! z7sQ$INVzUjOA1VRFcH9VJSMQBM;;tY;nImLf4KO;b8;GwZJjYu)JHh=-Ia%uP1d8Z zWqx((=(FR<{ZAQqPsKIAvLggt$(W9nODi#5t+8CdTnl1%ST)kQI_WWQKcs}L&ZWqt;9eO zApqdJRN}y`fO!u96a^TGpl|zRhwg@9W)Q;)E|$*zwbJi<-7$BM_R1Hl`VR7fjF5&& v0|G(-W(G(TeJMdC4jzO8c;~@KPnq4U6LL@zog|4h7x=r9DZ+$?gU$ok-THh| diff --git a/data-raw/es_info.R b/data-raw/es_info.R index 88044de67..401a991da 100644 --- a/data-raw/es_info.R +++ b/data-raw/es_info.R @@ -4,6 +4,7 @@ es_info <- tibble::tribble( "Cohens_d", "Cohen's d", NA, "twotail", -Inf, Inf, 0, "Hedges_g", "Hedges' g", NA, "twotail", -Inf, Inf, 0, "Glass_delta", "Glass' delta", "Glass' \u0394", "twotail", -Inf, Inf, 0, + "Glass_delta_adjusted", "Glass' delta (adj.)", "Glass' \u0394 (adj.)", "twotail", -Inf, Inf, 0, "d_rm", "d (rm)", "d\u1D63\u2098", "twotail", -Inf, Inf, 0, "d_av", "d (av)", "d\u2090\u1D65", "twotail", -Inf, Inf, 0, "d_z", "d (z)", NA, "twotail", -Inf, Inf, 0, diff --git a/man/cohens_d.Rd b/man/cohens_d.Rd index 90d7b1c81..60236654e 100644 --- a/man/cohens_d.Rd +++ b/man/cohens_d.Rd @@ -13,6 +13,7 @@ cohens_d( pooled_sd = TRUE, mu = 0, paired = FALSE, + adjust = FALSE, ci = 0.95, alternative = "two.sided", verbose = TRUE, @@ -37,6 +38,7 @@ glass_delta( y = NULL, data = NULL, mu = 0, + adjust = FALSE, ci = 0.95, alternative = "two.sided", verbose = TRUE, @@ -61,6 +63,10 @@ variance). Else the mean SD from both groups is used instead.} This produces an effect size that is equivalent to the one-sample effect size on \code{x - y}. See also \code{\link[=repeated_measures_d]{repeated_measures_d()}} for more options.} +\item{adjust}{Should the effect size be adjusted for small-sample bias using +Hedges' method? Note that \code{hedges_g()} is an alias for +\code{cohens_d(adjust = TRUE)}.} + \item{ci}{Confidence Interval (CI) level} \item{alternative}{a character string specifying the alternative hypothesis; diff --git a/tests/testthat/test-cohens_d.R b/tests/testthat/test-cohens_d.R index a412a20a4..f79031d67 100644 --- a/tests/testthat/test-cohens_d.R +++ b/tests/testthat/test-cohens_d.R @@ -54,6 +54,9 @@ test_that("hedges_g (and other bias correction things", { expect_equal(x[[1]], 1.844, tolerance = 0.001) expect_equal(x$CI_low, 1.004, tolerance = 0.001) expect_equal(x$CI_high, 2.664, tolerance = 0.001) + + x2 <- cohens_d(wt ~ am, data = mtcars, adjust = TRUE) + expect_equal(x2, x) }) test_that("glass_delta", { @@ -66,6 +69,12 @@ test_that("glass_delta", { expect_equal(x[[1]], 2.200, tolerance = 0.001) expect_equal(x$CI_low, 1.008664, tolerance = 0.001) expect_equal(x$CI_high, 3.352597, tolerance = 0.001) + + x2 <- glass_delta(wt ~ am, data = mtcars, adjust = TRUE) + expect_equal(colnames(x2)[1], "Glass_delta_adjusted") + expect_lt(x2[[1]], x[[1]]) + expect_lt(x2$CI_low, x$CI_low) + expect_lt(x2$CI_high, x$CI_high) }) From c3be95df2273c8cff80aa49f8ec01f9cbd3cda43 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Fri, 19 Jan 2024 20:50:39 +0200 Subject: [PATCH 26/30] default to adjust = TRUE in delta --- R/cohens_d.R | 2 +- tests/testthat/test-cohens_d.R | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/R/cohens_d.R b/R/cohens_d.R index 0bf528bab..617e7c654 100644 --- a/R/cohens_d.R +++ b/R/cohens_d.R @@ -168,7 +168,7 @@ hedges_g <- function(x, y = NULL, data = NULL, #' @rdname cohens_d #' @export glass_delta <- function(x, y = NULL, data = NULL, - mu = 0, adjust = FALSE, + mu = 0, adjust = TRUE, ci = 0.95, alternative = "two.sided", verbose = TRUE, ...) { .effect_size_difference( diff --git a/tests/testthat/test-cohens_d.R b/tests/testthat/test-cohens_d.R index f79031d67..ae1a763de 100644 --- a/tests/testthat/test-cohens_d.R +++ b/tests/testthat/test-cohens_d.R @@ -64,13 +64,13 @@ test_that("glass_delta", { expect_error(glass_delta(1:10), "two") expect_error(glass_delta("wt", data = mtcars), "two") - x <- glass_delta(wt ~ am, data = mtcars) + x <- glass_delta(wt ~ am, data = mtcars, adjust = FALSE) expect_equal(colnames(x)[1], "Glass_delta") expect_equal(x[[1]], 2.200, tolerance = 0.001) expect_equal(x$CI_low, 1.008664, tolerance = 0.001) expect_equal(x$CI_high, 3.352597, tolerance = 0.001) - x2 <- glass_delta(wt ~ am, data = mtcars, adjust = TRUE) + x2 <- glass_delta(wt ~ am, data = mtcars) expect_equal(colnames(x2)[1], "Glass_delta_adjusted") expect_lt(x2[[1]], x[[1]]) expect_lt(x2$CI_low, x$CI_low) From af6dfbabb3b003b3c80ebfda172f120f64cf949b Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" <35330040+mattansb@users.noreply.github.com> Date: Mon, 29 Jan 2024 15:38:46 +0200 Subject: [PATCH 27/30] Better ncp ci optimization (#629) * use q* instead of p* * v bump * update docs --- DESCRIPTION | 2 +- NEWS.md | 1 + R/docs_extra.R | 9 ++------- R/utils_ci.R | 41 ++++++++++++++++----------------------- man/cohens_d.Rd | 2 +- man/effectsize-package.Rd | 1 + man/effectsize_CIs.Rd | 12 ++---------- 7 files changed, 25 insertions(+), 43 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 45c7a283d..6446df71f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: effectsize Title: Indices of Effect Size -Version: 0.8.6.5 +Version: 0.8.6.6 Authors@R: c(person(given = "Mattan S.", family = "Ben-Shachar", diff --git a/NEWS.md b/NEWS.md index 4fa674822..8fe69bac8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -11,6 +11,7 @@ ## Bug fixes +- Minor stability fix to ncp-based CI methods ( #628 ) - `nnt()` now properly accepts the `y` argument. # effectsize 0.8.7 diff --git a/R/docs_extra.R b/R/docs_extra.R index 39249d9ff..cb133e6bc 100644 --- a/R/docs_extra.R +++ b/R/docs_extra.R @@ -124,13 +124,8 @@ #' smaller than the tolerance of the optimizer, resulting in CIs of width 0. #' This can also result in the estimated CIs excluding the point estimate. #' -#' For example: -#' ```{r} -#' t_to_d(80, df_error = 4555555) -#' ``` -#' -#' In these cases, consider an alternative optimizer, or an alternative method -#' for computing CIs, such as the bootstrap. +#' In these cases, consider an alternative method for computing CIs, such as the +#' bootstrap. #' #' #' @references diff --git a/R/utils_ci.R b/R/utils_ci.R index 20950705b..9f36db721 100644 --- a/R/utils_ci.R +++ b/R/utils_ci.R @@ -15,10 +15,8 @@ ncp <- suppressWarnings(stats::optim( par = 1.1 * rep(lambda, 2), fn = function(x) { - p <- stats::pf(q = f, df, df_error, ncp = x) - - abs(max(p) - probs[2]) + - abs(min(p) - probs[1]) + q <- stats::qf(p = probs, df, df_error, ncp = x) + sum(abs(q - f)) }, control = list(abstol = 1e-09) )) @@ -37,10 +35,9 @@ #' @keywords internal .get_ncp_t <- function(t, df_error, conf.level = 0.95) { - # # Note: these aren't actually needed - all t related functions would fail earlier - # if (!is.finite(t) || !is.finite(df_error)) { - # return(c(NA, NA)) - # } + if (!is.finite(t) || !is.finite(df_error)) { + return(c(NA, NA)) + } alpha <- 1 - conf.level probs <- c(alpha / 2, 1 - alpha / 2) @@ -48,45 +45,41 @@ ncp <- suppressWarnings(stats::optim( par = 1.1 * rep(t, 2), fn = function(x) { - p <- stats::pt(q = t, df = df_error, ncp = x) - - abs(max(p) - probs[2]) + - abs(min(p) - probs[1]) + q <- stats::qt(p = probs, df = df_error, ncp = x) + sum(abs(q - t)) }, control = list(abstol = 1e-09) )) + t_ncp <- unname(sort(ncp$par)) return(t_ncp) } #' @keywords internals -.get_ncp_chi <- function(chi, df, conf.level = 0.95) { - # # Note: these aren't actually needed - all chisq related functions would fail earlier - # if (!is.finite(chi) || !is.finite(df)) { - # return(c(NA, NA)) - # } +.get_ncp_chi <- function(chisq, df, conf.level = 0.95) { + if (!is.finite(chisq) || !is.finite(df)) { + return(c(NA, NA)) + } alpha <- 1 - conf.level probs <- c(alpha / 2, 1 - alpha / 2) ncp <- suppressWarnings(stats::optim( - par = 1.1 * rep(chi, 2), + par = 1.1 * rep(chisq, 2), fn = function(x) { - p <- stats::pchisq(q = chi, df, ncp = x) - - abs(max(p) - probs[2]) + - abs(min(p) - probs[1]) + q <- stats::qchisq(p = probs, df, ncp = x) + sum(abs(q - chisq)) }, control = list(abstol = 1e-09) )) chi_ncp <- sort(ncp$par) - if (chi <= stats::qchisq(probs[1], df)) { + if (chisq <= stats::qchisq(probs[1], df)) { chi_ncp[2] <- 0 } - if (chi <= stats::qchisq(probs[2], df)) { + if (chisq <= stats::qchisq(probs[2], df)) { chi_ncp[1] <- 0 } diff --git a/man/cohens_d.Rd b/man/cohens_d.Rd index 60236654e..6a67d0b3b 100644 --- a/man/cohens_d.Rd +++ b/man/cohens_d.Rd @@ -38,7 +38,7 @@ glass_delta( y = NULL, data = NULL, mu = 0, - adjust = FALSE, + adjust = TRUE, ci = 0.95, alternative = "two.sided", verbose = TRUE, diff --git a/man/effectsize-package.Rd b/man/effectsize-package.Rd index 30c9a4414..6cd2eb230 100644 --- a/man/effectsize-package.Rd +++ b/man/effectsize-package.Rd @@ -47,6 +47,7 @@ Authors: \item Indrajeet Patil \email{patilindrajeet.science@gmail.com} (\href{https://orcid.org/0000-0003-1995-6531}{ORCID}) (@patilindrajeets) \item Brenton M. Wiernik \email{brenton@wiernik.org} (\href{https://orcid.org/0000-0001-9560-6336}{ORCID}) (@bmwiernik) \item Rémi Thériault \email{remi.theriault@mail.mcgill.ca} (\href{https://orcid.org/0000-0003-4315-6788}{ORCID}) (@rempsyc) + \item Philip Waggoner \email{philip.waggoner@gmail.com} (\href{https://orcid.org/0000-0002-7825-7573}{ORCID}) [contributor] } Other contributors: diff --git a/man/effectsize_CIs.Rd b/man/effectsize_CIs.Rd index 8f848c601..db30b81ca 100644 --- a/man/effectsize_CIs.Rd +++ b/man/effectsize_CIs.Rd @@ -155,16 +155,8 @@ For very large sample sizes or effect sizes, the width of the CI can be smaller than the tolerance of the optimizer, resulting in CIs of width 0. This can also result in the estimated CIs excluding the point estimate. -For example: - -\if{html}{\out{
}}\preformatted{t_to_d(80, df_error = 4555555) -#> d | 95\% CI -#> ------------------- -#> 0.07 | [0.08, 0.08] -}\if{html}{\out{
}} - -In these cases, consider an alternative optimizer, or an alternative method -for computing CIs, such as the bootstrap. +In these cases, consider an alternative method for computing CIs, such as the +bootstrap. } \references{ From dc30fbb57d361350378322e618cbe83d716b67be Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Wed, 21 Feb 2024 16:39:44 +0200 Subject: [PATCH 28/30] Update test-convert_statistic.R --- tests/testthat/test-convert_statistic.R | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/testthat/test-convert_statistic.R b/tests/testthat/test-convert_statistic.R index 8cffc295b..2f78c11fa 100644 --- a/tests/testthat/test-convert_statistic.R +++ b/tests/testthat/test-convert_statistic.R @@ -93,4 +93,9 @@ test_that("eta2", { expect_equal(resf[[1]]^2, res[[1]] / (1 - res[[1]]), ignore_attr = TRUE) expect_equal(F_to_f(4, 3, 123), F_to_f2(4, 3, 123, squared = FALSE)) expect_equal(F_to_f2(4, 3, 123), F_to_f(4, 3, 123, squared = TRUE)) + + res <- F_to_eta2(3.23, 1, 137) + expect_equal(res[[1]], 3.23 / (3.23 + 137)) + expect_equal(res$CI_low, 0) + expect_equal(res$CI_high, 1) }) From a579a5093549be2edc264e2d1da95726ff4f4369 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:40:47 +0530 Subject: [PATCH 29/30] [create-pull-request] automated change (#633) Co-authored-by: IndrajeetPatil <11330453+IndrajeetPatil@users.noreply.github.com> --- DESCRIPTION | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6446df71f..38597d413 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -71,11 +71,11 @@ BugReports: https://github.com/easystats/effectsize/issues/ Depends: R (>= 3.6) Imports: - bayestestR (>= 0.13.1), - insight (>= 0.19.7), - parameters (>= 0.21.3), - performance (>= 0.10.8), - datawizard (>= 0.9.0), + bayestestR (>= 0.13.2), + insight (>= 0.19.8), + parameters (>= 0.21.5), + performance (>= 0.10.9), + datawizard (>= 0.9.1), stats, utils Suggests: From 6114f44ece1827b0245c62a38a95ef6fd06742a5 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" <35330040+mattansb@users.noreply.github.com> Date: Mon, 1 Apr 2024 10:58:24 +0300 Subject: [PATCH 30/30] prep for CRAN 0.8.7 (#634) * prep for CRAN * spelling * Update cran-comments.md --- DESCRIPTION | 10 +++++----- NEWS.md | 14 ++++---------- R/utils_validate_input_data.R | 2 +- cran-comments.md | 2 +- inst/WORDLIST | 17 +++++++++++------ man/RCT_table.Rd | 2 +- man/Smoking_FASD.Rd | 2 +- man/effectsize-package.Rd | 1 - man/food_class.Rd | 2 +- man/hardlyworking.Rd | 2 +- man/rouder2016.Rd | 2 +- man/screening_test.Rd | 2 +- vignettes/statistical_power.Rmd | 4 ++-- 13 files changed, 30 insertions(+), 32 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 38597d413..ad5a83029 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: effectsize Title: Indices of Effect Size -Version: 0.8.6.6 +Version: 0.8.7 Authors@R: c(person(given = "Mattan S.", family = "Ben-Shachar", @@ -72,9 +72,9 @@ Depends: R (>= 3.6) Imports: bayestestR (>= 0.13.2), - insight (>= 0.19.8), - parameters (>= 0.21.5), - performance (>= 0.10.9), + insight (>= 0.19.9), + parameters (>= 0.21.6), + performance (>= 0.11.0), datawizard (>= 0.9.1), stats, utils @@ -105,7 +105,7 @@ VignetteBuilder: Encoding: UTF-8 Language: en-US Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3.9000 +RoxygenNote: 7.3.1 Config/testthat/edition: 3 Config/testthat/parallel: true Config/Needs/website: diff --git a/NEWS.md b/NEWS.md index 8fe69bac8..4fb1b81f3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,25 +1,19 @@ -# effectsize 0.8.7.xxx +# effectsize 0.8.7 - This release changes the licensing model of `{effectsize}` to an MIT license. ## New features -- `cohens_d()` and `glass_delta()` gain an `adjust` argument for applying Hedges' small-sample bias correction (`hedges_g()` is now an alias for `cohens_d(adjust = TRUE)`). - +- `cohens_d()` and `glass_delta()` gain an `adjust` argument for applying Hedges' small-sample bias correction (`hedges_g()` is now an alias for `cohens_d(adjust = TRUE)`). - `repeated_measures_d()` to compute standardized mean differences (SMD) for repeated measures data. - - Also supported in `effectsize()` + - Also supported in `effectsize()` +- New function: `interpret_fei()` ## Bug fixes - Minor stability fix to ncp-based CI methods ( #628 ) - `nnt()` now properly accepts the `y` argument. -# effectsize 0.8.7 - -## New features - -- New function: `interpret_fei()` - # effectsize 0.8.6 This is a minor update to bring `effectsize` in-line with the formula methods diff --git a/R/utils_validate_input_data.R b/R/utils_validate_input_data.R index 0aa5e2f14..089d702ac 100644 --- a/R/utils_validate_input_data.R +++ b/R/utils_validate_input_data.R @@ -12,7 +12,7 @@ if (length(x) != 3L) { insight::format_error( "Formula must have one of the following forms:", - " y ~ group (independant samples)", + " y ~ group (independent samples)", " y ~ 1 (one sample)", " Pair(x,y) ~ 1 (paired samples)" ) diff --git a/cran-comments.md b/cran-comments.md index 24b7a9cfc..1e4601ce3 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -6,7 +6,7 @@ ## Test environments -* local installation: R 4.3.1 on Windows +* local installation: R 4.3.2 on Windows * GitHub Actions - Windows: release - macOS: release diff --git a/inst/WORDLIST b/inst/WORDLIST index a02cc55d5..15aff4260 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -49,7 +49,6 @@ Falk Faraggi Fei Fo -Fum Funder GFI Gelman @@ -82,8 +81,6 @@ Kiesser Koo Kruschke LMM -Labelled -labelled Lajeunesse Lakens Landis @@ -126,6 +123,7 @@ Penfield PloS Psychometrika Psychonomic +Pustejovsky RFI RMR RMSEA @@ -137,17 +135,21 @@ Ringle Rosenthal Rothstein Rouder +Rouder's Routledge Ruscio SDs SEM +SMD SRMR Sarstedt Sawilowsky Schumacker Schweder Shachar +Shadish Shmekels +Speckman Steiger Szodorai Szumilas @@ -172,6 +174,7 @@ anova arXiv arcsin biserial +blogspot bmwiernik brglm brms @@ -189,21 +192,24 @@ doi dynamicfit easystats effectSize +effectsize’ et fixest frac friedman ggstatsplot -github glmmadmb gtsummary homoscedasticity +http https +independant infty intraclass -io +jeffrouder joss kruskal +labelled lifecycle lm mattansb @@ -233,7 +239,6 @@ rescale rmANOVA sd semipartial -shinyapps statswiki strengejacke th diff --git a/man/RCT_table.Rd b/man/RCT_table.Rd index bf1e74266..8cad2ccff 100644 --- a/man/RCT_table.Rd +++ b/man/RCT_table.Rd @@ -20,8 +20,8 @@ Fictional Results from a Workers' Randomized Control Trial } \seealso{ Other effect size datasets: -\code{\link{Music_preferences2}}, \code{\link{Music_preferences}}, +\code{\link{Music_preferences2}}, \code{\link{Smoking_FASD}}, \code{\link{food_class}}, \code{\link{hardlyworking}}, diff --git a/man/Smoking_FASD.Rd b/man/Smoking_FASD.Rd index ec24a35fa..eee90e589 100644 --- a/man/Smoking_FASD.Rd +++ b/man/Smoking_FASD.Rd @@ -18,8 +18,8 @@ Fictional data. } \seealso{ Other effect size datasets: -\code{\link{Music_preferences2}}, \code{\link{Music_preferences}}, +\code{\link{Music_preferences2}}, \code{\link{RCT_table}}, \code{\link{food_class}}, \code{\link{hardlyworking}}, diff --git a/man/effectsize-package.Rd b/man/effectsize-package.Rd index 6cd2eb230..128f4fa50 100644 --- a/man/effectsize-package.Rd +++ b/man/effectsize-package.Rd @@ -3,7 +3,6 @@ \docType{package} \name{effectsize-package} \alias{effectsize-package} -\alias{_PACKAGE} \title{effectsize: Indices of Effect Size} \description{ In both theoretical and applied research, it is often of interest to assess diff --git a/man/food_class.Rd b/man/food_class.Rd index 1bc5576eb..eae288fa9 100644 --- a/man/food_class.Rd +++ b/man/food_class.Rd @@ -19,8 +19,8 @@ Fictional data. } \seealso{ Other effect size datasets: -\code{\link{Music_preferences2}}, \code{\link{Music_preferences}}, +\code{\link{Music_preferences2}}, \code{\link{RCT_table}}, \code{\link{Smoking_FASD}}, \code{\link{hardlyworking}}, diff --git a/man/hardlyworking.Rd b/man/hardlyworking.Rd index 5dbd45728..0bf4714b6 100644 --- a/man/hardlyworking.Rd +++ b/man/hardlyworking.Rd @@ -30,8 +30,8 @@ A sample (simulated) dataset, used in tests and some examples. } \seealso{ Other effect size datasets: -\code{\link{Music_preferences2}}, \code{\link{Music_preferences}}, +\code{\link{Music_preferences2}}, \code{\link{RCT_table}}, \code{\link{Smoking_FASD}}, \code{\link{food_class}}, diff --git a/man/rouder2016.Rd b/man/rouder2016.Rd index 866741c0f..7a990608f 100644 --- a/man/rouder2016.Rd +++ b/man/rouder2016.Rd @@ -31,8 +31,8 @@ The data is used in examples and tests of \code{\link[=rm_d]{rm_d()}}. } \seealso{ Other effect size datasets: -\code{\link{Music_preferences2}}, \code{\link{Music_preferences}}, +\code{\link{Music_preferences2}}, \code{\link{RCT_table}}, \code{\link{Smoking_FASD}}, \code{\link{food_class}}, diff --git a/man/screening_test.Rd b/man/screening_test.Rd index 7b3b0a67f..4cbb12289 100644 --- a/man/screening_test.Rd +++ b/man/screening_test.Rd @@ -27,8 +27,8 @@ A sample (simulated) dataset, used in tests and some examples. } \seealso{ Other effect size datasets: -\code{\link{Music_preferences2}}, \code{\link{Music_preferences}}, +\code{\link{Music_preferences2}}, \code{\link{RCT_table}}, \code{\link{Smoking_FASD}}, \code{\link{food_class}}, diff --git a/vignettes/statistical_power.Rmd b/vignettes/statistical_power.Rmd index c28c5179f..499162e91 100644 --- a/vignettes/statistical_power.Rmd +++ b/vignettes/statistical_power.Rmd @@ -79,7 +79,7 @@ So this is where we focus in this vignette, and pay special attention to the eas The following section walks through a simple applied example to ensure 1) the concepts surrounding and involved in power are clear and digestible, and 2) that the role and value of the `effectsize` package are likewise clear and digestible. Understanding both of these realities will allow for more complex extensions and applications to a wide array of research problems and questions. -# Example: Comparing Means of Independant Samples +# Example: Comparing Means of Independent Samples In addition to relying on the _easystats_ `effectsize` package for effect size calculation, we will also leverage the simple, but excellent `pwr` package for the following implementation of power analysis [@champley2017]. @@ -164,7 +164,7 @@ Given the prevalence of calculating effect sizes for different applications and There are many conversions available in the package. Take a look [here](https://easystats.github.io/effectsize/reference/index.html#effect-size-conversion). -This can also be dne directly by the user using the `t_to_d()` function: +This can also be done directly by the user using the `t_to_d()` function: ```{r} t_to_d(