diff --git a/DESCRIPTION b/DESCRIPTION index 8dff1add1..7f7a22354 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: parameters Title: Processing of Model Parameters -Version: 0.28.2 +Version: 0.28.2.3 Authors@R: c(person(given = "Daniel", family = "Lüdecke", @@ -224,10 +224,11 @@ VignetteBuilder: knitr Encoding: UTF-8 Language: en-US -RoxygenNote: 7.3.2 +RoxygenNote: 7.3.3 Roxygen: list(markdown = TRUE) Config/testthat/edition: 3 Config/testthat/parallel: true Config/Needs/website: easystats/easystatstemplate Config/Needs/check: stan-dev/cmdstanr Config/rcmdcheck/ignore-inconsequential-notes: true +Remotes: easystats/insight, easystats/modelbased diff --git a/NAMESPACE b/NAMESPACE index 5933be9ac..ca1b69d08 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -34,6 +34,9 @@ S3method(ci,crq) S3method(ci,default) S3method(ci,deltaMethod) S3method(ci,effectsize_table) +S3method(ci,estimate_contrasts) +S3method(ci,estimate_means) +S3method(ci,estimate_slopes) S3method(ci,fixest_multi) S3method(ci,flac) S3method(ci,flic) @@ -137,6 +140,9 @@ S3method(display,parameters_simulate) S3method(display,parameters_standardized) S3method(dof_satterthwaite,lmerMod) S3method(equivalence_test,MixMod) +S3method(equivalence_test,estimate_contrasts) +S3method(equivalence_test,estimate_means) +S3method(equivalence_test,estimate_slopes) S3method(equivalence_test,feis) S3method(equivalence_test,felm) S3method(equivalence_test,gee) @@ -237,6 +243,9 @@ S3method(model_parameters,draws) S3method(model_parameters,emmGrid) S3method(model_parameters,emm_list) S3method(model_parameters,epi.2by2) +S3method(model_parameters,estimate_contrasts) +S3method(model_parameters,estimate_means) +S3method(model_parameters,estimate_slopes) S3method(model_parameters,fa) S3method(model_parameters,fa.ci) S3method(model_parameters,feglm) @@ -788,6 +797,9 @@ S3method(standard_error,draws) S3method(standard_error,effectsize_table) S3method(standard_error,emmGrid) S3method(standard_error,emm_list) +S3method(standard_error,estimate_contrasts) +S3method(standard_error,estimate_means) +S3method(standard_error,estimate_slopes) S3method(standard_error,factor) S3method(standard_error,feglm) S3method(standard_error,fitdistr) diff --git a/NEWS.md b/NEWS.md index aee8ad3c7..266a10cba 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# parameters 0.28.2.1 + +* `equivalence_test()` gets methods for objects from the *modelbased* package. + # parameters 0.28.2 ## Bug fixes diff --git a/R/equivalence_test.R b/R/equivalence_test.R index a24ef7386..0ca8d9312 100644 --- a/R/equivalence_test.R +++ b/R/equivalence_test.R @@ -355,6 +355,98 @@ equivalence_test.glmmTMB <- equivalence_test.merMod equivalence_test.MixMod <- equivalence_test.merMod +# modelbased ------------------------------ + +#' @export +equivalence_test.estimate_means <- function( + x, + range = "default", + ci = 0.95, + rule = "classic", + vcov = NULL, + vcov_args = NULL, + verbose = TRUE, + ... +) { + # ==== define rope range ==== + + range <- .check_rope_range(x, range, verbose) + + if (length(ci) > 1) { + insight::format_alert("`ci` may only be of length 1. Using first ci-value now.") + ci <- ci[1] + } + + # ==== check degrees of freedom ==== + + dof <- unique(insight::get_df(x)) + if (length(dof) > 1) { + dof <- Inf + } + + # ==== requested confidence intervals ==== + + conf_int <- as.data.frame(t(x[c("CI_low", "CI_high")])) + + # ==== the "narrower" intervals (1-2*alpha) for CET-rules. ==== + + alpha <- 1 - ci + insight::check_if_installed("modelbased") + + # we need to call the modelbased function again, so get the call + # modify CI and evaluate that call + cl <- insight::get_call(x) + cl$ci <- ci - alpha + x2 <- eval(cl) + conf_int2 <- as.data.frame(t(x2[c("CI_low", "CI_high")])) + + # ==== equivalence test for each parameter ==== + + l <- Map( + function(ci_wide, ci_narrow) { + .equivalence_test_numeric( + ci = ci, + ci_wide, + ci_narrow, + range_rope = range, + rule = rule, + dof = dof, + verbose = verbose + ) + }, + conf_int, + conf_int2 + ) + + dat <- do.call(rbind, l) + params <- insight::get_parameters(x) + + out <- data.frame( + Parameter = params$Parameter, + CI = ifelse(rule == "bayes", ci, ci - alpha), + dat, + stringsAsFactors = FALSE + ) + + # ==== (adjusted) p-values for tests ==== + + out$p <- .add_p_to_equitest(x, ci, range, vcov = vcov, vcov_args = vcov_args, ...) + + attr(out, "rope") <- range + attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(x)) + attr(out, "rule") <- rule + class(out) <- c("equivalence_test_lm", "see_equivalence_test_lm", class(out)) + + out +} + +#' @export +equivalence_test.estimate_contrasts <- equivalence_test.estimate_means + +#' @export +equivalence_test.estimate_slopes <- equivalence_test.estimate_means + + # Special classes ------------------------- #' @export @@ -407,6 +499,14 @@ equivalence_test.parameters_model <- function(x, #' @keywords internal .check_rope_range <- function(x, range, verbose) { + # for modelbased-objects, we extract the model to define the rope range + if (inherits(x, c("estimate_means", "estimate_contrasts", "estimate_slopes"))) { + x <- .safe(insight::get_model(x)) + # if not successful, return defaults + if (is.null(x)) { + return(c(-1, 1)) + } + } if (all(range == "default")) { range <- bayestestR::rope_range(x, verbose = verbose) if (is.list(range)) { @@ -439,7 +539,6 @@ equivalence_test.parameters_model <- function(x, ci <- ci[1] } - # ==== check degrees of freedom ==== df_column <- grep("(df|df_error)", colnames(x)) diff --git a/R/methods_modelbased.R b/R/methods_modelbased.R new file mode 100644 index 000000000..3edc2926d --- /dev/null +++ b/R/methods_modelbased.R @@ -0,0 +1,56 @@ +# model_parameters ---------------- + +#' @export +model_parameters.estimate_means <- function(model, ...) { + out <- model + class(out) <- c("parameters_model", "see_parameters_model", class(out)) + out +} + +#' @export +model_parameters.estimate_slopes <- model_parameters.estimate_means + +#' @export +model_parameters.estimate_contrasts <- model_parameters.estimate_means + + +# standard_error ---------------- + +#' @export +standard_error.estimate_means <- function(model, ...) { + params <- insight::get_parameters(model) + data.frame(Parameter = params$Parameter, SE = model$SE, stringsAsFactors = FALSE) +} + +#' @export +standard_error.estimate_slopes <- standard_error.estimate_means + +#' @export +standard_error.estimate_contrasts <- standard_error.estimate_means + + +# ci ---------------- + +#' @export +ci.estimate_means <- function(x, ...) { + params <- insight::get_parameters(x) + + ci_value <- attributes(x)$ci + if (is.null(ci_value)) { + ci_value <- 0.95 + } + + data.frame( + Parameter = params$Parameter, + CI = ci_value, + CI_low = x$CI_low, + CI_high = x$CI_high, + stringsAsFactors = FALSE + ) +} + +#' @export +ci.estimate_slopes <- ci.estimate_means + +#' @export +ci.estimate_contrasts <- ci.estimate_means diff --git a/R/n_clusters_easystats.R b/R/n_clusters_easystats.R index 3c389a0ff..204d3eb00 100644 --- a/R/n_clusters_easystats.R +++ b/R/n_clusters_easystats.R @@ -244,20 +244,34 @@ n_clusters_hclust <- function(x, # Utils ------------------------------------------------------------------- - #' @keywords internal -.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, ...) +.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") - factoextra::fviz_nbclust(x, clustering_function, method = method, k.max = n_max, verbose = FALSE)$data + suppressWarnings( + factoextra::fviz_nbclust( + x, + clustering_function, + method = method, + k.max = n_max, + verbose = FALSE + )$data + ) } diff --git a/inst/WORDLIST b/inst/WORDLIST index f42bd3482..90c8832df 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -319,6 +319,7 @@ mgcv mhurdle mlogit mmrm +modelbased modelsummary multcomp multicollinearity diff --git a/man/bootstrap_model.Rd b/man/bootstrap_model.Rd index d030a0cb8..249b363f5 100644 --- a/man/bootstrap_model.Rd +++ b/man/bootstrap_model.Rd @@ -70,7 +70,7 @@ to obtain non-parametric p-values. } \examples{ -\dontshow{if (require("boot", quietly = TRUE) && require("emmeans", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("boot", quietly = TRUE) && require("emmeans", quietly = TRUE)) withAutoprint(\{ # examplesIf} \donttest{ model <- lm(mpg ~ wt + factor(cyl), data = mtcars) b <- bootstrap_model(model) diff --git a/man/bootstrap_parameters.Rd b/man/bootstrap_parameters.Rd index fcecdba27..2272fd486 100644 --- a/man/bootstrap_parameters.Rd +++ b/man/bootstrap_parameters.Rd @@ -78,7 +78,7 @@ to obtain non-parametric p-values. } \examples{ -\dontshow{if (require("boot", quietly = TRUE) && require("emmeans", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("boot", quietly = TRUE) && require("emmeans", quietly = TRUE)) withAutoprint(\{ # examplesIf} \donttest{ set.seed(2) model <- lm(Sepal.Length ~ Species * Petal.Width, data = iris) diff --git a/man/ci.default.Rd b/man/ci.default.Rd index dabf34e9f..4c4b64b90 100644 --- a/man/ci.default.Rd +++ b/man/ci.default.Rd @@ -299,7 +299,7 @@ here. } \examples{ -\dontshow{if (require("glmmTMB") && requireNamespace("sandwich")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("glmmTMB") && requireNamespace("sandwich")) withAutoprint(\{ # examplesIf} data(qol_cancer) model <- lm(QoL ~ time + age + education, data = qol_cancer) diff --git a/man/cluster_discrimination.Rd b/man/cluster_discrimination.Rd index 161dd9dd2..11ffab641 100644 --- a/man/cluster_discrimination.Rd +++ b/man/cluster_discrimination.Rd @@ -20,7 +20,7 @@ determines the goodness of classification for each cluster group. See \code{MASS for details. } \examples{ -\dontshow{if (requireNamespace("MASS", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (requireNamespace("MASS", quietly = TRUE)) withAutoprint(\{ # examplesIf} # Retrieve group classification from hierarchical cluster analysis clustering <- cluster_analysis(iris[, 1:4], n = 3) diff --git a/man/compare_parameters.Rd b/man/compare_parameters.Rd index 54770ea75..863299c17 100644 --- a/man/compare_parameters.Rd +++ b/man/compare_parameters.Rd @@ -236,7 +236,7 @@ Therefore, you should not use this function to compare models with interaction terms with models without interaction terms. } \examples{ -\dontshow{if (require("gt", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("gt", quietly = TRUE)) withAutoprint(\{ # examplesIf} data(iris) lm1 <- lm(Sepal.Length ~ Species, data = iris) lm2 <- lm(Sepal.Length ~ Species + Petal.Length, data = iris) diff --git a/man/convert_efa_to_cfa.Rd b/man/convert_efa_to_cfa.Rd index 5874fa1cf..b31e58823 100644 --- a/man/convert_efa_to_cfa.Rd +++ b/man/convert_efa_to_cfa.Rd @@ -40,7 +40,7 @@ Enables a conversion between Exploratory Factor Analysis (EFA) and Confirmatory Factor Analysis (CFA) \code{lavaan}-ready structure. } \examples{ -\dontshow{if (require("psych") && require("lavaan")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("psych") && require("lavaan")) withAutoprint(\{ # examplesIf} \donttest{ library(parameters) data(attitude) diff --git a/man/degrees_of_freedom.Rd b/man/degrees_of_freedom.Rd index 291bd55aa..d596186ee 100644 --- a/man/degrees_of_freedom.Rd +++ b/man/degrees_of_freedom.Rd @@ -55,7 +55,7 @@ Furthermore, for other approximation methods like \code{"kenward"} or freedom. } \examples{ -\dontshow{if (require("lme4", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("lme4", quietly = TRUE)) withAutoprint(\{ # examplesIf} model <- lm(Sepal.Length ~ Petal.Length * Species, data = iris) dof(model) diff --git a/man/display.parameters_model.Rd b/man/display.parameters_model.Rd index 2743a20bb..c0df36c2e 100644 --- a/man/display.parameters_model.Rd +++ b/man/display.parameters_model.Rd @@ -40,7 +40,7 @@ knitted from rmarkdown to PDF or Word files. See for examples. } \examples{ -\dontshow{if (require("gt", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("gt", quietly = TRUE)) withAutoprint(\{ # examplesIf} model <- lm(mpg ~ wt + cyl, data = mtcars) mp <- model_parameters(model) display(mp) @@ -66,7 +66,7 @@ print_html( ) } \dontshow{\}) # examplesIf} -\dontshow{if (all(insight::check_if_installed(c("glmmTMB", "lme4", "tinytable"), quietly = TRUE))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (all(insight::check_if_installed(c("glmmTMB", "lme4", "tinytable"), quietly = TRUE))) withAutoprint(\{ # examplesIf} \donttest{ data(iris) data(Salamanders, package = "glmmTMB") diff --git a/man/dominance_analysis.Rd b/man/dominance_analysis.Rd index 18732f606..048c1fe9f 100644 --- a/man/dominance_analysis.Rd +++ b/man/dominance_analysis.Rd @@ -124,7 +124,7 @@ When \code{performance::r2()} returns multiple values, only the first is used by default. } \examples{ -\dontshow{if (require("domir") && require("performance")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("domir") && require("performance")) withAutoprint(\{ # examplesIf} data(mtcars) # Dominance Analysis with Logit Regression diff --git a/man/equivalence_test.lm.Rd b/man/equivalence_test.lm.Rd index 82c37c3e6..2e7bf241e 100644 --- a/man/equivalence_test.lm.Rd +++ b/man/equivalence_test.lm.Rd @@ -266,7 +266,7 @@ documentation in \code{\link[=p_function]{p_function()}}). } \examples{ -\dontshow{if (requireNamespace("sandwich")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (requireNamespace("sandwich")) withAutoprint(\{ # examplesIf} data(qol_cancer) model <- lm(QoL ~ time + age + education, data = qol_cancer) diff --git a/man/factor_scores.Rd b/man/factor_scores.Rd index db5ae390e..b848f351f 100644 --- a/man/factor_scores.Rd +++ b/man/factor_scores.Rd @@ -21,7 +21,7 @@ element from the object and converts it into a data frame. \code{\link[psych:fa]{psych::fa()}}, \code{\link[=factor_analysis]{factor_analysis()}}, or \code{\link[psych:omega]{psych::omega()}} } \examples{ -\dontshow{if (insight::check_if_installed("psych", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (insight::check_if_installed("psych", quietly = TRUE)) withAutoprint(\{ # examplesIf} data(mtcars) out <- factor_analysis(mtcars[, 1:7], n = 2) head(factor_scores(out)) diff --git a/man/get_scores.Rd b/man/get_scores.Rd index 478b1f153..22c711119 100644 --- a/man/get_scores.Rd +++ b/man/get_scores.Rd @@ -37,7 +37,7 @@ is on the same scale as the original, single items that were used to compute the PCA/FA. } \examples{ -\dontshow{if (insight::check_if_installed("psych", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (insight::check_if_installed("psych", quietly = TRUE)) withAutoprint(\{ # examplesIf} pca <- principal_components(mtcars[, 1:7], n = 2, rotation = "varimax") # PCA extracted two components diff --git a/man/model_parameters.BFBayesFactor.Rd b/man/model_parameters.BFBayesFactor.Rd index edede2591..b8c497249 100644 --- a/man/model_parameters.BFBayesFactor.Rd +++ b/man/model_parameters.BFBayesFactor.Rd @@ -92,7 +92,7 @@ the \emph{g} parameters; See the \emph{Bayes Factors for ANOVAs} paper } } \examples{ -\dontshow{if (require("BayesFactor")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("BayesFactor")) withAutoprint(\{ # examplesIf} \donttest{ # Bayesian t-test model <- BayesFactor::ttestBF(x = rnorm(100, 1, 1)) diff --git a/man/model_parameters.aov.Rd b/man/model_parameters.aov.Rd index a3e4b733d..941a2688e 100644 --- a/man/model_parameters.aov.Rd +++ b/man/model_parameters.aov.Rd @@ -154,7 +154,7 @@ covariates are mean-centred and factors are coded with orthogonal contrasts \code{contr.helmert}, but \emph{not} by the default \code{contr.treatment}). } \examples{ -\dontshow{if (requireNamespace("effectsize", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (requireNamespace("effectsize", quietly = TRUE)) withAutoprint(\{ # examplesIf} df <- iris df$Sepal.Big <- ifelse(df$Sepal.Width >= 3, "Yes", "No") @@ -174,7 +174,7 @@ model_parameters( model <- aov(Sepal.Length ~ Sepal.Big + Error(Species), data = df) model_parameters(model) \dontshow{\}) # examplesIf} -\dontshow{if (requireNamespace("lme4", quietly = TRUE) && requireNamespace("effectsize", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (requireNamespace("lme4", quietly = TRUE) && requireNamespace("effectsize", quietly = TRUE)) withAutoprint(\{ # examplesIf} \donttest{ df <- iris df$Sepal.Big <- ifelse(df$Sepal.Width >= 3, "Yes", "No") diff --git a/man/model_parameters.brmsfit.Rd b/man/model_parameters.brmsfit.Rd index 7eb30cae5..e547b3611 100644 --- a/man/model_parameters.brmsfit.Rd +++ b/man/model_parameters.brmsfit.Rd @@ -442,7 +442,7 @@ here. } \examples{ -\dontshow{if (require("rstanarm")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("rstanarm")) withAutoprint(\{ # examplesIf} \donttest{ library(parameters) model <- suppressWarnings(stan_glm( diff --git a/man/model_parameters.compare.loo.Rd b/man/model_parameters.compare.loo.Rd index 617f36221..d0da49d19 100644 --- a/man/model_parameters.compare.loo.Rd +++ b/man/model_parameters.compare.loo.Rd @@ -33,7 +33,7 @@ conclude that a model is much better than another if both models make very similar predictions. } \examples{ -\dontshow{if (all(insight::check_if_installed(c("brms", "RcppEigen", "BH"), quietly = TRUE))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (all(insight::check_if_installed(c("brms", "RcppEigen", "BH"), quietly = TRUE))) withAutoprint(\{ # examplesIf} \donttest{ library(brms) diff --git a/man/model_parameters.default.Rd b/man/model_parameters.default.Rd index 1a5734677..0406cc446 100644 --- a/man/model_parameters.default.Rd +++ b/man/model_parameters.default.Rd @@ -337,7 +337,7 @@ which is converted into a p-value using \code{\link[bayestestR:pd_to_p]{bayestes } \examples{ -\dontshow{if (require("boot", quietly = TRUE) && require("sandwich") && require("clubSandwich") && require("brglm2")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("boot", quietly = TRUE) && require("sandwich") && require("clubSandwich") && require("brglm2")) withAutoprint(\{ # examplesIf} library(parameters) model <- lm(mpg ~ wt + cyl, data = mtcars) diff --git a/man/model_parameters.glmmTMB.Rd b/man/model_parameters.glmmTMB.Rd index 4fc5d9988..419eb0cc0 100644 --- a/man/model_parameters.glmmTMB.Rd +++ b/man/model_parameters.glmmTMB.Rd @@ -513,7 +513,7 @@ which is converted into a p-value using \code{\link[bayestestR:pd_to_p]{bayestes } \examples{ -\dontshow{if (require("lme4") && require("glmmTMB")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("lme4") && require("glmmTMB")) withAutoprint(\{ # examplesIf} library(parameters) data(mtcars) model <- lme4::lmer(mpg ~ wt + (1 | gear), data = mtcars) diff --git a/man/model_parameters.hclust.Rd b/man/model_parameters.hclust.Rd index 2593c9786..2eaaae075 100644 --- a/man/model_parameters.hclust.Rd +++ b/man/model_parameters.hclust.Rd @@ -20,7 +20,7 @@ rows in data).} Format cluster models obtained for example by \code{\link[=kmeans]{kmeans()}}. } \examples{ -\dontshow{if (require("factoextra", quietly = TRUE) && require("dbscan", quietly = TRUE) && require("cluster", quietly = TRUE) && require("fpc", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("factoextra", quietly = TRUE) && require("dbscan", quietly = TRUE) && require("cluster", quietly = TRUE) && require("fpc", quietly = TRUE)) withAutoprint(\{ # examplesIf} \donttest{ # # K-means ------------------------------- diff --git a/man/model_parameters.mira.Rd b/man/model_parameters.mira.Rd index c2c4de9a5..29f894915 100644 --- a/man/model_parameters.mira.Rd +++ b/man/model_parameters.mira.Rd @@ -78,7 +78,7 @@ similar to \code{summary(mice::pool())}, i.e. it generates the pooled summary of multiple imputed repeated regression analyses. } \examples{ -\dontshow{if (require("mice", quietly = TRUE) && require("gee", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("mice", quietly = TRUE) && require("gee", quietly = TRUE)) withAutoprint(\{ # examplesIf} library(parameters) data(nhanes2, package = "mice") imp <- mice::mice(nhanes2) diff --git a/man/model_parameters.mlm.Rd b/man/model_parameters.mlm.Rd index c5197ebb8..6188f995e 100644 --- a/man/model_parameters.mlm.Rd +++ b/man/model_parameters.mlm.Rd @@ -208,7 +208,7 @@ here. } \examples{ -\dontshow{if (require("brglm2", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("brglm2", quietly = TRUE)) withAutoprint(\{ # examplesIf} data("stemcell", package = "brglm2") model <- brglm2::bracl( research ~ as.numeric(religion) + gender, diff --git a/man/model_parameters.principal.Rd b/man/model_parameters.principal.Rd index e99be2b56..3bdfb0f64 100644 --- a/man/model_parameters.principal.Rd +++ b/man/model_parameters.principal.Rd @@ -114,7 +114,7 @@ for \code{lavaan} models implemented in the \href{https://easystats.github.io/see/}{\strong{see}-package}. } \examples{ -\dontshow{if (all(insight::check_if_installed(c("psych", "lavaan"), quietly = TRUE))) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (all(insight::check_if_installed(c("psych", "lavaan"), quietly = TRUE))) withAutoprint(\{ # examplesIf} library(parameters) \donttest{ # Principal Component Analysis (PCA) --------- diff --git a/man/model_parameters.zcpglm.Rd b/man/model_parameters.zcpglm.Rd index 06477a19e..6e6391db4 100644 --- a/man/model_parameters.zcpglm.Rd +++ b/man/model_parameters.zcpglm.Rd @@ -183,7 +183,7 @@ here. } \examples{ -\dontshow{if (require("pscl")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("pscl")) withAutoprint(\{ # examplesIf} data("bioChemists", package = "pscl") model <- pscl::zeroinfl( art ~ fem + mar + kid5 + ment | kid5 + phd, diff --git a/man/n_clusters.Rd b/man/n_clusters.Rd index 8a55f3a01..bdf079a54 100644 --- a/man/n_clusters.Rd +++ b/man/n_clusters.Rd @@ -167,7 +167,7 @@ if (require("mclust", quietly = TRUE) && require("NbClust", quietly = TRUE) && # n_clusters(iris[1:4], standardize = FALSE, package = "all", fast = FALSE) } } -\dontshow{if (require("see", quietly = TRUE) && require("factoextra", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("see", quietly = TRUE) && require("factoextra", quietly = TRUE)) withAutoprint(\{ # examplesIf} \donttest{ x <- n_clusters_elbow(iris[1:4]) x diff --git a/man/n_factors.Rd b/man/n_factors.Rd index 09a88fcf1..740fded6b 100644 --- a/man/n_factors.Rd +++ b/man/n_factors.Rd @@ -89,7 +89,7 @@ implemented in the \href{https://easystats.github.io/see/}{\strong{see}-package} \code{n_components()} is a convenient short-cut for \code{n_factors(type = "PCA")}. } \examples{ -\dontshow{if (require("PCDimension", quietly = TRUE) && require("nFactors", quietly = TRUE) && require("EGAnet", quietly = TRUE) && require("psych", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("PCDimension", quietly = TRUE) && require("nFactors", quietly = TRUE) && require("EGAnet", quietly = TRUE) && require("psych", quietly = TRUE)) withAutoprint(\{ # examplesIf} library(parameters) n_factors(mtcars, type = "PCA") diff --git a/man/p_direction.lm.Rd b/man/p_direction.lm.Rd index b5f8ef670..1f683a89c 100644 --- a/man/p_direction.lm.Rd +++ b/man/p_direction.lm.Rd @@ -194,7 +194,7 @@ documentation in \code{\link[=p_function]{p_function()}}). } \examples{ -\dontshow{if (requireNamespace("bayestestR") && require("see", quietly = TRUE) && requireNamespace("sandwich")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (requireNamespace("bayestestR") && require("see", quietly = TRUE) && requireNamespace("sandwich")) withAutoprint(\{ # examplesIf} data(qol_cancer) model <- lm(QoL ~ time + age + education, data = qol_cancer) p_direction(model) diff --git a/man/p_function.Rd b/man/p_function.Rd index 9013f444c..02da48f14 100644 --- a/man/p_function.Rd +++ b/man/p_function.Rd @@ -432,7 +432,7 @@ For certain models (like mixed models), profiled intervals may be more accurate, however, this is currently not supported. } \examples{ -\dontshow{if (requireNamespace("see")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (requireNamespace("see")) withAutoprint(\{ # examplesIf} model <- lm(Sepal.Length ~ Species, data = iris) p_function(model) diff --git a/man/p_significance.lm.Rd b/man/p_significance.lm.Rd index 2e8c0e3da..8a5ed9871 100644 --- a/man/p_significance.lm.Rd +++ b/man/p_significance.lm.Rd @@ -197,7 +197,7 @@ documentation in \code{\link[=p_function]{p_function()}}). } \examples{ -\dontshow{if (requireNamespace("bayestestR") && packageVersion("bayestestR") > "0.14.0" && requireNamespace("sandwich")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (requireNamespace("bayestestR") && packageVersion("bayestestR") > "0.14.0" && requireNamespace("sandwich")) withAutoprint(\{ # examplesIf} data(qol_cancer) model <- lm(QoL ~ time + age + education, data = qol_cancer) diff --git a/man/p_value.Rd b/man/p_value.Rd index 350b3a5cc..cb2cedf03 100644 --- a/man/p_value.Rd +++ b/man/p_value.Rd @@ -308,7 +308,7 @@ here. } \examples{ -\dontshow{if (require("pscl", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("pscl", quietly = TRUE)) withAutoprint(\{ # examplesIf} data(iris) model <- lm(Petal.Length ~ Sepal.Length + Species, data = iris) p_value(model) diff --git a/man/pool_parameters.Rd b/man/pool_parameters.Rd index 045e4984b..9f9a290ee 100644 --- a/man/pool_parameters.Rd +++ b/man/pool_parameters.Rd @@ -89,7 +89,7 @@ Some model objects do not return standard errors (e.g. objects of class are returned. } \examples{ -\dontshow{if (require("mice") && require("datawizard")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("mice") && require("datawizard")) withAutoprint(\{ # examplesIf} # example for multiple imputed datasets data("nhanes2", package = "mice") imp <- mice::mice(nhanes2, printFlag = FALSE) diff --git a/man/principal_components.Rd b/man/principal_components.Rd index 82cdb2402..d5cdb1c12 100644 --- a/man/principal_components.Rd +++ b/man/principal_components.Rd @@ -269,7 +269,7 @@ data along the new feature axes. } } \examples{ -\dontshow{if (require("nFactors", quietly = TRUE) && require("sparsepca", quietly = TRUE) && require("psych", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("nFactors", quietly = TRUE) && require("sparsepca", quietly = TRUE) && require("psych", quietly = TRUE)) withAutoprint(\{ # examplesIf} library(parameters) \donttest{ diff --git a/man/print.compare_parameters.Rd b/man/print.compare_parameters.Rd index 916b5962d..9afa7f6dd 100644 --- a/man/print.compare_parameters.Rd +++ b/man/print.compare_parameters.Rd @@ -255,7 +255,7 @@ print unicode-chars for symbols as column names, wherever possible (e.g., } \examples{ -\dontshow{if (require("gt", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("gt", quietly = TRUE)) withAutoprint(\{ # examplesIf} \donttest{ data(iris) lm1 <- lm(Sepal.Length ~ Species, data = iris) diff --git a/man/print.parameters_model.Rd b/man/print.parameters_model.Rd index 03c5f9e5e..0b61bc4f4 100644 --- a/man/print.parameters_model.Rd +++ b/man/print.parameters_model.Rd @@ -336,7 +336,7 @@ freedom. } \examples{ -\dontshow{if (require("gt", quietly = TRUE) && require("glmmTMB", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("gt", quietly = TRUE) && require("glmmTMB", quietly = TRUE)) withAutoprint(\{ # examplesIf} \donttest{ library(parameters) model <- glmmTMB::glmmTMB( diff --git a/man/select_parameters.Rd b/man/select_parameters.Rd index 12a880eac..aa3bdfc9b 100644 --- a/man/select_parameters.Rd +++ b/man/select_parameters.Rd @@ -56,7 +56,7 @@ excludes random-effects until the cAIC can't be improved further. } \examples{ -\dontshow{if (requireNamespace("lme4")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (requireNamespace("lme4")) withAutoprint(\{ # examplesIf} model <- lm(mpg ~ ., data = mtcars) select_parameters(model) diff --git a/man/standard_error.Rd b/man/standard_error.Rd index 4f0dfb306..5618fd3a1 100644 --- a/man/standard_error.Rd +++ b/man/standard_error.Rd @@ -86,7 +86,7 @@ For Bayesian models (from \strong{rstanarm} or \strong{brms}), the standard error is the SD of the posterior samples. } \examples{ -\dontshow{if (require("sandwich") && require("clubSandwich")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("sandwich") && require("clubSandwich")) withAutoprint(\{ # examplesIf} model <- lm(Petal.Length ~ Sepal.Length * Species, data = iris) standard_error(model) diff --git a/man/standardize_info.Rd b/man/standardize_info.Rd index 6c6e0018a..0b0c69b85 100644 --- a/man/standardize_info.Rd +++ b/man/standardize_info.Rd @@ -51,7 +51,7 @@ parameters. This function gives a window on how standardized are obtained, i.e., by what they are divided. The "basic" method of standardization uses. } \examples{ -\dontshow{if (insight::check_if_installed("datawizard", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (insight::check_if_installed("datawizard", quietly = TRUE)) withAutoprint(\{ # examplesIf} model <- lm(mpg ~ ., data = mtcars) standardize_info(model) standardize_info(model, robust = TRUE) diff --git a/man/standardize_parameters.Rd b/man/standardize_parameters.Rd index 82cd6c2c5..045aa4f8b 100644 --- a/man/standardize_parameters.Rd +++ b/man/standardize_parameters.Rd @@ -198,13 +198,13 @@ standardize_parameters(model, method = "posthoc") standardize_parameters(model, method = "basic", exponentiate = TRUE) } -\dontshow{if (require("lme4", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("lme4", quietly = TRUE)) withAutoprint(\{ # examplesIf} \donttest{ m <- lme4::lmer(mpg ~ cyl + am + vs + (1 | cyl), mtcars) standardize_parameters(m, method = "pseudo", ci_method = "satterthwaite") } \dontshow{\}) # examplesIf} -\dontshow{if (require("rstanarm", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("rstanarm", quietly = TRUE)) withAutoprint(\{ # examplesIf} \donttest{ model <- rstanarm::stan_glm(rating ~ critical + privileges, data = attitude, refresh = 0) standardize_posteriors(model, method = "refit", verbose = FALSE)