From e7d3eadc177d318bb51a37026f3bc9c13a9d30da Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 9 Jun 2024 09:34:42 +0200 Subject: [PATCH] Fix #978 --- R/methods_BayesFactor.R | 17 ++++++--- R/methods_aov.R | 34 ++++++++++------- R/methods_htest.R | 37 +++++++++++-------- R/methods_other.R | 11 +++++- man/model_parameters.BFBayesFactor.Rd | 11 ++++-- man/model_parameters.aov.Rd | 17 +++++---- man/model_parameters.cgam.Rd | 7 +++- man/model_parameters.htest.Rd | 15 +++++--- .../test-model_parameters.BFBayesFactor.R | 4 +- tests/testthat/test-model_parameters.anova.R | 2 +- tests/testthat/test-model_parameters.aov.R | 6 +-- .../test-model_parameters.aov_es_ci.R | 20 +++++----- tests/testthat/test-model_parameters.htest.R | 6 +-- vignettes/model_parameters.Rmd | 4 +- 14 files changed, 116 insertions(+), 75 deletions(-) diff --git a/R/methods_BayesFactor.R b/R/methods_BayesFactor.R index ee21c8f56..72d96dd32 100644 --- a/R/methods_BayesFactor.R +++ b/R/methods_BayesFactor.R @@ -33,7 +33,7 @@ #' # Bayesian t-test #' model <- BayesFactor::ttestBF(x = rnorm(100, 1, 1)) #' model_parameters(model) -#' model_parameters(model, effectsize_type = "cohens_d", ci = 0.9) +#' model_parameters(model, es_type = "cohens_d", ci = 0.9) #' #' # Bayesian contingency table analysis #' data(raceDolls) @@ -46,7 +46,7 @@ #' centrality = "mean", #' dispersion = TRUE, #' verbose = FALSE, -#' effectsize_type = "cramers_v" +#' es_type = "cramers_v" #' ) #' } #' @return A data frame of indices related to the model's parameters. @@ -60,9 +60,10 @@ model_parameters.BFBayesFactor <- function(model, rope_range = "default", rope_ci = 0.95, priors = TRUE, - effectsize_type = NULL, + es_type = NULL, include_proportions = FALSE, verbose = TRUE, + effectsize_type = NULL, ...) { insight::check_if_installed("BayesFactor") @@ -83,6 +84,12 @@ model_parameters.BFBayesFactor <- function(model, return(NULL) } + ## TODO: remove deprecation warning later + if (!is.null(effectsize_type)) { + insight::format_warning("Argument `effectsize_type` is deprecated. Use `es_type` instead.") + es_type <- effectsize_type + } + out <- bayestestR::describe_posterior( model, centrality = centrality, @@ -132,7 +139,7 @@ model_parameters.BFBayesFactor <- function(model, } # Effect size? - if (!is.null(effectsize_type)) { + if (!is.null(es_type)) { # needs {effectsize} to be installed insight::check_if_installed("effectsize") @@ -144,7 +151,7 @@ model_parameters.BFBayesFactor <- function(model, dispersion = dispersion, ci_method = ci_method, rope_ci = rope_ci, - type = effectsize_type, + type = es_type, ... ) diff --git a/R/methods_aov.R b/R/methods_aov.R index a021114d9..50c09e33f 100644 --- a/R/methods_aov.R +++ b/R/methods_aov.R @@ -7,7 +7,7 @@ #' @param model Object of class [aov()], [anova()], #' `aovlist`, `Gam`, [manova()], `Anova.mlm`, #' `afex_aov` or `maov`. -#' @param effectsize_type The effect size of interest. Not that possibly not all +#' @param es_type The effect size of interest. Not that possibly not all #' effect sizes are applicable to the model object. See 'Details'. For Anova #' models, can also be a character vector with multiple effect size names. #' @param df_error Denominator degrees of freedom (or degrees of freedom of the @@ -18,7 +18,7 @@ #' ANOVA-tables using `car::Anova()` will be returned. (Ignored for #' `afex_aov`.) #' @param ci Confidence Interval (CI) level for effect sizes specified in -#' `effectsize_type`. The default, `NULL`, will compute no confidence +#' `es_type`. The default, `NULL`, will compute no confidence #' intervals. `ci` should be a scalar between 0 and 1. #' @param test String, indicating the type of test for `Anova.mlm` to be #' returned. If `"multivariate"` (or `NULL`), returns the summary of @@ -35,6 +35,7 @@ #' (e.g., `"g"`, `"l"`, `"two"`...). See section *One-Sided CIs* in #' the [effectsize_CIs vignette](https://easystats.github.io/effectsize/). #' @inheritParams model_parameters.default +#' @param effectsize_type Deprecated. Use `es_type` instead. #' @param ... Arguments passed to [`effectsize::effectsize()`]. For example, #' to calculate _partial_ effect sizes types, use `partial = TRUE`. For objects #' of class `htest` or `BFBayesFactor`, `adjust = TRUE` can be used to return @@ -65,13 +66,13 @@ #' model <- aov(Sepal.Length ~ Sepal.Big, data = df) #' model_parameters(model) #' -#' model_parameters(model, effectsize_type = c("omega", "eta"), ci = 0.9) +#' model_parameters(model, es_type = c("omega", "eta"), ci = 0.9) #' #' model <- anova(lm(Sepal.Length ~ Sepal.Big, data = df)) #' model_parameters(model) #' model_parameters( #' model, -#' effectsize_type = c("omega", "eta", "epsilon"), +#' es_type = c("omega", "eta", "epsilon"), #' alternative = "greater" #' ) #' @@ -91,7 +92,7 @@ #' # parameters table including effect sizes #' model_parameters( #' model, -#' effectsize_type = "eta", +#' es_type = "eta", #' ci = 0.9, #' df_error = dof_satterthwaite(mm)[2:3] #' ) @@ -104,16 +105,23 @@ model_parameters.aov <- function(model, alternative = NULL, test = NULL, power = FALSE, - effectsize_type = NULL, + es_type = NULL, keep = NULL, drop = NULL, table_wide = FALSE, verbose = TRUE, + effectsize_type = NULL, ...) { # save model object, for later checks original_model <- model object_name <- insight::safe_deparse_symbol(substitute(model)) + ## TODO: remove deprecation warning later + if (!is.null(effectsize_type)) { + insight::format_warning("Argument `effectsize_type` is deprecated. Use `es_type` instead.") + es_type <- effectsize_type + } + if (inherits(model, "aov") && !is.null(type) && type > 1) { if (requireNamespace("car", quietly = TRUE)) { model <- car::Anova(model, type = type) @@ -144,7 +152,7 @@ model_parameters.aov <- function(model, params <- .effectsizes_for_aov( model, params = params, - effectsize_type = effectsize_type, + es_type = es_type, df_error = df_error, ci = ci, alternative = alternative, @@ -250,7 +258,7 @@ model_parameters.aovlist <- model_parameters.aov #' @rdname model_parameters.aov #' @export model_parameters.afex_aov <- function(model, - effectsize_type = NULL, + es_type = NULL, df_error = NULL, type = NULL, keep = NULL, @@ -270,7 +278,7 @@ model_parameters.afex_aov <- function(model, out <- .effectsizes_for_aov( model, params = out, - effectsize_type = effectsize_type, + es_type = es_type, df_error = df_error, verbose = verbose, ... @@ -432,19 +440,19 @@ model_parameters.maov <- model_parameters.aov .effectsizes_for_aov <- function(model, params, - effectsize_type = NULL, + es_type = NULL, df_error = NULL, ci = NULL, alternative = NULL, verbose = TRUE, ...) { # user actually does not want to compute effect sizes - if (is.null(effectsize_type)) { + if (is.null(es_type)) { return(params) } # is valid effect size? - if (!all(effectsize_type %in% c("eta", "omega", "epsilon", "f", "f2"))) { + if (!all(es_type %in% c("eta", "omega", "epsilon", "f", "f2"))) { return(params) } @@ -462,7 +470,7 @@ model_parameters.maov <- model_parameters.aov } # multiple effect sizes possible - for (es in effectsize_type) { + for (es in es_type) { fx <- effectsize::effectsize( model, type = es, diff --git a/R/methods_htest.R b/R/methods_htest.R index 4586a6cf7..4e070c61d 100644 --- a/R/methods_htest.R +++ b/R/methods_htest.R @@ -16,13 +16,13 @@ #' model_parameters(model) #' #' model <- t.test(iris$Sepal.Width, iris$Sepal.Length) -#' model_parameters(model, effectsize_type = "hedges_g") +#' model_parameters(model, es_type = "hedges_g") #' #' model <- t.test(mtcars$mpg ~ mtcars$vs) -#' model_parameters(model, effectsize_type = "hedges_g") +#' model_parameters(model, es_type = "hedges_g") #' #' model <- t.test(iris$Sepal.Width, mu = 1) -#' model_parameters(model, effectsize_type = "cohens_d") +#' model_parameters(model, es_type = "cohens_d") #' #' data(airquality) #' airquality$Month <- factor(airquality$Month, labels = month.abb[5:9]) @@ -35,7 +35,7 @@ #' model_parameters(model) #' #' model <- suppressWarnings(chisq.test(table(mtcars$am, mtcars$cyl))) -#' model_parameters(model, effectsize_type = "cramers_v") +#' model_parameters(model, es_type = "cramers_v") #' #' @return A data frame of indices related to the model's parameters. #' @@ -44,15 +44,22 @@ model_parameters.htest <- function(model, ci = 0.95, alternative = NULL, bootstrap = FALSE, - effectsize_type = NULL, + es_type = NULL, verbose = TRUE, + effectsize_type = NULL, ...) { + ## TODO: remove deprecation warning later + if (!is.null(effectsize_type)) { + insight::format_warning("Argument `effectsize_type` is deprecated. Use `es_type` instead.") + es_type <- effectsize_type + } + if (bootstrap) { insight::format_error("Bootstrapped h-tests are not yet implemented.") } else { parameters <- .extract_parameters_htest( model, - effectsize_type = effectsize_type, + es_type = es_type, ci = ci, alternative = alternative, verbose = verbose, @@ -121,7 +128,7 @@ model_parameters.svytable <- function(model, verbose = TRUE, ...) { #' @keywords internal .extract_parameters_htest <- function(model, - effectsize_type = NULL, + es_type = NULL, ci = 0.95, alternative = NULL, verbose = TRUE, @@ -164,7 +171,7 @@ model_parameters.svytable <- function(model, verbose = TRUE, ...) { out <- .add_effectsize_htest(model, out, - effectsize_type = effectsize_type, + es_type = es_type, ci = ci, alternative = alternative, verbose = verbose, @@ -568,20 +575,20 @@ model_parameters.svytable <- function(model, verbose = TRUE, ...) { .add_effectsize_htest <- function(model, out, - effectsize_type = NULL, + es_type = NULL, ci = 0.95, alternative = NULL, verbose = TRUE, ...) { # check if effect sizes are requested - if (!requireNamespace("effectsize", quietly = TRUE) || is.null(effectsize_type)) { + if (!requireNamespace("effectsize", quietly = TRUE) || is.null(es_type)) { return(out) } # return on invalid options. We may have partial matching with argument - # `effects` for `effectsize_type`, and thus all "effects" options should be + # `effects` for `es_type`, and thus all "effects" options should be # ignored. - if (effectsize_type %in% c("fixed", "random", "all")) { + if (es_type %in% c("fixed", "random", "all")) { return(out) } @@ -590,7 +597,7 @@ model_parameters.svytable <- function(model, verbose = TRUE, ...) { { effectsize::effectsize( model, - type = effectsize_type, + type = es_type, ci = ci, alternative = alternative, verbose = verbose, @@ -600,7 +607,7 @@ model_parameters.svytable <- function(model, verbose = TRUE, ...) { error = function(e) { if (verbose) { msg <- c( - paste0("Could not compute effectsize ", effectsize::get_effectsize_label(effectsize_type), "."), + paste0("Could not compute effectsize ", effectsize::get_effectsize_label(es_type), "."), paste0("Possible reason: ", e$message) ) insight::format_alert(msg) @@ -616,7 +623,7 @@ model_parameters.svytable <- function(model, verbose = TRUE, ...) { ## TODO: check if effectsize prefixes are correct @mattansb # Find prefix for CI-columns - prefix <- switch(effectsize_type, + prefix <- switch(es_type, cohens_g = "Cohens_", cramers_v = "Cramers_", phi = "phi_", diff --git a/R/methods_other.R b/R/methods_other.R index f1afb42e1..f5110bf59 100644 --- a/R/methods_other.R +++ b/R/methods_other.R @@ -36,15 +36,22 @@ degrees_of_freedom.complmrob <- function(model, method = "wald", ...) { #' @inheritParams model_parameters.aov #' @export model_parameters.Gam <- function(model, - effectsize_type = NULL, + es_type = NULL, df_error = NULL, type = NULL, table_wide = FALSE, verbose = TRUE, + effectsize_type = NULL, ...) { + ## TODO: remove deprecation warning later + if (!is.null(effectsize_type)) { + insight::format_warning("Argument `effectsize_type` is deprecated. Use `es_type` instead.") + es_type <- effectsize_type + } + model_parameters( summary(model)$parametric.anova, - effectsize_type = effectsize_type, + es_type = es_type, df_error = df_error, type = type, table_wide = table_wide, diff --git a/man/model_parameters.BFBayesFactor.Rd b/man/model_parameters.BFBayesFactor.Rd index b24faeaa8..b88312181 100644 --- a/man/model_parameters.BFBayesFactor.Rd +++ b/man/model_parameters.BFBayesFactor.Rd @@ -14,9 +14,10 @@ rope_range = "default", rope_ci = 0.95, priors = TRUE, - effectsize_type = NULL, + es_type = NULL, include_proportions = FALSE, verbose = TRUE, + effectsize_type = NULL, ... ) } @@ -58,7 +59,7 @@ proportion of HDI, to use for the percentage in ROPE.} \item{priors}{Add the prior used for each parameter.} -\item{effectsize_type}{The effect size of interest. Not that possibly not all +\item{es_type}{The effect size of interest. Not that possibly not all effect sizes are applicable to the model object. See 'Details'. For Anova models, can also be a character vector with multiple effect size names.} @@ -69,6 +70,8 @@ information is often redundant.} \item{verbose}{Toggle off warnings.} +\item{effectsize_type}{Deprecated. Use \code{es_type} instead.} + \item{...}{Additional arguments to be passed to or from methods.} } \value{ @@ -98,7 +101,7 @@ the \emph{g} parameters; See the \emph{Bayes Factors for ANOVAs} paper # Bayesian t-test model <- BayesFactor::ttestBF(x = rnorm(100, 1, 1)) model_parameters(model) -model_parameters(model, effectsize_type = "cohens_d", ci = 0.9) +model_parameters(model, es_type = "cohens_d", ci = 0.9) # Bayesian contingency table analysis data(raceDolls) @@ -111,7 +114,7 @@ model_parameters(bf, centrality = "mean", dispersion = TRUE, verbose = FALSE, - effectsize_type = "cramers_v" + es_type = "cramers_v" ) } \dontshow{\}) # examplesIf} diff --git a/man/model_parameters.aov.Rd b/man/model_parameters.aov.Rd index 16f1d249e..4033ecc41 100644 --- a/man/model_parameters.aov.Rd +++ b/man/model_parameters.aov.Rd @@ -13,17 +13,18 @@ alternative = NULL, test = NULL, power = FALSE, - effectsize_type = NULL, + es_type = NULL, keep = NULL, drop = NULL, table_wide = FALSE, verbose = TRUE, + effectsize_type = NULL, ... ) \method{model_parameters}{afex_aov}( model, - effectsize_type = NULL, + es_type = NULL, df_error = NULL, type = NULL, keep = NULL, @@ -47,7 +48,7 @@ for ANOVA-tables from mixed models. See 'Examples'. (Ignored for \code{afex_aov}.)} \item{ci}{Confidence Interval (CI) level for effect sizes specified in -\code{effectsize_type}. The default, \code{NULL}, will compute no confidence +\code{es_type}. The default, \code{NULL}, will compute no confidence intervals. \code{ci} should be a scalar between 0 and 1.} \item{alternative}{A character string specifying the alternative hypothesis; @@ -64,7 +65,7 @@ the multivariate test (that is also given by the \code{print}-method). If \item{power}{Logical, if \code{TRUE}, adds a column with power for each parameter.} -\item{effectsize_type}{The effect size of interest. Not that possibly not all +\item{es_type}{The effect size of interest. Not that possibly not all effect sizes are applicable to the model object. See 'Details'. For Anova models, can also be a character vector with multiple effect size names.} @@ -96,6 +97,8 @@ be in the same row. Default: \code{FALSE}.} \item{verbose}{Toggle warnings and messages.} +\item{effectsize_type}{Deprecated. Use \code{es_type} instead.} + \item{...}{Arguments passed to \code{\link[effectsize:effectsize]{effectsize::effectsize()}}. For example, to calculate \emph{partial} effect sizes types, use \code{partial = TRUE}. For objects of class \code{htest} or \code{BFBayesFactor}, \code{adjust = TRUE} can be used to return @@ -161,13 +164,13 @@ df$Sepal.Big <- ifelse(df$Sepal.Width >= 3, "Yes", "No") model <- aov(Sepal.Length ~ Sepal.Big, data = df) model_parameters(model) -model_parameters(model, effectsize_type = c("omega", "eta"), ci = 0.9) +model_parameters(model, es_type = c("omega", "eta"), ci = 0.9) model <- anova(lm(Sepal.Length ~ Sepal.Big, data = df)) model_parameters(model) model_parameters( model, - effectsize_type = c("omega", "eta", "epsilon"), + es_type = c("omega", "eta", "epsilon"), alternative = "greater" ) @@ -187,7 +190,7 @@ model_parameters(model) # parameters table including effect sizes model_parameters( model, - effectsize_type = "eta", + es_type = "eta", ci = 0.9, df_error = dof_satterthwaite(mm)[2:3] ) diff --git a/man/model_parameters.cgam.Rd b/man/model_parameters.cgam.Rd index 90a5ff164..7b684a368 100644 --- a/man/model_parameters.cgam.Rd +++ b/man/model_parameters.cgam.Rd @@ -34,11 +34,12 @@ \method{model_parameters}{Gam}( model, - effectsize_type = NULL, + es_type = NULL, df_error = NULL, type = NULL, table_wide = FALSE, verbose = TRUE, + effectsize_type = NULL, ... ) @@ -143,7 +144,7 @@ names.} \code{bootstrap = TRUE}, arguments like \code{type} or \code{parallel} are passed down to \code{bootstrap_model()}.} -\item{effectsize_type}{The effect size of interest. Not that possibly not all +\item{es_type}{The effect size of interest. Not that possibly not all effect sizes are applicable to the model object. See 'Details'. For Anova models, can also be a character vector with multiple effect size names.} @@ -159,6 +160,8 @@ ANOVA-tables using \code{car::Anova()} will be returned. (Ignored for \item{table_wide}{Logical that decides whether the ANOVA table should be in wide format, i.e. should the numerator and denominator degrees of freedom be in the same row. Default: \code{FALSE}.} + +\item{effectsize_type}{Deprecated. Use \code{es_type} instead.} } \value{ A data frame of indices related to the model's parameters. diff --git a/man/model_parameters.htest.Rd b/man/model_parameters.htest.Rd index dcd667b86..c988acf4d 100644 --- a/man/model_parameters.htest.Rd +++ b/man/model_parameters.htest.Rd @@ -10,8 +10,9 @@ ci = 0.95, alternative = NULL, bootstrap = FALSE, - effectsize_type = NULL, + es_type = NULL, verbose = TRUE, + effectsize_type = NULL, ... ) @@ -39,12 +40,14 @@ the \href{https://easystats.github.io/effectsize/}{effectsize_CIs vignette}.} \item{bootstrap}{Should estimates be bootstrapped?} -\item{effectsize_type}{The effect size of interest. Not that possibly not all +\item{es_type}{The effect size of interest. Not that possibly not all effect sizes are applicable to the model object. See 'Details'. For Anova models, can also be a character vector with multiple effect size names.} \item{verbose}{Toggle warnings and messages.} +\item{effectsize_type}{Deprecated. Use \code{es_type} instead.} + \item{...}{Arguments passed to or from other methods. For instance, when \code{bootstrap = TRUE}, arguments like \code{type} or \code{parallel} are passed down to \code{bootstrap_model()}.} @@ -124,13 +127,13 @@ model <- cor.test(mtcars$mpg, mtcars$cyl, method = "pearson") model_parameters(model) model <- t.test(iris$Sepal.Width, iris$Sepal.Length) -model_parameters(model, effectsize_type = "hedges_g") +model_parameters(model, es_type = "hedges_g") model <- t.test(mtcars$mpg ~ mtcars$vs) -model_parameters(model, effectsize_type = "hedges_g") +model_parameters(model, es_type = "hedges_g") model <- t.test(iris$Sepal.Width, mu = 1) -model_parameters(model, effectsize_type = "cohens_d") +model_parameters(model, es_type = "cohens_d") data(airquality) airquality$Month <- factor(airquality$Month, labels = month.abb[5:9]) @@ -143,6 +146,6 @@ model <- suppressWarnings(pairwise.prop.test(smokers, patients)) model_parameters(model) model <- suppressWarnings(chisq.test(table(mtcars$am, mtcars$cyl))) -model_parameters(model, effectsize_type = "cramers_v") +model_parameters(model, es_type = "cramers_v") } diff --git a/tests/testthat/test-model_parameters.BFBayesFactor.R b/tests/testthat/test-model_parameters.BFBayesFactor.R index 6acabdb50..14dfb8474 100644 --- a/tests/testthat/test-model_parameters.BFBayesFactor.R +++ b/tests/testthat/test-model_parameters.BFBayesFactor.R @@ -84,7 +84,7 @@ test_that("model_parameters.BFBayesFactor", { centrality = "mean", dispersion = TRUE, verbose = FALSE, - effectsize_type = "cramers_v", + es_type = "cramers_v", adjust = TRUE, include_proportions = TRUE )) @@ -158,7 +158,7 @@ test_that("model_parameters.BFBayesFactor, with effectsize", { skip_if_not_installed("BayesFactor") set.seed(123) df_t_es <- as.data.frame( - parameters(BayesFactor::ttestBF(mtcars$wt, mu = 3), effectsize_type = "cohens_d") + parameters(BayesFactor::ttestBF(mtcars$wt, mu = 3), es_type = "cohens_d") ) # TODO: fix column order diff --git a/tests/testthat/test-model_parameters.anova.R b/tests/testthat/test-model_parameters.anova.R index 9533031d4..3095a9057 100644 --- a/tests/testthat/test-model_parameters.anova.R +++ b/tests/testthat/test-model_parameters.anova.R @@ -94,7 +94,7 @@ test_that("model_parameters_Anova-effectsize", { # parameters table including effect sizes mp <- model_parameters( model, - effectsize_type = "eta", + es_type = "eta", ci = 0.9, df_error = dof_satterthwaite(mm)[2:3] ) diff --git a/tests/testthat/test-model_parameters.aov.R b/tests/testthat/test-model_parameters.aov.R index 09e40803a..a1d069107 100644 --- a/tests/testthat/test-model_parameters.aov.R +++ b/tests/testthat/test-model_parameters.aov.R @@ -8,7 +8,7 @@ iris$Cat2 <- rep(c("A", "B"), length.out = nrow(iris)) test_that("model_parameters.aov", { skip_if_not_installed("effectsize", minimum_version = "0.5.0") model <- aov(Sepal.Width ~ Species, data = iris) - mp <- suppressMessages(model_parameters(model, effectsize_type = c("omega", "eta", "epsilon"))) + mp <- suppressMessages(model_parameters(model, es_type = c("omega", "eta", "epsilon"))) expect_identical(mp$Parameter, c("Species", "Residuals")) expect_equal(mp$Sum_Squares, c(11.34493, 16.962), tolerance = 1e-3) }) @@ -16,7 +16,7 @@ test_that("model_parameters.aov", { test_that("model_parameters.aov", { skip_if_not_installed("effectsize", minimum_version = "0.5.0") model <- aov(Sepal.Width ~ Species, data = iris) - mp <- suppressMessages(model_parameters(model, effectsize_type = c("omega", "eta", "epsilon"))) + mp <- suppressMessages(model_parameters(model, es_type = c("omega", "eta", "epsilon"))) expect_identical(sum(mp$df), 149) expect_named(mp, c( "Parameter", "Sum_Squares", "df", "Mean_Square", "F", "p", @@ -24,7 +24,7 @@ test_that("model_parameters.aov", { )) model <- aov(Sepal.Length ~ Species * Cat1 * Cat2, data = iris) - expect_identical(sum(model_parameters(model, effectsize_type = c("omega", "eta", "epsilon"), verbose = FALSE)$df), 149) + expect_identical(sum(model_parameters(model, es_type = c("omega", "eta", "epsilon"), verbose = FALSE)$df), 149) model <- aov(Sepal.Length ~ Species / Cat1 * Cat2, data = iris) expect_identical(sum(model_parameters(model, verbose = FALSE)$df), 149) diff --git a/tests/testthat/test-model_parameters.aov_es_ci.R b/tests/testthat/test-model_parameters.aov_es_ci.R index 826f895f2..4e5a5f969 100644 --- a/tests/testthat/test-model_parameters.aov_es_ci.R +++ b/tests/testthat/test-model_parameters.aov_es_ci.R @@ -9,7 +9,7 @@ test_that("model_parameters.aov", { model <- aov(Sepal.Width ~ Species, data = iris) mp <- suppressMessages(model_parameters( model, - effectsize_type = c("omega", "eta", "epsilon"), + es_type = c("omega", "eta", "epsilon"), ci = 0.9, alternative = "greater" )) @@ -28,7 +28,7 @@ test_that("model_parameters.aov", { )) model <- aov(Sepal.Length ~ Species * Cat1 * Cat2, data = iris) - mp <- model_parameters(model, effectsize_type = "eta", ci = 0.9, partial = FALSE, alternative = "greater") + mp <- model_parameters(model, es_type = "eta", ci = 0.9, partial = FALSE, alternative = "greater") es <- effectsize::eta_squared(model, partial = FALSE, ci = 0.9) expect_equal(na.omit(mp$Eta2_CI_low), es$CI_low, tolerance = 1e-3, ignore_attr = TRUE) expect_equal(mp$Eta2_CI_low, c(0.5572, 0, 0, 0, 0, 0, 0, NA), tolerance = 1e-3, ignore_attr = TRUE) @@ -53,7 +53,7 @@ test_that("model_parameters.anova", { model <- anova(lm(Sepal.Length ~ Species * Cat1 * Cat2, data = iris)) mp <- model_parameters( model, - effectsize_type = c("omega", "eta", "epsilon"), + es_type = c("omega", "eta", "epsilon"), partial = TRUE, ci = 0.9, alternative = "greater" @@ -75,7 +75,7 @@ test_that("model_parameters.anova", { skip_if_not_installed("effectsize", minimum_version = "0.5.1") model <- aov(wt ~ cyl + Error(gear), data = mtcars) suppressWarnings({ - mp <- model_parameters(model, effectsize_type = c("omega", "eta", "epsilon"), partial = TRUE, ci = 0.9) + mp <- model_parameters(model, es_type = c("omega", "eta", "epsilon"), partial = TRUE, ci = 0.9) es <- effectsize::omega_squared(model, partial = TRUE, ci = 0.9, verbose = FALSE) }) expect_equal(na.omit(mp$Omega2_CI_low), es$CI_low[2], tolerance = 1e-3, ignore_attr = TRUE) @@ -107,7 +107,7 @@ test_that("model_parameters.car-anova", { contrasts = list(fcategory = contr.sum, partner.status = contr.sum) )) - mp <- model_parameters(model, effectsize_type = c("omega", "eta", "epsilon"), partial = TRUE, ci = 0.9) + mp <- model_parameters(model, es_type = c("omega", "eta", "epsilon"), partial = TRUE, ci = 0.9) es <- effectsize::omega_squared(model, partial = TRUE, ci = 0.9) expect_equal(na.omit(mp$Omega2_CI_low), es$CI_low, tolerance = 1e-3, ignore_attr = TRUE) expect_equal(mp$Omega2_CI_low, c(0, 0.05110, 0.00666, NA), tolerance = 1e-3, ignore_attr = TRUE) @@ -133,7 +133,7 @@ test_that("model_parameters.maov", { mp <- suppressMessages(model_parameters( model, - effectsize_type = c("omega", "eta", "epsilon"), + es_type = c("omega", "eta", "epsilon"), partial = TRUE, ci = 0.9 )) @@ -165,7 +165,7 @@ test_that("works with aov", { df_aov <- as.data.frame(parameters::model_parameters(npk.aov, ci = 0.95, - effectsize_type = c("eta", "omega"), + es_type = c("eta", "omega"), partial = FALSE )) @@ -280,7 +280,7 @@ test_that("works with manova", { df_manova <- as.data.frame(model_parameters(m, ci = 0.99, - effectsize_type = c("epsilon", "omega"), + es_type = c("epsilon", "omega"), partial = TRUE )) @@ -333,7 +333,7 @@ test_that("works with Gam", { df_Gam <- as.data.frame(model_parameters(g, ci = 0.50, - effectsize_type = "omega", + es_type = "omega", partial = TRUE )) @@ -384,7 +384,7 @@ test_that("works with anova", { df_car <- as.data.frame(model_parameters(mod, ci = 0.89, - effectsize_type = c("eta", "epsilon"), + es_type = c("eta", "epsilon"), partial = FALSE )) diff --git a/tests/testthat/test-model_parameters.htest.R b/tests/testthat/test-model_parameters.htest.R index 15a76c6f4..dad34b4b5 100644 --- a/tests/testthat/test-model_parameters.htest.R +++ b/tests/testthat/test-model_parameters.htest.R @@ -68,14 +68,14 @@ test_that("model_parameters-chisq-test works with `svychisq` objects", { test_that("model_parameters-chisq-test adjusted", { expect_message({ - mp <- model_parameters(stats::chisq.test(table(mtcars$am)), effectsize_type = "phi", ci = 0.95) + mp <- model_parameters(stats::chisq.test(table(mtcars$am)), es_type = "phi", ci = 0.95) }) expect_equal(mp$Chi2, 1.125, tolerance = 1e-3) expect_named(mp, c("Chi2", "df", "p", "Method")) }) test_that("model_parameters-t-test standardized d", { - params <- model_parameters(t.test(iris$Sepal.Width, iris$Sepal.Length), effectsize_type = "cohens_d") + params <- model_parameters(t.test(iris$Sepal.Width, iris$Sepal.Length), es_type = "cohens_d") expect_equal(params$Cohens_d, -4.210417, tolerance = 0.05) expect_equal(params$d_CI_low, -4.655306, tolerance = 0.05) expect_named( @@ -89,7 +89,7 @@ test_that("model_parameters-t-test standardized d", { }) test_that("model_parameters-t-test standardized d", { - mp <- model_parameters(t.test(mtcars$mpg ~ mtcars$vs), effectsize_type = "cohens_d", verbose = FALSE) + mp <- model_parameters(t.test(mtcars$mpg ~ mtcars$vs), es_type = "cohens_d", verbose = FALSE) expect_equal(mp$Cohens_d, -1.696032, tolerance = 1e-3) expect_named( mp, diff --git a/vignettes/model_parameters.Rmd b/vignettes/model_parameters.Rmd index 719ffb69c..709a5ec0d 100644 --- a/vignettes/model_parameters.Rmd +++ b/vignettes/model_parameters.Rmd @@ -106,7 +106,7 @@ summaries, including confidence intervals ```{r eval=successfully_loaded["effectsize"]} aov(Sepal.Length ~ Species, data = iris) |> - parameters(effectsize_type = c("omega", "eta", "epsilon")) + parameters(es_type = c("omega", "eta", "epsilon")) ``` Let's complicate things further with an interaction term: @@ -114,7 +114,7 @@ Let's complicate things further with an interaction term: ```{r eval=successfully_loaded["effectsize"]} aov(Sepal.Length ~ Species * Sepal.Width, data = iris) |> parameters( - effectsize_type = c("omega", "eta"), + es_type = c("omega", "eta"), ci = 0.8 ) ```