From d4a3b3cf4b5ed037524ca7425cd5dc0a7fd1047f Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 20 Jun 2024 08:50:57 +0200 Subject: [PATCH] Prepare CRAN release (#977) * Prepare CRAN release * fix, lintr * Trigger CI * Fix #978 * news * typo, lintr * lintr * eval conditional on gt * Update model_parameters_print.Rmd * fix * Update DESCRIPTION * Update NEWS.md * Update DESCRIPTION * Update NEWS.md * lintr * lintr * doc cleanup * lintr * update orcid * newline * update news * docs * typo * support glmgee * newline * cran comm * news * wordlist * submitted * fix notes * lintr * re-submitted --------- Co-authored-by: Indrajeet Patil --- .lintr | 3 +- CRAN-SUBMISSION | 6 +- DESCRIPTION | 11 +- NAMESPACE | 3 + NEWS.md | 15 ++- R/1_model_parameters.R | 2 +- R/bootstrap_model.R | 6 +- R/extract_parameters.R | 8 +- R/methods_BayesFactor.R | 23 ++-- R/methods_aov.R | 40 ++++--- R/methods_glmgee.R | 64 +++++++++++ R/methods_htest.R | 37 +++--- R/methods_kmeans.R | 8 +- R/methods_other.R | 11 +- R/n_clusters_easystats.R | 106 +++++++++++------- R/print.parameters_model.R | 4 +- R/print_md.R | 6 +- R/select_parameters.R | 46 ++++---- R/standardize_parameters.R | 16 +-- R/standardize_posteriors.R | 2 +- cran-comments.md | 2 +- inst/WORDLIST | 2 + man/model_parameters.BFBayesFactor.Rd | 11 +- man/model_parameters.Rd | 2 +- man/model_parameters.aov.Rd | 17 +-- man/model_parameters.cgam.Rd | 7 +- man/model_parameters.htest.Rd | 15 ++- man/parameters-package.Rd | 2 +- man/select_parameters.Rd | 45 ++++---- man/standardize_parameters.Rd | 7 +- .../test-model_parameters.BFBayesFactor.R | 4 +- tests/testthat/test-model_parameters.anova.R | 2 +- tests/testthat/test-model_parameters.aov.R | 10 +- .../test-model_parameters.aov_es_ci.R | 29 ++--- .../testthat/test-model_parameters.blmerMod.R | 10 +- tests/testthat/test-model_parameters.htest.R | 6 +- vignettes/model_parameters.Rmd | 4 +- vignettes/model_parameters_print.Rmd | 28 ++--- 38 files changed, 381 insertions(+), 239 deletions(-) create mode 100644 R/methods_glmgee.R diff --git a/.lintr b/.lintr index b0e8abefe..c575e7c95 100644 --- a/.lintr +++ b/.lintr @@ -1,7 +1,7 @@ linters: linters_with_defaults( absolute_path_linter = NULL, commented_code_linter = NULL, - cyclocomp_linter = cyclocomp_linter(25), + cyclocomp_linter = cyclocomp_linter(125), extraction_operator_linter = NULL, implicit_integer_linter = NULL, line_length_linter(120), @@ -9,6 +9,7 @@ linters: linters_with_defaults( nonportable_path_linter = NULL, object_name_linter = NULL, object_length_linter(50), + library_call_linter = NULL, object_usage_linter = NULL, todo_comment_linter = NULL, undesirable_function_linter(c("mapply" = NA, "sapply" = NA, "setwd" = NA)), diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index ff774c869..f9ec7dee2 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ -Version: 0.21.7 -Date: 2024-05-13 17:50:43 UTC -SHA: 5c707ee00026cae0f4439eb8514e2537275344cc +Version: 0.22.0 +Date: 2024-06-19 20:40:00 UTC +SHA: 3861512ee3c11ecca44c2edd412c2a5cb65e1f59 diff --git a/DESCRIPTION b/DESCRIPTION index e0306819a..ed19045b2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: parameters Title: Processing of Model Parameters -Version: 0.21.7.4 +Version: 0.22.0 Authors@R: c(person(given = "Daniel", family = "Lüdecke", @@ -40,7 +40,7 @@ Authors@R: family = "Arel-Bundock", role = "ctb", email = "vincent.arel-bundock@umontreal.ca", - comment = c(ORCID = "0000-0003-1995-6531", Twitter = "@vincentab")), + comment = c(ORCID = "0000-0003-2042-7063", Twitter = "@vincentab")), person(given = "Jeffrey", family = "Girard", role = "ctb", @@ -177,7 +177,7 @@ Suggests: panelr, pbkrtest, PCDimension, - performance (>= 0.10.8), + performance (>= 0.12.0), plm, PMCMRplus, poorman, @@ -213,8 +213,5 @@ RoxygenNote: 7.3.1 Roxygen: list(markdown = TRUE) Config/testthat/edition: 3 Config/testthat/parallel: true -Config/Needs/website: - rstudio/bslib, - r-lib/pkgdown, - easystats/easystatstemplate +Config/Needs/website: easystats/easystatstemplate Config/rcmdcheck/ignore-inconsequential-notes: true diff --git a/NAMESPACE b/NAMESPACE index b4974aef4..e2cf309e1 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -42,6 +42,7 @@ S3method(ci,gamm4) S3method(ci,geeglm) S3method(ci,glht) S3method(ci,glm) +S3method(ci,glmgee) S3method(ci,glmm) S3method(ci,glmmTMB) S3method(ci,hglm) @@ -462,6 +463,7 @@ S3method(p_value,gee) S3method(p_value,geeglm) S3method(p_value,glht) S3method(p_value,glimML) +S3method(p_value,glmgee) S3method(p_value,glmm) S3method(p_value,glmx) S3method(p_value,gls) @@ -792,6 +794,7 @@ S3method(standard_error,gee) S3method(standard_error,geeglm) S3method(standard_error,glht) S3method(standard_error,glimML) +S3method(standard_error,glmgee) S3method(standard_error,glmm) S3method(standard_error,glmmTMB) S3method(standard_error,glmx) diff --git a/NEWS.md b/NEWS.md index 180c60436..6dbe22731 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,18 +1,25 @@ -# parameters 0.21.8 +# parameters 0.22.0 ## Breaking changes * Deprecated arguments in `model_parameters()` for `htest`, `aov` and `BFBayesFactor` objects were removed. +* Argument `effectsize_type` is deprecated. Please use `es_type` now. This change + was necessary to avoid conflicts with partial matching of argument names (here: + `effects`). + ## New supported models * Support for objects from `stats::Box.test()`. -## Bug fixes +* Support for `glmgee` models from package *glmtoolbox*. + +## Bug fix + +* Fixed edge case in `predict()` for `factor_analysis()`. -* Fixed issues with partial matching of argument `effects` and `effectsize_type` - in `model_parameters()` for objects of class `htest`. +* Fixed wrong ORCID in `DESCRIPTION`. # parameters 0.21.7 diff --git a/R/1_model_parameters.R b/R/1_model_parameters.R index 991a3704d..2a0980280 100644 --- a/R/1_model_parameters.R +++ b/R/1_model_parameters.R @@ -87,7 +87,7 @@ #' include interactions or transformations (e.g., polynomial or spline terms). #' The `robust` (default to `FALSE`) argument enables a robust standardization #' of data, i.e., based on the `median` and `MAD` instead of the `mean` and -#' `SD`. **See [standardize()] for more details.** +#' `SD`. **See [`datawizard::standardize()`] for more details.** #' **Note** that `standardize_parameters(method = "refit")` may not return #' the same results as fitting a model on data that has been standardized with #' `standardize()`; `standardize_parameters()` used the data used by the model diff --git a/R/bootstrap_model.R b/R/bootstrap_model.R index 949bc415a..cdfc66109 100644 --- a/R/bootstrap_model.R +++ b/R/bootstrap_model.R @@ -178,7 +178,7 @@ bootstrap_model.merMod <- function(model, } else { params <- stats::setNames(params$Estimate, params$Parameter) # Transform to named vector } - return(params) + params } if (verbose) { @@ -244,9 +244,7 @@ bootstrap_model.nestedLogit <- function(model, } params <- insight::get_parameters(fit, verbose = FALSE) - params <- stats::setNames(params$Estimate, params$Parameter) # Transform to named vector - - return(params) + stats::setNames(params$Estimate, params$Parameter) # Transform to named vector } results <- boot::boot( diff --git a/R/extract_parameters.R b/R/extract_parameters.R index dcccdf5c9..34e6e1305 100644 --- a/R/extract_parameters.R +++ b/R/extract_parameters.R @@ -355,7 +355,7 @@ verbose = TRUE) { # check pattern if (!is.null(keep) && length(keep) > 1) { - keep <- paste0("(", paste0(keep, collapse = "|"), ")") + keep <- paste0("(", paste(keep, collapse = "|"), ")") if (verbose) { insight::format_alert( sprintf("The `keep` argument has more than 1 element. Merging into following regular expression: `%s`.", keep) @@ -365,7 +365,7 @@ # check pattern if (!is.null(drop) && length(drop) > 1) { - drop <- paste0("(", paste0(drop, collapse = "|"), ")") + drop <- paste0("(", paste(drop, collapse = "|"), ")") if (verbose) { insight::format_alert( sprintf("The `drop` argument has more than 1 element. Merging into following regular expression: `%s`.", drop) @@ -486,7 +486,9 @@ } else { ci_df <- ci(model, ci = ci, method = ci_method, effects = "fixed") } - if (length(ci) > 1) ci_df <- datawizard::reshape_ci(ci_df) + if (length(ci) > 1) { + ci_df <- datawizard::reshape_ci(ci_df) + } ci_cols <- names(ci_df)[!names(ci_df) %in% c("CI", "Parameter")] parameters <- merge(parameters, ci_df, by = "Parameter", sort = FALSE) } diff --git a/R/methods_BayesFactor.R b/R/methods_BayesFactor.R index ee21c8f56..a5fd14625 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, @@ -115,10 +122,10 @@ model_parameters.BFBayesFactor <- function(model, tryCatch( { bfm <- as.data.frame(bayestestR::bayesfactor_models(model)[-1, ]) - if (!is.null(bfm$log_BF)) { - out$BF <- exp(bfm$log_BF) - } else { + if (is.null(bfm$log_BF)) { out$BF <- bfm$BF + } else { + out$BF <- exp(bfm$log_BF) } }, error = function(e) { @@ -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..c74b3c2a0 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, ... @@ -404,7 +412,9 @@ model_parameters.maov <- model_parameters.aov predictors <- .safe(insight::get_predictors(model)) # if data available, check contrasts and mean centering - if (!is.null(predictors)) { + if (is.null(predictors)) { + treatment_contrasts_or_not_centered <- FALSE + } else { treatment_contrasts_or_not_centered <- vapply(predictors, function(i) { if (is.factor(i)) { cn <- stats::contrasts(i) @@ -416,8 +426,6 @@ model_parameters.maov <- model_parameters.aov } FALSE }, TRUE) - } else { - treatment_contrasts_or_not_centered <- FALSE } # successfully checked predictors, or if not possible, at least found interactions? @@ -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_glmgee.R b/R/methods_glmgee.R new file mode 100644 index 000000000..2d3bde52f --- /dev/null +++ b/R/methods_glmgee.R @@ -0,0 +1,64 @@ +#' @export +standard_error.glmgee <- function(model, + vcov = c("robust", "df-adjusted", "model", "bias-corrected", "jackknife"), + verbose = TRUE, + ...) { + vcov <- match.arg(vcov) + se <- NULL + + .vcov <- insight::get_varcov( + model, + vcov = vcov, + verbose = verbose, + ... + ) + se <- sqrt(diag(.vcov)) + .data_frame(Parameter = names(se), SE = as.vector(se)) +} + + +#' @export +p_value.glmgee <- function(model, + method = NULL, + vcov = c("robust", "df-adjusted", "model", "bias-corrected", "jackknife"), + ...) { + vcov <- match.arg(vcov) + est <- insight::get_parameters(model, component = "conditional") + se <- standard_error(model, vcov = vcov, verbose = FALSE) + + p <- 2 * stats::pt( + abs(est$Estimate / se$SE), + df = degrees_of_freedom(model, method = method), + lower.tail = FALSE + ) + + .data_frame( + Parameter = est$Parameter, + p = as.vector(p) + ) +} + + +#' @export +ci.glmgee <- function(x, + ci = 0.95, + dof = NULL, + method = NULL, + vcov = c("robust", "df-adjusted", "model", "bias-corrected", "jackknife"), + verbose = TRUE, + ...) { + vcov <- match.arg(vcov) + out <- .ci_generic( + model = x, + ci = ci, + dof = dof, + method = method, + vcov = vcov, + vcov_args = NULL, + component = "conditional", + verbose = verbose + ) + # Return the CI bounds as a data frame. + row.names(out) <- NULL + out +} 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_kmeans.R b/R/methods_kmeans.R index 22b630f79..e28a7a11f 100644 --- a/R/methods_kmeans.R +++ b/R/methods_kmeans.R @@ -102,10 +102,12 @@ model_parameters.hkmeans <- model_parameters.kmeans #' @export print.parameters_clusters <- function(x, digits = 2, ...) { - title <- "# Clustering Solution" - if ("title" %in% attributes(x)) title <- attributes(x)$title + clusterHeading <- "# Clustering Solution" + if ("title" %in% attributes(x)) { + clusterHeading <- attributes(x)$title + } - insight::print_color(title, "blue") + insight::print_color(clusterHeading, "blue") cat("\n\n") insight::print_colour(.text_components_variance(x), "yellow") 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/R/n_clusters_easystats.R b/R/n_clusters_easystats.R index f069e0d6a..6a9205a82 100644 --- a/R/n_clusters_easystats.R +++ b/R/n_clusters_easystats.R @@ -26,9 +26,9 @@ n_clusters_elbow <- function(x, names(out) <- c("n_Clusters", "WSS") gradient <- c(0, diff(out$WSS)) - optim <- out$n_Clusters[which.min(gradient)] + optimal <- out$n_Clusters[which.min(gradient)] - attr(out, "n") <- optim + attr(out, "n") <- optimal attr(out, "gradient") <- gradient attr(out, "duration") <- as.numeric(difftime(Sys.time(), t0, units = "secs")) class(out) <- c("n_clusters_elbow", class(out)) @@ -75,9 +75,9 @@ n_clusters_gap <- function(x, out <- rez[c("clusters", "gap", "SE.sim")] names(out) <- c("n_Clusters", "Gap", "SE") - optim <- cluster::maxSE(f = out$Gap, SE.f = out$SE, method = gap_method) + optimal <- cluster::maxSE(f = out$Gap, SE.f = out$SE, method = gap_method) - attr(out, "n") <- optim + attr(out, "n") <- optimal attr(out, "ymin") <- rez$ymin attr(out, "ymax") <- rez$ymax attr(out, "duration") <- as.numeric(difftime(Sys.time(), t0, units = "secs")) @@ -118,9 +118,9 @@ n_clusters_silhouette <- function(x, ) names(out) <- c("n_Clusters", "Silhouette") - optim <- which.max(out$Silhouette) + optimal <- which.max(out$Silhouette) - attr(out, "n") <- optim + attr(out, "n") <- optimal attr(out, "duration") <- as.numeric(difftime(Sys.time(), t0, units = "secs")) class(out) <- c("n_clusters_silhouette", class(out)) out @@ -149,7 +149,14 @@ n_clusters_silhouette <- function(x, #' } #' } #' @export -n_clusters_dbscan <- function(x, standardize = TRUE, include_factors = FALSE, method = c("kNN", "SS"), min_size = 0.1, eps_n = 50, eps_range = c(0.1, 3), ...) { +n_clusters_dbscan <- function(x, + standardize = TRUE, + include_factors = FALSE, + method = c("kNN", "SS"), + min_size = 0.1, + eps_n = 50, + eps_range = c(0.1, 3), + ...) { method <- match.arg(method) t0 <- Sys.time() x <- .prepare_data_clustering(x, include_factors = include_factors, standardize = standardize, ...) @@ -250,7 +257,13 @@ n_clusters_hclust <- function(x, #' @keywords internal -.n_clusters_factoextra <- function(x, method = "wss", standardize = TRUE, include_factors = FALSE, clustering_function = stats::kmeans, n_max = 10, ...) { +.n_clusters_factoextra <- function(x, + method = "wss", + standardize = TRUE, + include_factors = FALSE, + clustering_function = stats::kmeans, + n_max = 10, + ...) { x <- .prepare_data_clustering(x, include_factors = include_factors, standardize = standardize, ...) insight::check_if_installed("factoextra") @@ -265,31 +278,31 @@ n_clusters_hclust <- function(x, #' @export print.n_clusters_elbow <- function(x, ...) { - insight::print_color(paste0("The Elbow method, that aims at minimizing the total intra-cluster variation (i.e., the total within-cluster sum of square), suggests that the optimal number of clusters is ", attributes(x)$n, "."), "green") + insight::print_color(paste0("The Elbow method, that aims at minimizing the total intra-cluster variation (i.e., the total within-cluster sum of square), suggests that the optimal number of clusters is ", attributes(x)$n, "."), "green") # nolint invisible(x) } #' @export print.n_clusters_gap <- function(x, ...) { - insight::print_color(paste0("The Gap method, that compares the total intracluster variation of k clusters with their expected values under null reference distribution of the data, suggests that the optimal number of clusters is ", attributes(x)$n, "."), "green") + insight::print_color(paste0("The Gap method, that compares the total intracluster variation of k clusters with their expected values under null reference distribution of the data, suggests that the optimal number of clusters is ", attributes(x)$n, "."), "green") # nolint invisible(x) } #' @export print.n_clusters_silhouette <- function(x, ...) { - insight::print_color(paste0("The Silhouette method, based on the average quality of clustering, suggests that the optimal number of clusters is ", attributes(x)$n, "."), "green") + insight::print_color(paste0("The Silhouette method, based on the average quality of clustering, suggests that the optimal number of clusters is ", attributes(x)$n, "."), "green") # nolint invisible(x) } #' @export print.n_clusters_dbscan <- function(x, ...) { - insight::print_color(paste0("The DBSCAN method, based on the total clusters sum of squares, suggests that the optimal eps = ", attributes(x)$eps, " (with min. cluster size set to ", attributes(x)$min_size, "), which corresponds to ", attributes(x)$n, " clusters."), "green") + insight::print_color(paste0("The DBSCAN method, based on the total clusters sum of squares, suggests that the optimal eps = ", attributes(x)$eps, " (with min. cluster size set to ", attributes(x)$min_size, "), which corresponds to ", attributes(x)$n, " clusters."), "green") # nolint invisible(x) } #' @export print.n_clusters_hclust <- function(x, ...) { - insight::print_color(paste0("The bootstrap analysis of hierachical clustering highlighted ", attributes(x)$n, " significant clusters."), "green") + insight::print_color(paste0("The bootstrap analysis of hierachical clustering highlighted ", attributes(x)$n, " significant clusters."), "green") # nolint invisible(x) } @@ -297,25 +310,28 @@ print.n_clusters_hclust <- function(x, ...) { #' @export visualisation_recipe.n_clusters_elbow <- function(x, ...) { - data <- as.data.frame(x) - data$Gradient <- datawizard::rescale(attributes(x)$gradient, c(min(data$WSS, max(data$WSS)))) + input_df <- as.data.frame(x) + input_df$Gradient <- datawizard::rescale( + attributes(x)$gradient, + min(input_df$WSS, max(input_df$WSS)) + ) layers <- list() # Layers ----------------------- layers[["l1"]] <- list( geom = "line", - data = data, + data = input_df, aes = list(x = "n_Clusters", y = "WSS", group = 1), size = 1 ) layers[["l2"]] <- list( geom = "point", - data = data, + data = input_df, aes = list(x = "n_Clusters", y = "WSS") ) layers[["l3"]] <- list( geom = "line", - data = data, + data = input_df, aes = list(x = "n_Clusters", y = "Gradient", group = 1), size = 0.5, color = "red", @@ -323,7 +339,7 @@ visualisation_recipe.n_clusters_elbow <- function(x, ...) { ) layers[["l4"]] <- list( geom = "vline", - data = data, + data = input_df, xintercept = attributes(x)$n, linetype = "dotted" ) @@ -336,32 +352,32 @@ visualisation_recipe.n_clusters_elbow <- function(x, ...) { # Out class(layers) <- c("visualisation_recipe", "see_visualisation_recipe", class(layers)) - attr(layers, "data") <- data + attr(layers, "data") <- input_df layers } #' @export visualisation_recipe.n_clusters_gap <- function(x, ...) { - data <- as.data.frame(x) - data$ymin <- attributes(x)$ymin - data$ymax <- attributes(x)$ymax + dataset <- as.data.frame(x) + dataset$ymin <- attributes(x)$ymin + dataset$ymax <- attributes(x)$ymax layers <- list() # Layers ----------------------- layers[["l1"]] <- list( geom = "line", - data = data, + data = dataset, aes = list(x = "n_Clusters", y = "Gap", group = 1) ) layers[["l2"]] <- list( geom = "pointrange", - data = data, + data = dataset, aes = list(x = "n_Clusters", y = "Gap", ymin = "ymin", ymax = "ymax") ) layers[["l4"]] <- list( geom = "vline", - data = data, + data = dataset, xintercept = attributes(x)$n, linetype = "dotted" ) @@ -374,30 +390,30 @@ visualisation_recipe.n_clusters_gap <- function(x, ...) { # Out class(layers) <- c("visualisation_recipe", "see_visualisation_recipe", class(layers)) - attr(layers, "data") <- data + attr(layers, "data") <- dataset layers } #' @export visualisation_recipe.n_clusters_silhouette <- function(x, ...) { - data <- as.data.frame(x) + dataset <- as.data.frame(x) layers <- list() # Layers ----------------------- layers[["l1"]] <- list( geom = "line", - data = data, + data = dataset, aes = list(x = "n_Clusters", y = "Silhouette", group = 1) ) layers[["l2"]] <- list( geom = "point", - data = data, + data = dataset, aes = list(x = "n_Clusters", y = "Silhouette") ) layers[["l4"]] <- list( geom = "vline", - data = data, + data = dataset, xintercept = attributes(x)$n, linetype = "dotted" ) @@ -410,38 +426,41 @@ visualisation_recipe.n_clusters_silhouette <- function(x, ...) { # Out class(layers) <- c("visualisation_recipe", "see_visualisation_recipe", class(layers)) - attr(layers, "data") <- data + attr(layers, "data") <- dataset layers } #' @export visualisation_recipe.n_clusters_dbscan <- function(x, ...) { - data <- as.data.frame(x) + dataset <- as.data.frame(x) layers <- list() # Layers ----------------------- if ("gradient" %in% names(attributes(x))) { - data$gradient <- datawizard::rescale(attributes(x)$gradient, c(min(data$eps), max(data$eps))) + dataset$gradient <- datawizard::rescale( + attributes(x)$gradient, + c(min(dataset$eps), max(dataset$eps)) + ) layers[["l1"]] <- list( geom = "line", - data = data, + data = dataset, aes = list(x = "n_Obs", y = "eps"), size = 1 ) layers[["l2"]] <- list( geom = "line", - data = data, + data = dataset, aes = list(x = "n_Obs", y = "gradient"), color = "red", linetype = "dashed" ) layers[["l3"]] <- list( geom = "hline", - data = data, + data = dataset, yintercept = attributes(x)$eps, linetype = "dotted" ) @@ -452,24 +471,27 @@ visualisation_recipe.n_clusters_dbscan <- function(x, ...) { title = "DBSCAN Method" ) } else { - data$y <- datawizard::rescale(data$total_SS, c(min(data$n_Clusters), max(data$n_Clusters))) + dataset$y <- datawizard::rescale( + dataset$total_SS, + c(min(dataset$n_Clusters), max(dataset$n_Clusters)) + ) layers[["l1"]] <- list( geom = "line", - data = data, + data = dataset, aes = list(x = "eps", y = "n_Clusters"), size = 1 ) layers[["l2"]] <- list( geom = "line", - data = data, + data = dataset, aes = list(x = "eps", y = "y"), color = "red", linetype = "dashed" ) layers[["l3"]] <- list( geom = "vline", - data = data, + data = dataset, xintercept = attributes(x)$eps, linetype = "dotted" ) @@ -483,7 +505,7 @@ visualisation_recipe.n_clusters_dbscan <- function(x, ...) { # Out class(layers) <- c("visualisation_recipe", "see_visualisation_recipe", class(layers)) - attr(layers, "data") <- data + attr(layers, "data") <- dataset layers } diff --git a/R/print.parameters_model.R b/R/print.parameters_model.R index 35876aff2..58fa5a213 100644 --- a/R/print.parameters_model.R +++ b/R/print.parameters_model.R @@ -385,7 +385,7 @@ print.parameters_random <- function(x, digits = 2, ...) { ci_width = "auto", ci_brackets = TRUE, format = "text", - group = NULL, + groups = NULL, include_reference = FALSE, ...) { format( @@ -400,7 +400,7 @@ print.parameters_random <- function(x, digits = 2, ...) { ci_brackets = ci_brackets, zap_small = zap_small, format = format, - group = group, + groups = groups, include_reference = include_reference, ... ) diff --git a/R/print_md.R b/R/print_md.R index cc997fe3a..f7bc40e64 100644 --- a/R/print_md.R +++ b/R/print_md.R @@ -252,9 +252,9 @@ print_md.parameters_efa_summary <- function(x, digits = 3, ...) { table_caption <- "(Explained) Variance of Components" if ("Parameter" %in% names(x)) { - x$Parameter <- c("Eigenvalues", "Variance Explained", "Variance Explained (Cumulative)", "Variance Explained (Proportion)") + x$Parameter <- c("Eigenvalues", "Variance Explained", "Variance Explained (Cumulative)", "Variance Explained (Proportion)") # nolint } else if ("Component" %in% names(x)) { - names(x) <- c("Component", "Eigenvalues", "Variance Explained", "Variance Explained (Cumulative)", "Variance Explained (Proportion)") + names(x) <- c("Component", "Eigenvalues", "Variance Explained", "Variance Explained (Cumulative)", "Variance Explained (Proportion)") # nolint } insight::export_table(x, digits = digits, format = "markdown", caption = table_caption, align = "firstleft") } @@ -327,7 +327,7 @@ print_md.equivalence_test_lm <- function(x, digits = 2, ci_brackets = c("(", ")" } if (!is.null(rope)) { - names(formatted_table)[names(formatted_table) == "% in ROPE"] <- sprintf("%% in ROPE (%.*f, %.*f)", digits, rope[1], digits, rope[2]) + names(formatted_table)[names(formatted_table) == "% in ROPE"] <- sprintf("%% in ROPE (%.*f, %.*f)", digits, rope[1], digits, rope[2]) # nolint } insight::export_table(formatted_table, format = "markdown", caption = table_caption, align = "firstleft") diff --git a/R/select_parameters.R b/R/select_parameters.R index 3588d74e4..93c697017 100644 --- a/R/select_parameters.R +++ b/R/select_parameters.R @@ -6,21 +6,17 @@ #' @param model A statistical model (of class `lm`, `glm`, or `merMod`). #' @param ... Arguments passed to or from other methods. #' -#' @details -#' \subsection{Classical lm and glm}{ -#' For frequentist GLMs, `select_parameters()` performs an AIC-based -#' stepwise selection. -#' } +#' @section Classical lm and glm: +#' For frequentist GLMs, `select_parameters()` performs an AIC-based stepwise +#' selection. #' -#' \subsection{Mixed models}{ -#' For mixed-effects models of class `merMod`, stepwise selection is -#' based on [cAIC4::stepcAIC()]. This step function -#' only searches the "best" model based on the random-effects structure, -#' i.e. `select_parameters()` adds or excludes random-effects until -#' the cAIC can't be improved further. -#' } +#' @section Mixed models: +#' For mixed-effects models of class `merMod`, stepwise selection is based on +#' [`cAIC4::stepcAIC()`]. This step function only searches the "best" model +#' based on the random-effects structure, i.e. `select_parameters()` adds or +#' excludes random-effects until the cAIC can't be improved further. #' -#' @examples +#' @examplesIf requireNamespace("lme4") #' model <- lm(mpg ~ ., data = mtcars) #' select_parameters(model) #' @@ -28,13 +24,11 @@ #' select_parameters(model) #' \donttest{ #' # lme4 ------------------------------------------- -#' if (require("lme4")) { -#' model <- lmer( -#' Sepal.Width ~ Sepal.Length * Petal.Width * Petal.Length + (1 | Species), -#' data = iris -#' ) -#' select_parameters(model) -#' } +#' model <- lme4::lmer( +#' Sepal.Width ~ Sepal.Length * Petal.Width * Petal.Length + (1 | Species), +#' data = iris +#' ) +#' select_parameters(model) #' } #' #' @return The model refitted with optimal number of parameters. @@ -45,6 +39,9 @@ select_parameters <- function(model, ...) { #' @rdname select_parameters +#' @param k The multiple of the number of degrees of freedom used for the penalty. +#' Only `k = 2` gives the genuine AIC: `k = log(n)` is sometimes referred to as +#' BIC or SBC. #' @inheritParams stats::step #' @export select_parameters.lm <- function(model, @@ -108,10 +105,15 @@ select_parameters.merMod <- function(model, ) - # Using MuMIn's dredge(): works nicely BUT throws unnecessary warnings and requires to set global options for na.action even tho no NaNs. + # Using MuMIn's dredge(): works nicely BUT throws unnecessary warnings and + # requires to set global options for na.action even tho no NaNs. # The code is here: https://github.com/cran/MuMIn/blob/master/R/dredge.R Maybe it could be reimplemented? # insight::check_if_installed("MuMIn") - # model <- lmer(Sepal.Width ~ Sepal.Length * Petal.Width * Petal.Length + (1 | Species), data = iris, na.action = na.fail) + # model <- lmer( + # Sepal.Width ~ Sepal.Length * Petal.Width * Petal.Length + (1 | Species), + # data = iris, + # na.action = na.fail + # ) # summary(MuMIn::get.models(MuMIn::dredge(model), 1)[[1]]) best diff --git a/R/standardize_parameters.R b/R/standardize_parameters.R index 1c3885271..05ee794b2 100644 --- a/R/standardize_parameters.R +++ b/R/standardize_parameters.R @@ -13,7 +13,7 @@ #' @inheritParams datawizard::standardize.default #' @inheritParams effectsize::chisq_to_phi #' @param ... For `standardize_parameters()`, arguments passed to -#' [model_parameters()], such as: +#' [`model_parameters()`], such as: #' - `ci_method`, `centrality` for Mixed models and Bayesian models... #' - `exponentiate`, ... #' - etc. @@ -30,7 +30,7 @@ #' include interactions or transformations (e.g., polynomial or spline terms). #' The `robust` (default to `FALSE`) argument enables a robust standardization #' of data, i.e., based on the `median` and `MAD` instead of the `mean` and -#' `SD`. **See [standardize()] for more details.** +#' `SD`. **See [`datawizard::standardize()`] for more details.** #' - **Note** that `standardize_parameters(method = "refit")` may not return #' the same results as fitting a model on data that has been standardized with #' `standardize()`; `standardize_parameters()` used the data used by the model @@ -52,7 +52,7 @@ #' deviation of model's matrix' parameter of factors levels (transformed to #' integers) or binary predictors. Although being inappropriate for these cases, #' this method is the one implemented by default in other software packages, -#' such as [lm.beta::lm.beta()]. +#' such as [`lm.beta::lm.beta()`]. #' - **smart** (Standardization of Model's parameters with Adjustment, #' Reconnaissance and Transformation - *experimental*): Similar to `method = #' "posthoc"` in that it does not involve model refitting. The difference is @@ -64,9 +64,9 @@ #' delta. #' - **pseudo** (*for 2-level (G)LMMs only*): In this (post-hoc) method, the #' response and the predictor are standardized based on the level of prediction -#' (levels are detected with [performance::check_heterogeneity_bias()]): Predictors +#' (levels are detected with [`performance::check_heterogeneity_bias()`]): Predictors #' are standardized based on their SD at level of prediction (see also -#' [datawizard::demean()]); The outcome (in linear LMMs) is standardized based +#' [`datawizard::demean()`]); The outcome (in linear LMMs) is standardized based #' on a fitted random-intercept-model, where `sqrt(random-intercept-variance)` #' is used for level 2 predictors, and `sqrt(residual-variance)` is used for #' level 1 predictors (Hoffman 2015, page 342). A warning is given when a @@ -91,9 +91,9 @@ #' equivalent to `exp(scale(X))`), the `"basic"` method standardizes the #' transformed data (e.g. equivalent to `scale(exp(X))`). #' \cr\cr -#' See the *Transformed Variables* section in [standardize.default()] for more -#' details on how different transformations are dealt with when `method = -#' "refit"`. +#' See the *Transformed Variables* section in [`datawizard::standardize.default()`] +#' for more details on how different transformations are dealt with when +#' `method = "refit"`. #' #' ## Confidence Intervals #' The returned confidence intervals are re-scaled versions of the diff --git a/R/standardize_posteriors.R b/R/standardize_posteriors.R index cccab54ca..27a9f5baf 100644 --- a/R/standardize_posteriors.R +++ b/R/standardize_posteriors.R @@ -72,7 +72,7 @@ standardise_posteriors <- standardize_posteriors i <- match(deviations$Parameter, colnames(pars)) pars <- pars[, i] - if (method == "basic") { + if (method == "basic") { # nolint col_dev_resp <- "Deviation_Response_Basic" col_dev_pred <- "Deviation_Basic" } else if (method == "posthoc") { diff --git a/cran-comments.md b/cran-comments.md index 88b6f9530..5768f7b84 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1 +1 @@ -This release addresses errors in CRAN checks related to the last *marginaleffects* update. +This release addresses issues with duplicated ORCID in the DESCRIPTION file. diff --git a/inst/WORDLIST b/inst/WORDLIST index a7e977782..879650eb9 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -228,8 +228,10 @@ ggeffects github glm glm's +glmgee glmmTMB glmx +glmtoolbox hclust heteroskedasticity hglm 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.Rd b/man/model_parameters.Rd index d124d2cc9..74d40b89b 100644 --- a/man/model_parameters.Rd +++ b/man/model_parameters.Rd @@ -99,7 +99,7 @@ models). This method is particularly recommended for complex models that include interactions or transformations (e.g., polynomial or spline terms). The \code{robust} (default to \code{FALSE}) argument enables a robust standardization of data, i.e., based on the \code{median} and \code{MAD} instead of the \code{mean} and -\code{SD}. \strong{See \code{\link[=standardize]{standardize()}} for more details.} +\code{SD}. \strong{See \code{\link[datawizard:standardize]{datawizard::standardize()}} for more details.} \strong{Note} that \code{standardize_parameters(method = "refit")} may not return the same results as fitting a model on data that has been standardized with \code{standardize()}; \code{standardize_parameters()} used the data used by the model 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/man/parameters-package.Rd b/man/parameters-package.Rd index ab8407b4f..3f8d4c249 100644 --- a/man/parameters-package.Rd +++ b/man/parameters-package.Rd @@ -46,7 +46,7 @@ Authors: Other contributors: \itemize{ \item Zen J. Lau \email{zenjuen.lau@ntu.edu.sg} [contributor] - \item Vincent Arel-Bundock \email{vincent.arel-bundock@umontreal.ca} (\href{https://orcid.org/0000-0003-1995-6531}{ORCID}) (@vincentab) [contributor] + \item Vincent Arel-Bundock \email{vincent.arel-bundock@umontreal.ca} (\href{https://orcid.org/0000-0003-2042-7063}{ORCID}) (@vincentab) [contributor] \item Jeffrey Girard \email{me@jmgirard.com} (\href{https://orcid.org/0000-0002-7359-3746}{ORCID}) (@jeffreymgirard) [contributor] \item Christina Maimone \email{christina.maimone@northwestern.edu} [reviewer] \item Niels Ohlsen (@Niels_Bremen) [reviewer] diff --git a/man/select_parameters.Rd b/man/select_parameters.Rd index edff5d02c..12a880eac 100644 --- a/man/select_parameters.Rd +++ b/man/select_parameters.Rd @@ -30,11 +30,9 @@ select_parameters(model, ...) process early. } -\item{k}{ - the multiple of the number of degrees of freedom used for the penalty. - Only \code{k = 2} gives the genuine AIC: \code{k = log(n)} is sometimes - referred to as BIC or \abbr{SBC}. - } +\item{k}{The multiple of the number of degrees of freedom used for the penalty. +Only \code{k = 2} gives the genuine AIC: \code{k = log(n)} is sometimes referred to as +BIC or SBC.} } \value{ The model refitted with optimal number of parameters. @@ -43,21 +41,22 @@ The model refitted with optimal number of parameters. This function performs an automated selection of the 'best' parameters, updating and returning the "best" model. } -\details{ -\subsection{Classical lm and glm}{ -For frequentist GLMs, \code{select_parameters()} performs an AIC-based -stepwise selection. -} +\section{Classical lm and glm}{ -\subsection{Mixed models}{ -For mixed-effects models of class \code{merMod}, stepwise selection is -based on \code{\link[cAIC4:stepcAIC]{cAIC4::stepcAIC()}}. This step function -only searches the "best" model based on the random-effects structure, -i.e. \code{select_parameters()} adds or excludes random-effects until -the cAIC can't be improved further. +For frequentist GLMs, \code{select_parameters()} performs an AIC-based stepwise +selection. } + +\section{Mixed models}{ + +For mixed-effects models of class \code{merMod}, stepwise selection is based on +\code{\link[cAIC4:stepcAIC]{cAIC4::stepcAIC()}}. This step function only searches the "best" model +based on the random-effects structure, i.e. \code{select_parameters()} adds or +excludes random-effects until the cAIC can't be improved further. } + \examples{ +\dontshow{if (requireNamespace("lme4")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} model <- lm(mpg ~ ., data = mtcars) select_parameters(model) @@ -65,13 +64,11 @@ model <- lm(mpg ~ cyl * disp * hp * wt, data = mtcars) select_parameters(model) \donttest{ # lme4 ------------------------------------------- -if (require("lme4")) { - model <- lmer( - Sepal.Width ~ Sepal.Length * Petal.Width * Petal.Length + (1 | Species), - data = iris - ) - select_parameters(model) -} +model <- lme4::lmer( + Sepal.Width ~ Sepal.Length * Petal.Width * Petal.Length + (1 | Species), + data = iris +) +select_parameters(model) } - +\dontshow{\}) # examplesIf} } diff --git a/man/standardize_parameters.Rd b/man/standardize_parameters.Rd index a0bd0eeaa..db5c3945a 100644 --- a/man/standardize_parameters.Rd +++ b/man/standardize_parameters.Rd @@ -84,7 +84,7 @@ models). This method is particularly recommended for complex models that include interactions or transformations (e.g., polynomial or spline terms). The \code{robust} (default to \code{FALSE}) argument enables a robust standardization of data, i.e., based on the \code{median} and \code{MAD} instead of the \code{mean} and -\code{SD}. \strong{See \code{\link[=standardize]{standardize()}} for more details.} +\code{SD}. \strong{See \code{\link[datawizard:standardize]{datawizard::standardize()}} for more details.} \itemize{ \item \strong{Note} that \code{standardize_parameters(method = "refit")} may not return the same results as fitting a model on data that has been standardized with @@ -148,8 +148,9 @@ When the model's formula contains transformations (e.g. \code{y ~ exp(X)}) \code equivalent to \code{exp(scale(X))}), the \code{"basic"} method standardizes the transformed data (e.g. equivalent to \code{scale(exp(X))}). \cr\cr -See the \emph{Transformed Variables} section in \code{\link[=standardize.default]{standardize.default()}} for more -details on how different transformations are dealt with when \code{method = "refit"}. +See the \emph{Transformed Variables} section in \code{\link[datawizard:standardize.default]{datawizard::standardize.default()}} +for more details on how different transformations are dealt with when +\code{method = "refit"}. } \subsection{Confidence Intervals}{ 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..bbe50e64b 100644 --- a/tests/testthat/test-model_parameters.aov.R +++ b/tests/testthat/test-model_parameters.aov.R @@ -1,14 +1,14 @@ skip_on_cran() -iris$Cat1 <- rep(c("X", "X", "Y"), length.out = nrow(iris)) -iris$Cat2 <- rep(c("A", "B"), length.out = nrow(iris)) +iris$Cat1 <- rep_len(c("X", "X", "Y"), nrow(iris)) +iris$Cat2 <- rep_len(c("A", "B"), nrow(iris)) # 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(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..7beda64f4 100644 --- a/tests/testthat/test-model_parameters.aov_es_ci.R +++ b/tests/testthat/test-model_parameters.aov_es_ci.R @@ -1,5 +1,5 @@ -iris$Cat1 <- rep(c("X", "X", "Y"), length.out = nrow(iris)) -iris$Cat2 <- rep(c("A", "B"), length.out = nrow(iris)) +iris$Cat1 <- rep_len(c("X", "X", "Y"), nrow(iris)) +iris$Cat2 <- rep_len(c("A", "B"), nrow(iris)) # aov ---------------------------------- @@ -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 )) @@ -271,7 +271,8 @@ test_that("works with manova", { set.seed(123) # fake a 2nd response variable - npk2 <- within(npk, foo <- rnorm(24)) + foo <- rnorm(24) + npk2 <- within(npk, foo) # model m <- manova(cbind(yield, foo) ~ block + N * P * K, npk2) @@ -280,7 +281,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 +334,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 )) @@ -345,7 +346,7 @@ test_that("works with Gam", { Sum_Squares = c(678.37287, 202.23503, 6.87905, 238.56023), df = c(1, 1, 1, 28), Mean_Square = c(678.37287, 202.23503, 6.87905, 8.52001), - `F` = c(79.62115, 23.73648, 0.8074, NA), + `F` = c(79.62115, 23.73648, 0.8074, NA), # nolint p = c(0, 4e-05, 0.37655, NA), Omega2_partial = c(0.71072, 0.41538, -0.00606, NA), Omega2_CI_low = c(0.70634, 0.41067, 0, NA), @@ -384,7 +385,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.blmerMod.R b/tests/testthat/test-model_parameters.blmerMod.R index 77308e385..fde18e5ea 100644 --- a/tests/testthat/test-model_parameters.blmerMod.R +++ b/tests/testthat/test-model_parameters.blmerMod.R @@ -8,8 +8,8 @@ model <- blme::blmer(Reaction ~ Days + (1 + Days | Subject), data = sleepstudy, test_that("model_parameters.blmerMod", { params <- model_parameters(model, effects = "fixed") expect_equal(params$SE, c(6.8246, 1.54579), tolerance = 1e-3) - expect_equal( - colnames(params), + expect_named( + params, c("Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high", "t", "df_error", "p", "Effects") ) }) @@ -19,11 +19,11 @@ test_that("model_parameters.blmerMod-all", { params <- model_parameters(model, effects = "all") expect_equal(params$SE, c(6.8246, 1.54579, 5.83626, 1.24804, 0.31859, 1.50801), tolerance = 1e-3) expect_equal(params$Coefficient, c(251.4051, 10.46729, 24.74066, 5.92214, 0.06555, 25.5918), tolerance = 1e-3) - expect_equal( - colnames(params), + expect_named( + params, c("Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high", "t", "df_error", "p", "Effects", "Group") ) - expect_equal( + expect_identical( params$Parameter, c("(Intercept)", "Days", "SD (Intercept)", "SD (Days)", "Cor (Intercept~Days)", "SD (Observations)") ) 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 ) ``` diff --git a/vignettes/model_parameters_print.Rmd b/vignettes/model_parameters_print.Rmd index ba23f8583..c4a94810d 100644 --- a/vignettes/model_parameters_print.Rmd +++ b/vignettes/model_parameters_print.Rmd @@ -15,8 +15,7 @@ editor_options: bibliography: bibliography.bib --- -```{r , include=FALSE} -library(knitr) +```{r, include=FALSE} options(knitr.kable.NA = "") options(digits = 2) @@ -25,19 +24,22 @@ knitr::opts_chunk$set( collapse = TRUE, warning = FALSE, message = FALSE, + eval = requireNamespace("gt", quietly = TRUE), comment = "#>", out.width = "100%", tidy.opts = list(width.cutoff = 100) ) -pkgs <- c("gt", "datawizard", "glmmTMB", "parameters") +# hard deps +library(parameters) +library(datawizard) +# soft deps +pkgs <- c("gt", "glmmTMB") successfully_loaded <- sapply(pkgs, requireNamespace, quietly = TRUE) - if (all(successfully_loaded)) { - library(parameters) - library(datawizard) library(glmmTMB) + library(gt) } set.seed(333) @@ -67,7 +69,7 @@ print(mp, pretty_names = FALSE) If data is [labelled](https://strengejacke.github.io/sjlabelled/articles/intro_sjlabelled.html), `pretty_names = "labels"` will use variable and value labels as pretty names. If data is not labelled, default pretty names will be used. -```{r eval=successfully_loaded["datawizard"]} +```{r} data(efc, package = "datawizard") model <- lm(neg_c_7 ~ e42dep + c172code, data = efc) @@ -212,9 +214,9 @@ Note that the parameters in the table summary are re-ordered according to the or ```{r} # group parameters, either by parameter name or position print(mp, groups = list( - "Engine" = c("cyl6", "cyl8", "vs", "hp"), - "Interactions" = c("gear4:vs", "gear5:vs"), - "Controls" = c(2, 3, 7) + Engine = c("cyl6", "cyl8", "vs", "hp"), + Interactions = c("gear4:vs", "gear5:vs"), + Controls = c(2, 3, 7) )) # gear 4 and 5, drat ``` @@ -225,9 +227,9 @@ If you prefer tables without vertical borders, use the `sep` argument to define print(mp, sep = " ", groups = list( - "Engine" = c("cyl6", "cyl8", "vs", "hp"), - "Interactions" = c("gear4:vs", "gear5:vs"), - "Controls" = c(2, 3, 7) + Engine = c("cyl6", "cyl8", "vs", "hp"), + Interactions = c("gear4:vs", "gear5:vs"), + Controls = c(2, 3, 7) ) ) ```