diff --git a/DESCRIPTION b/DESCRIPTION index 31e2ea52f..eb0dff8d7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -141,7 +141,7 @@ Suggests: WRS2 Encoding: UTF-8 Language: en-US -RoxygenNote: 7.1.1 +RoxygenNote: 7.1.1.9001 VignetteBuilder: knitr Config/testthat/edition: 3 Remotes: easystats/insight diff --git a/R/1_model_parameters.R b/R/1_model_parameters.R index 1a35bcf54..115ef323e 100644 --- a/R/1_model_parameters.R +++ b/R/1_model_parameters.R @@ -213,7 +213,12 @@ model_parameters.default <- function(model, # Processing if (bootstrap) { - params <- bootstrap_parameters(model, iterations = iterations, ci = ci, ...) + params <- bootstrap_parameters( + model, + iterations = iterations, + ci = ci, + ... + ) } else { params <- .extract_parameters_generic( model, diff --git a/R/5_simulate_model.R b/R/5_simulate_model.R index 4852b7683..bbabd40d7 100644 --- a/R/5_simulate_model.R +++ b/R/5_simulate_model.R @@ -36,7 +36,7 @@ #' model <- lm(Sepal.Length ~ Species * Petal.Width + Petal.Length, data = iris) #' head(simulate_model(model)) #' \donttest{ -#' if (require("glmmTMB")) { +#' if (require("glmmTMB", quietly = TRUE)) { #' model <- glmmTMB( #' count ~ spp + mined + (1 | site), #' ziformula = ~mined, diff --git a/R/bootstrap_model.R b/R/bootstrap_model.R index c3a8131c1..b3315e4c0 100644 --- a/R/bootstrap_model.R +++ b/R/bootstrap_model.R @@ -26,7 +26,7 @@ #' #' @examples #' \dontrun{ -#' if (require("boot")) { +#' if (require("boot", quietly = TRUE)) { #' model <- lm(mpg ~ wt + factor(cyl), data = mtcars) #' b <- bootstrap_model(model) #' print(head(b)) @@ -38,7 +38,10 @@ #' } #' } #' @export -bootstrap_model <- function(model, iterations = 1000, verbose = FALSE, ...) { +bootstrap_model <- function(model, + iterations = 1000, + verbose = FALSE, + ...) { UseMethod("bootstrap_model") } @@ -50,7 +53,10 @@ bootstrap_model <- function(model, iterations = 1000, verbose = FALSE, ...) { #' @importFrom stats coef update setNames complete.cases #' @importFrom insight get_data find_parameters get_parameters #' @export -bootstrap_model.default <- function(model, iterations = 1000, verbose = FALSE, ...) { +bootstrap_model.default <- function(model, + iterations = 1000, + verbose = FALSE, + ...) { if (!requireNamespace("boot", quietly = TRUE)) { stop("Package 'boot' needed for this function to work. Please install it.") } @@ -82,7 +88,12 @@ bootstrap_model.default <- function(model, iterations = 1000, verbose = FALSE, . return(params) } - results <- boot::boot(data = data, statistic = boot_function, R = iterations, model = model) + results <- boot::boot( + data = data, + statistic = boot_function, + R = iterations, + model = model + ) out <- as.data.frame(results$t) out <- out[stats::complete.cases(out), ] @@ -115,9 +126,18 @@ bootstrap_model.merMod <- function(model, iterations = 1000, verbose = FALSE, .. } if (verbose) { - results <- suppressMessages(lme4::bootMer(model, boot_function, nsim = iterations, verbose = FALSE)) + results <- suppressMessages(lme4::bootMer( + model, + boot_function, + nsim = iterations, + verbose = FALSE + )) } else { - results <- lme4::bootMer(model, boot_function, nsim = iterations) + results <- lme4::bootMer( + model, + boot_function, + nsim = iterations + ) } out <- as.data.frame(results$t) diff --git a/R/bootstrap_parameters.R b/R/bootstrap_parameters.R index bad935671..a2d128a95 100644 --- a/R/bootstrap_parameters.R +++ b/R/bootstrap_parameters.R @@ -28,7 +28,7 @@ #' #' @examples #' \dontrun{ -#' if (require("boot")) { +#' if (require("boot", quietly = TRUE)) { #' set.seed(2) #' model <- lm(Sepal.Length ~ Species * Petal.Width, data = iris) #' b <- bootstrap_parameters(model) diff --git a/R/demean.R b/R/demean.R index 5e5c92fe1..81bac374a 100644 --- a/R/demean.R +++ b/R/demean.R @@ -235,10 +235,13 @@ degroup <- function(x, select, group, center = "mean", suffix_demean = "_within" not_found <- setdiff(select, colnames(x)) if (length(not_found) && isTRUE(verbose)) { - insight::print_color(sprintf("%i variables were not found in the dataset: %s\n", - length(not_found), - paste0(not_found, collapse = ", ")), - color = "red") + insight::print_color(sprintf( + "%i variables were not found in the dataset: %s\n", + length(not_found), + paste0(not_found, collapse = ", ") + ), + color = "red" + ) } select <- intersect(colnames(x), select) diff --git a/R/describe_distribution.R b/R/describe_distribution.R index af02cb18e..0dadb535c 100644 --- a/R/describe_distribution.R +++ b/R/describe_distribution.R @@ -81,7 +81,12 @@ describe_distribution.numeric <- function(x, if (!requireNamespace("boot", quietly = TRUE)) { warning("Package 'boot' needed for bootstrapping confidence intervals.", call. = FALSE) } else { - results <- boot::boot(data = x, statistic = .boot_distribution, R = iterations, centrality = centrality) + results <- boot::boot( + data = x, + statistic = .boot_distribution, + R = iterations, + centrality = centrality + ) out_ci <- bayestestR::ci(results$t, ci = ci, verbose = FALSE) out <- cbind(out, data.frame(CI_low = out_ci$CI_low[1], CI_high = out_ci$CI_high[1])) } diff --git a/R/dof.R b/R/dof.R index a2749aecb..9473b229d 100644 --- a/R/dof.R +++ b/R/dof.R @@ -36,12 +36,12 @@ #' model <- glm(vs ~ mpg * cyl, data = mtcars, family = "binomial") #' dof(model) #' \dontrun{ -#' if (require("lme4")) { +#' if (require("lme4", quietly = TRUE)) { #' model <- lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) #' dof(model) #' } #' -#' if (require("rstanarm")) { +#' if (require("rstanarm", quietly = TRUE)) { #' model <- stan_glm( #' Sepal.Length ~ Petal.Length * Species, #' data = iris, diff --git a/R/equivalence_test.R b/R/equivalence_test.R index 7381ad936..99d442b82 100644 --- a/R/equivalence_test.R +++ b/R/equivalence_test.R @@ -130,7 +130,7 @@ bayestestR::equivalence_test #' equivalence_test(model, rule = "cet") #' #' # plot method -#' if (require("see")) { +#' if (require("see", quietly = TRUE)) { #' result <- equivalence_test(model) #' plot(result) #' } diff --git a/R/format.R b/R/format.R index ab41d9c5d..3566ff900 100644 --- a/R/format.R +++ b/R/format.R @@ -15,7 +15,7 @@ format.parameters_model <- function(x, zap_small = FALSE, format = NULL, ...) { - # save attributes + # save attributes coef_name <- attributes(x)$coefficient_name s_value <- attributes(x)$s_value m_class <- attributes(x)$model_class diff --git a/R/methods_DirichletReg.R b/R/methods_DirichletReg.R index 30def2f09..dfb6550bf 100644 --- a/R/methods_DirichletReg.R +++ b/R/methods_DirichletReg.R @@ -40,7 +40,10 @@ model_parameters.DirichletRegModel <- function(model, #' @rdname ci.merMod #' @export -ci.DirichletRegModel <- function(x, ci = .95, component = c("all", "conditional", "precision"), ...) { +ci.DirichletRegModel <- function(x, + ci = .95, + component = c("all", "conditional", "precision"), + ...) { component <- match.arg(component) params <- insight::get_parameters(x, component = component) out <- ci_wald(model = x, ci = ci, dof = Inf, ...) @@ -61,7 +64,9 @@ ci.DirichletRegModel <- function(x, ci = .95, component = c("all", "conditional" #' @rdname standard_error #' @export -standard_error.DirichletRegModel <- function(model, component = c("all", "conditional", "precision"), ...) { +standard_error.DirichletRegModel <- function(model, + component = c("all", "conditional", "precision"), + ...) { component <- match.arg(component) params <- insight::get_parameters(model) @@ -102,7 +107,9 @@ standard_error.DirichletRegModel <- function(model, component = c("all", "condit #' @importFrom stats pnorm #' @importFrom insight get_parameters #' @export -p_value.DirichletRegModel <- function(model, component = c("all", "conditional", "precision"), ...) { +p_value.DirichletRegModel <- function(model, + component = c("all", "conditional", "precision"), + ...) { component <- match.arg(component) params <- insight::get_parameters(model) diff --git a/R/methods_averaging.R b/R/methods_averaging.R index 96f7e79dd..0394a6341 100644 --- a/R/methods_averaging.R +++ b/R/methods_averaging.R @@ -15,7 +15,7 @@ #' #' @examples #' library(parameters) -#' if (require("brglm2")) { +#' if (require("brglm2", quietly = TRUE)) { #' data("stemcell") #' model <- bracl( #' research ~ as.numeric(religion) + gender, diff --git a/R/methods_betareg.R b/R/methods_betareg.R index 14ec87559..4399fcfd6 100644 --- a/R/methods_betareg.R +++ b/R/methods_betareg.R @@ -39,7 +39,10 @@ model_parameters.betareg <- function(model, #' @rdname ci.merMod #' @export -ci.betareg <- function(x, ci = .95, component = c("all", "conditional", "precision"), ...) { +ci.betareg <- function(x, + ci = .95, + component = c("all", "conditional", "precision"), + ...) { component <- match.arg(component) ci_wald(model = x, ci = ci, dof = Inf, component = component) } @@ -47,7 +50,9 @@ ci.betareg <- function(x, ci = .95, component = c("all", "conditional", "precisi #' @rdname standard_error #' @export -standard_error.betareg <- function(model, component = c("all", "conditional", "precision"), ...) { +standard_error.betareg <- function(model, + component = c("all", "conditional", "precision"), + ...) { component <- match.arg(component) params <- insight::get_parameters(model) @@ -70,7 +75,9 @@ standard_error.betareg <- function(model, component = c("all", "conditional", "p #' @rdname p_value.DirichletRegModel #' @export -p_value.betareg <- function(model, component = c("all", "conditional", "precision"), ...) { +p_value.betareg <- function(model, + component = c("all", "conditional", "precision"), + ...) { component <- match.arg(component) params <- insight::get_parameters(model) @@ -92,7 +99,10 @@ p_value.betareg <- function(model, component = c("all", "conditional", "precisio #' @export -simulate_model.betareg <- function(model, iterations = 1000, component = c("all", "conditional", "precision"), ...) { +simulate_model.betareg <- function(model, + iterations = 1000, + component = c("all", "conditional", "precision"), + ...) { component <- match.arg(component) out <- .simulate_model(model, iterations, component = component) diff --git a/R/methods_cplm.R b/R/methods_cplm.R index f1fbafca8..18131ad25 100644 --- a/R/methods_cplm.R +++ b/R/methods_cplm.R @@ -120,10 +120,12 @@ standard_error.zcpglm <- function(model, component = c("all", "conditional", "zi #' @inheritParams standard_error #' @inheritParams ci.merMod #' -#' @return A data frame with at least two columns: the parameter names and the p-values. Depending on the model, may also include columns for model components etc. +#' @return A data frame with at least two columns: the parameter names and the +#' p-values. Depending on the model, may also include columns for model +#' components etc. #' #' @examples -#' if (require("pscl")) { +#' if (require("pscl", quietly = TRUE)) { #' data("bioChemists") #' model <- zeroinfl(art ~ fem + mar + kid5 | kid5 + phd, data = bioChemists) #' p_value(model) diff --git a/R/methods_epi2x2.R b/R/methods_epi2x2.R index 251a9a474..c78a865b5 100644 --- a/R/methods_epi2x2.R +++ b/R/methods_epi2x2.R @@ -38,4 +38,4 @@ model_parameters.epi.2by2 <- function(model, verbose = TRUE, ...) { attr(params, "pretty_names") <- stats::setNames(pretty_names, params$Parameter) class(params) <- c("parameters_model", "see_parameters_model", class(params)) params -} \ No newline at end of file +} diff --git a/R/methods_gam.R b/R/methods_gam.R index 8ced0159a..23938f1fc 100644 --- a/R/methods_gam.R +++ b/R/methods_gam.R @@ -19,7 +19,12 @@ model_parameters.gam <- function(model, # Processing if (bootstrap) { - parameters <- bootstrap_parameters(model, iterations = iterations, ci = ci, ...) + parameters <- bootstrap_parameters( + model, + iterations = iterations, + ci = ci, + ... + ) } else { parameters <- .extract_parameters_generic( diff --git a/R/methods_glmmTMB.R b/R/methods_glmmTMB.R index b08268efd..620dd81ed 100644 --- a/R/methods_glmmTMB.R +++ b/R/methods_glmmTMB.R @@ -45,7 +45,12 @@ model_parameters.glmmTMB <- function(model, if (effects %in% c("fixed", "all")) { # Processing if (bootstrap) { - params <- bootstrap_parameters(model, iterations = iterations, ci = ci, ...) + params <- bootstrap_parameters( + model, + iterations = iterations, + ci = ci, + ... + ) } else { params <- .extract_parameters_generic( model, diff --git a/R/methods_lavaan.R b/R/methods_lavaan.R index bf1a23243..9d04c98cb 100644 --- a/R/methods_lavaan.R +++ b/R/methods_lavaan.R @@ -67,7 +67,7 @@ p_value.blavaan <- function(model, ...) { #' library(parameters) #' #' # lavaan ------------------------------------- -#' if (require("lavaan")) { +#' if (require("lavaan", quietly = TRUE)) { #' #' # Confirmatory Factor Analysis (CFA) --------- #' @@ -102,8 +102,12 @@ p_value.blavaan <- function(model, ...) { #' @return A data frame of indices related to the model's parameters. #' #' @references \itemize{ -#' \item Rosseel Y (2012). lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48(2), 1-36. -#' \item Merkle EC , Rosseel Y (2018). blavaan: Bayesian Structural Equation Models via Parameter Expansion. Journal of Statistical Software, 85(4), 1-30. http://www.jstatsoft.org/v85/i04/ +#' \item Rosseel Y (2012). lavaan: An R Package for Structural Equation +#' Modeling. Journal of Statistical Software, 48(2), 1-36. +#' +#' \item Merkle EC , Rosseel Y (2018). blavaan: Bayesian Structural Equation +#' Models via Parameter Expansion. Journal of Statistical Software, 85(4), +#' 1-30. http://www.jstatsoft.org/v85/i04/ #' } #' @export model_parameters.lavaan <- function(model, @@ -112,7 +116,12 @@ model_parameters.lavaan <- function(model, type = c("regression", "correlation", "loading", "defined"), verbose = TRUE, ...) { - params <- .extract_parameters_lavaan(model, ci = ci, standardize = standardize, verbose = verbose, ...) + params <- .extract_parameters_lavaan(model, + ci = ci, + standardize = standardize, + verbose = verbose, + ... + ) # Filter if (all(type == "all")) { diff --git a/R/methods_lme4.R b/R/methods_lme4.R index f5be287db..ac92e9d53 100644 --- a/R/methods_lme4.R +++ b/R/methods_lme4.R @@ -58,15 +58,34 @@ p_value.lmerMod <- function(model, method = "wald", ...) { #' @description Parameters from (linear) mixed models. #' #' @param model A mixed model. -#' @param effects Should parameters for fixed effects (\code{"fixed"}), random effects (\code{"random"}), or both (\code{"all"}) be returned? Only applies to mixed models. May be abbreviated. -#' @param details Logical, if \code{TRUE}, a summary of the random effects is included. See \code{\link{random_parameters}} for details. -#' @param df_method Method for computing degrees of freedom for p values, standard errors and confidence intervals (CI). May be \code{"wald"} (default, see \code{\link{degrees_of_freedom}}), \code{"ml1"} (see \code{\link{dof_ml1}}), \code{"betwithin"} (see \code{\link{dof_betwithin}}), \code{"satterthwaite"} (see \code{\link{dof_satterthwaite}}) or \code{"kenward"} (see \code{\link{dof_kenward}}). The options \code{df_method = "boot"}, \code{df_method = "profile"} and \code{df_method = "uniroot"} only affect confidence intervals; in this case, bootstrapped resp. profiled confidence intervals are computed. \code{"uniroot"} only applies to models of class \code{glmmTMB}. Note that when \code{df_method} is not \code{"wald"}, robust standard errors etc. cannot be computed. -#' @param wb_component Logical, if \code{TRUE} and models contains within- and between-effects (see \code{\link{demean}}), the \code{Component} column will indicate which variables belong to the within-effects, between-effects, and cross-level interactions. By default, the \code{Component} column indicates, which parameters belong to the conditional or zero-inflated component of the model. +#' @param effects Should parameters for fixed effects (\code{"fixed"}), random +#' effects (\code{"random"}), or both (\code{"all"}) be returned? Only applies +#' to mixed models. May be abbreviated. +#' @param details Logical, if \code{TRUE}, a summary of the random effects is +#' included. See \code{\link{random_parameters}} for details. +#' @param df_method Method for computing degrees of freedom for p values, +#' standard errors and confidence intervals (CI). May be \code{"wald"} +#' (default, see \code{\link{degrees_of_freedom}}), \code{"ml1"} (see +#' \code{\link{dof_ml1}}), \code{"betwithin"} (see +#' \code{\link{dof_betwithin}}), \code{"satterthwaite"} (see +#' \code{\link{dof_satterthwaite}}) or \code{"kenward"} (see +#' \code{\link{dof_kenward}}). The options \code{df_method = "boot"}, +#' \code{df_method = "profile"} and \code{df_method = "uniroot"} only affect +#' confidence intervals; in this case, bootstrapped resp. profiled confidence +#' intervals are computed. \code{"uniroot"} only applies to models of class +#' \code{glmmTMB}. Note that when \code{df_method} is not \code{"wald"}, +#' robust standard errors etc. cannot be computed. +#' @param wb_component Logical, if \code{TRUE} and models contains within- and +#' between-effects (see \code{\link{demean}}), the \code{Component} column +#' will indicate which variables belong to the within-effects, +#' between-effects, and cross-level interactions. By default, the +#' \code{Component} column indicates, which parameters belong to the +#' conditional or zero-inflated component of the model. #' @inheritParams model_parameters.default #' @inheritParams model_parameters.stanreg #' -#' @seealso \code{\link[insight:standardize_names]{standardize_names()}} to rename -#' columns into a consistent, standardized naming scheme. +#' @seealso \code{\link[insight:standardize_names]{standardize_names()}} to +#' rename columns into a consistent, standardized naming scheme. #' #' @note There is also a \href{https://easystats.github.io/see/articles/parameters.html}{\code{plot()}-method} implemented in the \href{https://easystats.github.io/see/}{\pkg{see}-package}. #' @@ -123,7 +142,12 @@ model_parameters.merMod <- function(model, if (effects %in% c("fixed", "all")) { # Processing if (bootstrap) { - params <- bootstrap_parameters(model, iterations = iterations, ci = ci, ...) + params <- bootstrap_parameters( + model, + iterations = iterations, + ci = ci, + ... + ) } else { params <- .extract_parameters_mixed( model, @@ -137,6 +161,7 @@ model_parameters.merMod <- function(model, ... ) } + params$Effects <- "fixed" if (isTRUE(exponentiate) || identical(exponentiate, "nongaussian")) { @@ -205,8 +230,19 @@ model_parameters.merMod <- function(model, #' #' @param x A statistical model. #' @param ci Confidence Interval (CI) level. Default to 0.95 (95\%). -#' @param method For mixed models, can be \code{\link[=p_value_wald]{"wald"}} (default), \code{\link[=p_value_ml1]{"ml1"}} or \code{\link[=p_value_betwithin]{"betwithin"}}. For linear mixed model, can also be \code{\link[=p_value_satterthwaite]{"satterthwaite"}}, \code{\link[=p_value_kenward]{"kenward"}} or \code{"boot"} (see \code{lme4::confint.merMod}). For (generalized) linear models, can be \code{"robust"} to compute confidence intervals based on robust covariance matrix estimation, and for generalized linear models and models from packages \pkg{lme4} or \pkg{glmmTMB}, may also be \code{"profile"}, \code{"uniroot"} or \code{"wald"} (default). -#' @param ... Arguments passed down to \code{standard_error_robust()} when confidence intervals or p-values based on robust standard errors should be computed. +#' @param method For mixed models, can be \code{\link[=p_value_wald]{"wald"}} +#' (default), \code{\link[=p_value_ml1]{"ml1"}} or +#' \code{\link[=p_value_betwithin]{"betwithin"}}. For linear mixed model, can +#' also be \code{\link[=p_value_satterthwaite]{"satterthwaite"}}, +#' \code{\link[=p_value_kenward]{"kenward"}} or \code{"boot"} (see +#' \code{lme4::confint.merMod}). For (generalized) linear models, can be +#' \code{"robust"} to compute confidence intervals based on robust covariance +#' matrix estimation, and for generalized linear models and models from +#' packages \pkg{lme4} or \pkg{glmmTMB}, may also be \code{"profile"}, +#' \code{"uniroot"} or \code{"wald"} (default). +#' @param ... Arguments passed down to \code{standard_error_robust()} when +#' confidence intervals or p-values based on robust standard errors should be +#' computed. #' @inheritParams simulate_model #' @inheritParams standard_error #' @inheritParams p_value @@ -282,7 +318,10 @@ ci.merMod <- function(x, #' @rdname standard_error #' @export -standard_error.merMod <- function(model, effects = c("fixed", "random"), method = NULL, ...) { +standard_error.merMod <- function(model, + effects = c("fixed", "random"), + method = NULL, + ...) { effects <- match.arg(effects) if (is.null(method)) method <- "wald" robust <- !is.null(method) && method == "robust" diff --git a/R/methods_lqmm.R b/R/methods_lqmm.R index 1a8db5cab..991cc50c6 100644 --- a/R/methods_lqmm.R +++ b/R/methods_lqmm.R @@ -9,9 +9,20 @@ model_parameters.lqmm <- function(model, # Processing if (bootstrap) { - parameters <- bootstrap_parameters(model, iterations = iterations, ci = ci, ...) + parameters <- bootstrap_parameters( + model, + iterations = iterations, + ci = ci, + ... + ) } else { - parameters <- .extract_parameters_lqmm(model, ci = ci, p_adjust = p_adjust, verbose = verbose, ...) + parameters <- .extract_parameters_lqmm( + model, + ci = ci, + p_adjust = p_adjust, + verbose = verbose, + ... + ) } parameters <- .add_model_parameters_attributes( diff --git a/R/methods_mclust.R b/R/methods_mclust.R index 153186678..31962cca3 100644 --- a/R/methods_mclust.R +++ b/R/methods_mclust.R @@ -8,7 +8,7 @@ #' #' @examples #' library(parameters) -#' if (require("mclust")) { +#' if (require("mclust", quietly = TRUE)) { #' model <- mclust::Mclust(iris[1:4], verbose = FALSE) #' model_parameters(model) #' } diff --git a/R/methods_metafor.R b/R/methods_metafor.R index 3bd9731bc..28c3fdb1c 100644 --- a/R/methods_metafor.R +++ b/R/methods_metafor.R @@ -18,13 +18,13 @@ #' effectsize = c(-0.393, 0.675, 0.282, -1.398), #' stderr = c(0.317, 0.317, 0.13, 0.36) #' ) -#' if (require("metafor")) { +#' if (require("metafor", quietly = TRUE)) { #' model <- rma(yi = effectsize, sei = stderr, method = "REML", data = mydat) #' model_parameters(model) #' } #' \dontrun{ #' # with subgroups -#' if (require("metafor")) { +#' if (require("metafor", quietly = TRUE)) { #' data(dat.bcg) #' dat <- escalc( #' measure = "RR", @@ -39,7 +39,7 @@ #' model_parameters(model) #' } #' -#' if (require("metaBMA")) { +#' if (require("metaBMA", quietly = TRUE)) { #' data(towels) #' m <- meta_random(logOR, SE, study, data = towels) #' model_parameters(m) diff --git a/R/methods_mfx.R b/R/methods_mfx.R index 2845f2283..ee70bed96 100644 --- a/R/methods_mfx.R +++ b/R/methods_mfx.R @@ -161,7 +161,11 @@ ci.negbinirr <- ci.logitor #' @rdname ci.merMod #' @export -ci.poissonmfx <- function(x, ci = .95, component = c("all", "conditional", "marginal"), method = NULL, ...) { +ci.poissonmfx <- function(x, + ci = .95, + component = c("all", "conditional", "marginal"), + method = NULL, + ...) { component <- match.arg(component) robust <- !is.null(method) && method == "robust" ci_wald(model = x, ci = ci, component = component, robust = robust, ...) @@ -181,7 +185,10 @@ ci.probitmfx <- ci.poissonmfx #' @export -ci.betaor <- function(x, ci = .95, component = c("all", "conditional", "precision"), ...) { +ci.betaor <- function(x, + ci = .95, + component = c("all", "conditional", "precision"), + ...) { component <- match.arg(component) ci_wald(model = x$fit, ci = ci, dof = Inf, component = component) } @@ -189,7 +196,11 @@ ci.betaor <- function(x, ci = .95, component = c("all", "conditional", "precisio #' @rdname ci.merMod #' @export -ci.betamfx <- function(x, ci = .95, component = c("all", "conditional", "precision", "marginal"), method = NULL, ...) { +ci.betamfx <- function(x, + ci = .95, + component = c("all", "conditional", "precision", "marginal"), + method = NULL, + ...) { component <- match.arg(component) robust <- !is.null(method) && method == "robust" ci_wald(model = x, ci = ci, component = component, robust = robust, ...) @@ -221,7 +232,9 @@ standard_error.negbinirr <- standard_error.logitor #' @rdname standard_error #' @export -standard_error.poissonmfx <- function(model, component = c("all", "conditional", "marginal"), ...) { +standard_error.poissonmfx <- function(model, + component = c("all", "conditional", "marginal"), + ...) { parms <- insight::get_parameters(model, component = "all") cs <- stats::coef(summary(model$fit)) se <- c(as.vector(model$mfxest[, 2]), as.vector(cs[, 2])) @@ -254,7 +267,9 @@ standard_error.negbinmfx <- standard_error.poissonmfx #' @export -standard_error.betaor <- function(model, component = c("all", "conditional", "precision"), ...) { +standard_error.betaor <- function(model, + component = c("all", "conditional", "precision"), + ...) { component <- match.arg(component) standard_error.betareg(model$fit, component = component, ...) } @@ -262,7 +277,9 @@ standard_error.betaor <- function(model, component = c("all", "conditional", "pr #' @rdname standard_error #' @export -standard_error.betamfx <- function(model, component = c("all", "conditional", "precision", "marginal"), ...) { +standard_error.betamfx <- function(model, + component = c("all", "conditional", "precision", "marginal"), + ...) { parms <- insight::get_parameters(model, component = "all") cs <- do.call(rbind, stats::coef(summary(model$fit))) se <- c(as.vector(model$mfxest[, 2]), as.vector(cs[, 2])) @@ -338,10 +355,12 @@ degrees_of_freedom.betamfx <- degrees_of_freedom.logitor #' @param component Should all parameters, parameters for the conditional model, precision-component or marginal effects be returned? \code{component} may be one of \code{"conditional"}, \code{"precision"}, \code{"marginal"} or \code{"all"} (default). #' @param ... Currently not used. #' -#' @return A data frame with at least two columns: the parameter names and the p-values. Depending on the model, may also include columns for model components etc. +#' @return A data frame with at least two columns: the parameter names and the +#' p-values. Depending on the model, may also include columns for model +#' components etc. #' #' @examples -#' if (require("mfx")) { +#' if (require("mfx", quietly = TRUE)) { #' set.seed(12345) #' n <- 1000 #' x <- rnorm(n) diff --git a/R/methods_mhurdle.R b/R/methods_mhurdle.R index 5ece2955c..48b3e276f 100644 --- a/R/methods_mhurdle.R +++ b/R/methods_mhurdle.R @@ -6,7 +6,6 @@ model_parameters.mhurdle <- function(model, p_adjust = NULL, verbose = TRUE, ...) { - component <- match.arg(component) params <- .model_parameters_generic( diff --git a/R/methods_mice.R b/R/methods_mice.R index 207c0cfbe..02d02359b 100644 --- a/R/methods_mice.R +++ b/R/methods_mice.R @@ -96,7 +96,7 @@ model_parameters.mipo <- model_parameters.default #' #' @examples #' library(parameters) -#' if (require("mice")) { +#' if (require("mice", quietly = TRUE)) { #' data(nhanes2) #' imp <- mice(nhanes2) #' fit <- with(data = imp, exp = lm(bmi ~ age + hyp + chl)) @@ -104,7 +104,7 @@ model_parameters.mipo <- model_parameters.default #' } #' \dontrun{ #' # model_parameters() also works for models that have no "tidy"-method in mice -#' if (require("mice") && require("gee")) { +#' if (require("mice", quietly = TRUE) && require("gee", quietly = TRUE)) { #' data(warpbreaks) #' set.seed(1234) #' warpbreaks$tension[sample(1:nrow(warpbreaks), size = 10)] <- NA diff --git a/R/methods_mjoint.R b/R/methods_mjoint.R index 12241d8d2..f3c5120a6 100644 --- a/R/methods_mjoint.R +++ b/R/methods_mjoint.R @@ -7,7 +7,6 @@ model_parameters.mjoint <- function(model, p_adjust = NULL, verbose = TRUE, ...) { - effects <- match.arg(effects, choices = c("fixed", "random", "all")) component <- match.arg(component) diff --git a/R/methods_mlm.R b/R/methods_mlm.R index 27ef65e9c..d2bc77244 100644 --- a/R/methods_mlm.R +++ b/R/methods_mlm.R @@ -22,7 +22,7 @@ #' #' @examples #' library(parameters) -#' if (require("brglm2")) { +#' if (require("brglm2", quietly = TRUE)) { #' data("stemcell") #' model <- bracl( #' research ~ as.numeric(religion) + gender, diff --git a/R/methods_multcomp.R b/R/methods_multcomp.R index 5cb3d1bad..7881632ea 100644 --- a/R/methods_multcomp.R +++ b/R/methods_multcomp.R @@ -10,7 +10,7 @@ #' #' @examples #' \donttest{ -#' if (require("multcomp")) { +#' if (require("multcomp", quietly = TRUE)) { #' # multiple linear model, swiss data #' lmod <- lm(Fertility ~ ., data = swiss) #' mod <- glht( @@ -25,7 +25,7 @@ #' ) #' model_parameters(mod) #' } -#' if (require("PMCMRplus")) { +#' if (require("PMCMRplus", quietly = TRUE)) { #' model <- kwAllPairsConoverTest(count ~ spray, data = InsectSprays) #' model_parameters(model) #' } diff --git a/R/methods_panelr.R b/R/methods_panelr.R index a99368d50..d71e31566 100644 --- a/R/methods_panelr.R +++ b/R/methods_panelr.R @@ -16,14 +16,22 @@ model_parameters.wbm <- function(model, p_adjust = NULL, verbose = TRUE, ...) { - effects <- match.arg(effects, choices = c("fixed", "random", "all")) params <- .mixed_model_parameters_generic( - model = model, ci = ci, bootstrap = bootstrap, iterations = iterations, - merge_by = c("Parameter", "Component"), standardize = NULL, - exponentiate = exponentiate, effects = effects, robust = FALSE, - p_adjust = p_adjust, group_level = group_level, df_method = NULL, ... + model = model, + ci = ci, + bootstrap = bootstrap, + iterations = iterations, + merge_by = c("Parameter", "Component"), + standardize = NULL, + exponentiate = exponentiate, + effects = effects, + robust = FALSE, + p_adjust = p_adjust, + group_level = group_level, + df_method = NULL, + ... ) attr(params, "object_name") <- deparse(substitute(model), width.cutoff = 500) diff --git a/R/methods_psych.R b/R/methods_psych.R index 14de1f533..10694c1df 100644 --- a/R/methods_psych.R +++ b/R/methods_psych.R @@ -18,7 +18,7 @@ #' @examples #' \donttest{ #' library(parameters) -#' if (require("psych")) { +#' if (require("psych", quietly = TRUE)) { #' # Principal Component Analysis (PCA) --------- #' pca <- psych::principal(attitude) #' model_parameters(pca) @@ -42,7 +42,7 @@ #' } #' #' # FactoMineR --------- -#' if (require("FactoMineR")) { +#' if (require("FactoMineR", quietly = TRUE)) { #' model <- FactoMineR::PCA(iris[, 1:4], ncp = 2) #' model_parameters(model) #' attributes(model_parameters(model))$scores diff --git a/R/methods_quantreg.R b/R/methods_quantreg.R index 203ea0df0..8ca13b585 100644 --- a/R/methods_quantreg.R +++ b/R/methods_quantreg.R @@ -111,7 +111,9 @@ standard_error.nlrq <- standard_error.rq #' @export -standard_error.rqss <- function(model, component = c("all", "conditional", "smooth_terms"), ...) { +standard_error.rqss <- function(model, + component = c("all", "conditional", "smooth_terms"), + ...) { component <- match.arg(component) cs <- summary(model)$coef @@ -233,7 +235,9 @@ p_value.nlrq <- p_value.rq #' @export -p_value.rqss <- function(model, component = c("all", "conditional", "smooth_terms"), ...) { +p_value.rqss <- function(model, + component = c("all", "conditional", "smooth_terms"), + ...) { component <- match.arg(component) cs <- summary(model)$coef diff --git a/R/methods_varest.R b/R/methods_varest.R index 3db6f96bd..cb3c758cc 100644 --- a/R/methods_varest.R +++ b/R/methods_varest.R @@ -13,10 +13,15 @@ model_parameters.varest <- function(model, ...) { params <- lapply(names(model$varresult), function(i) { out <- model_parameters( - model = model$varresult[[i]], ci = ci, - bootstrap = bootstrap, iterations = iterations, - standardize = standardize, exponentiate = exponentiate, - robust = robust, p_adjust = p_adjust, verbose = verbose, + model = model$varresult[[i]], + ci = ci, + bootstrap = bootstrap, + iterations = iterations, + standardize = standardize, + exponentiate = exponentiate, + robust = robust, + p_adjust = p_adjust, + verbose = verbose, ... ) out$Group <- paste0("Equation ", i) diff --git a/R/n_clusters.R b/R/n_clusters.R index ec423d76e..c9081a350 100644 --- a/R/n_clusters.R +++ b/R/n_clusters.R @@ -15,7 +15,8 @@ #' @examples #' library(parameters) #' \donttest{ -#' if (require("mclust") && require("NbClust") && require("cluster")) { +#' if (require("mclust", quietly = TRUE) && require("NbClust", quietly = TRUE) && +#' require("cluster", quietly = TRUE)) { #' n_clusters(iris[, 1:4], package = c("NbClust", "mclust", "cluster")) #' } #' } diff --git a/R/n_factors.R b/R/n_factors.R index 82548d652..2ca724767 100644 --- a/R/n_factors.R +++ b/R/n_factors.R @@ -11,13 +11,19 @@ #' @param cor An optional correlation matrix that can be used (note that the data must still be passed as the first argument). If \code{NULL}, will compute it by running \code{cor()} on the passed data. #' @param ... Arguments passed to or from other methods. #' -#' @details \code{n_components} is actually an alias for \code{n_factors}, with different defaults for the function arguments. +#' @details \code{n_components} is actually an alias for \code{n_factors}, with +#' different defaults for the function arguments. #' -#' @note There is also a \href{https://easystats.github.io/see/articles/parameters.html}{\code{plot()}-method} implemented in the \href{https://easystats.github.io/see/}{\pkg{see}-package}. \code{n_components()} is a convenient short for \code{n_factors(type = "PCA")}. +#' @note There is also a +#' \href{https://easystats.github.io/see/articles/parameters.html}{\code{plot()}-method} +#' implemented in the +#' \href{https://easystats.github.io/see/}{\pkg{see}-package}. +#' \code{n_components()} is a convenient short for \code{n_factors(type = +#' "PCA")}. #' #' @examples #' library(parameters) -#' if (require("nFactors") && require("EGAnet")) { +#' if (require("nFactors", quietly = TRUE) && require("EGAnet", quietly = TRUE)) { #' n_factors(mtcars, type = "PCA") #' #' result <- n_factors(mtcars[1:5], type = "FA") diff --git a/R/p_value_kenward.R b/R/p_value_kenward.R index 33c9dd1e3..48d8afbc7 100644 --- a/R/p_value_kenward.R +++ b/R/p_value_kenward.R @@ -28,13 +28,14 @@ #' #' @examples #' \donttest{ -#' if (require("lme4")) { +#' if (require("lme4", quietly = TRUE)) { #' model <- lmer(Petal.Length ~ Sepal.Length + (1 | Species), data = iris) #' p_value_kenward(model) #' } #' } #' @return A data frame. -#' @references Kenward, M. G., & Roger, J. H. (1997). Small sample inference for fixed effects from restricted maximum likelihood. Biometrics, 983-997. +#' @references Kenward, M. G., & Roger, J. H. (1997). Small sample inference for +#' fixed effects from restricted maximum likelihood. Biometrics, 983-997. #' @importFrom stats pt coef #' @export p_value_kenward <- function(model, dof = NULL) { diff --git a/R/p_value_satterthwaite.R b/R/p_value_satterthwaite.R index 9405510b1..f608f0bcb 100644 --- a/R/p_value_satterthwaite.R +++ b/R/p_value_satterthwaite.R @@ -26,7 +26,7 @@ #' #' @examples #' \donttest{ -#' if (require("lme4")) { +#' if (require("lme4", quietly = TRUE)) { #' model <- lmer(Petal.Length ~ Sepal.Length + (1 | Species), data = iris) #' p_value_satterthwaite(model) #' } diff --git a/R/print.parameters_model.R b/R/print.parameters_model.R index 81f868b1a..89bbe55e4 100644 --- a/R/print.parameters_model.R +++ b/R/print.parameters_model.R @@ -22,12 +22,13 @@ #' #' @return Invisibly returns the original input object. #' -#' @seealso There is a dedicated method to use inside rmarkdown files, \code{\link[=print_md.parameters_model]{print_md()}}. +#' @seealso There is a dedicated method to use inside rmarkdown files, +#' \code{\link[=print_md.parameters_model]{print_md()}}. #' #' @examples #' \donttest{ #' library(parameters) -#' if (require("glmmTMB")) { +#' if (require("glmmTMB", quietly = TRUE)) { #' model <- glmmTMB( #' count ~ spp + mined + (1 | site), #' ziformula = ~mined, diff --git a/R/robust_estimation.R b/R/robust_estimation.R index 8ffde7b4d..49d8c8e6d 100644 --- a/R/robust_estimation.R +++ b/R/robust_estimation.R @@ -29,13 +29,13 @@ #' @seealso Working examples cam be found \href{https://easystats.github.io/parameters/articles/model_parameters_robust.html}{in this vignette}. #' #' @examples -#' if (require("sandwich")) { +#' if (require("sandwich", quietly = TRUE)) { #' # robust standard errors, calling sandwich::vcovHC(type="HC3") by default #' model <- lm(Petal.Length ~ Sepal.Length * Species, data = iris) #' standard_error_robust(model) #' } #' \dontrun{ -#' if (require("clubSandwich")) { +#' if (require("clubSandwich", quietly = TRUE)) { #' # cluster-robust standard errors, using clubSandwich #' iris$cluster <- factor(rep(LETTERS[1:8], length.out = nrow(iris))) #' standard_error_robust( diff --git a/R/skewness_kurtosis.R b/R/skewness_kurtosis.R index 83019474a..e4cc5bbaa 100644 --- a/R/skewness_kurtosis.R +++ b/R/skewness_kurtosis.R @@ -2,9 +2,15 @@ #' #' @param x A numeric vector or data.frame. #' @param na.rm Remove missing values. -#' @param type Type of algorithm for computing skewness. May be one of \code{1} (or \code{"1"}, \code{"I"} or \code{"classic"}), \code{2} (or \code{"2"}, \code{"II"} or \code{"SPSS"} or \code{"SAS"}) or \code{3} (or \code{"3"}, \code{"III"} or \code{"Minitab"}). See 'Details'. -#' @param iterations The number of bootstrap replicates for computing standard errors. If \code{NULL} (default), parametric standard errors are computed. See 'Details'. -#' @param test Logical, if \code{TRUE}, tests if skewness or kurtosis is significantly different from zero. +#' @param type Type of algorithm for computing skewness. May be one of \code{1} +#' (or \code{"1"}, \code{"I"} or \code{"classic"}), \code{2} (or \code{"2"}, +#' \code{"II"} or \code{"SPSS"} or \code{"SAS"}) or \code{3} (or \code{"3"}, +#' \code{"III"} or \code{"Minitab"}). See 'Details'. +#' @param iterations The number of bootstrap replicates for computing standard +#' errors. If \code{NULL} (default), parametric standard errors are computed. +#' See 'Details'. +#' @param test Logical, if \code{TRUE}, tests if skewness or kurtosis is +#' significantly different from zero. #' @param digits Number of decimal places. #' @param object An object returned by \code{skewness()} or \code{kurtosis()}. #' @param ... Arguments passed to or from other methods. @@ -15,10 +21,12 @@ #' positive skewness values indicates a "right-skewed" distribution. Examples #' for the relationship of skewness and distributions are: #' \itemize{ -#' \item Normal distribution (and other symmetric distribution) has a skewness of 0 +#' \item Normal distribution (and other symmetric distribution) has a skewness +#' of 0 #' \item Half-normal distribution has a skewness just below 1 #' \item Exponential distribution has a skewness of 2 -#' \item Lognormal distribution can have a skewness of any positive value, depending on its parameters +#' \item Lognormal distribution can have a skewness of any positive value, +#' depending on its parameters #' } #' (\cite{https://en.wikipedia.org/wiki/Skewness}) #' } @@ -102,7 +110,13 @@ skewness.numeric <- function(x, na.rm = TRUE, type = "2", iterations = NULL, ... if (!requireNamespace("boot", quietly = TRUE)) { warning("Package 'boot' needed for bootstrapping SEs.", call. = FALSE) } else { - results <- boot::boot(data = x, statistic = .boot_skewness, R = iterations, na.rm = na.rm, type = type) + results <- boot::boot( + data = x, + statistic = .boot_skewness, + R = iterations, + na.rm = na.rm, + type = type + ) out_se <- stats::sd(results$t, na.rm = TRUE) } } @@ -195,7 +209,13 @@ kurtosis.numeric <- function(x, na.rm = TRUE, type = "2", iterations = NULL, ... if (!requireNamespace("boot", quietly = TRUE)) { warning("Package 'boot' needed for bootstrapping SEs.", call. = FALSE) } else { - results <- boot::boot(data = x, statistic = .boot_kurtosis, R = iterations, na.rm = na.rm, type = type) + results <- boot::boot( + data = x, + statistic = .boot_kurtosis, + R = iterations, + na.rm = na.rm, + type = type + ) out_se <- stats::sd(results$t, na.rm = TRUE) } } diff --git a/R/smoothness.R b/R/smoothness.R index 98ec1d402..0217db771 100644 --- a/R/smoothness.R +++ b/R/smoothness.R @@ -1,8 +1,10 @@ #' Quantify the smoothness of a vector #' #' @param x Numeric vector (similar to a time series). -#' @param method Can be "diff" (the standard deviation of the standardized differences) or "cor" (default, lag-one autocorrelation). -#' @param lag An integer indicating which lag to use. If less than 1, will be interpreted as expressed in percentage of the length of the vector. +#' @param method Can be "diff" (the standard deviation of the standardized +#' differences) or "cor" (default, lag-one autocorrelation). +#' @param lag An integer indicating which lag to use. If less than 1, will be +#' interpreted as expressed in percentage of the length of the vector. #' @inheritParams skewness #' #' @examples @@ -40,7 +42,13 @@ smoothness.numeric <- function(x, method = "cor", lag = 1, iterations = NULL, .. if (!requireNamespace("boot", quietly = TRUE)) { warning("Package 'boot' needed for bootstrapping SEs.", call. = FALSE) } else { - results <- boot::boot(data = x, statistic = .boot_smoothness, R = iterations, method = method, lag = lag) + results <- boot::boot( + data = x, + statistic = .boot_smoothness, + R = iterations, + method = method, + lag = lag + ) out_se <- stats::sd(results$t, na.rm = TRUE) smooth <- data.frame(Smoothness = smooth, SE = out_se) } diff --git a/R/utils_format.R b/R/utils_format.R index af4cd019b..df4b56933 100644 --- a/R/utils_format.R +++ b/R/utils_format.R @@ -302,9 +302,11 @@ "conditional.fixed" = , "conditional.fixed." = ifelse(is_zero_inflated, "Fixed Effects (Count Model)", "Fixed Effects"), "conditional.random" = ifelse(ran_pars, - "Random Effects Variances", - ifelse(is_zero_inflated, - "Random Effects (Count Model)", "Random Effects")), + "Random Effects Variances", + ifelse(is_zero_inflated, + "Random Effects (Count Model)", "Random Effects" + ) + ), "zero_inflated" = "Zero-Inflated", "zero_inflated.fixed" = , "zero_inflated.fixed." = "Fixed Effects (Zero-Inflated Model)", diff --git a/inst/WORDLIST b/inst/WORDLIST index 6f74c0c02..570099e9b 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -4,6 +4,7 @@ Ameijeiras Analysing Anova Asparouhov +BLUPs BMC Bafumi BayesFactor @@ -158,6 +159,7 @@ effectsize emmGrid emmeans endogeneity +epiR equivariance ergm et @@ -177,6 +179,7 @@ interpretable io ivfixed ivprobit +joineRML joss jstatsoft kmeans @@ -199,6 +202,7 @@ metaBMA metafor metaplus mfx +mhurdle minkowski mira mlm diff --git a/man/bootstrap_model.Rd b/man/bootstrap_model.Rd index cd6a6623c..cfc721a2f 100644 --- a/man/bootstrap_model.Rd +++ b/man/bootstrap_model.Rd @@ -38,7 +38,7 @@ to obtain non-parametric p-values. \examples{ \dontrun{ -if (require("boot")) { +if (require("boot", quietly = TRUE)) { model <- lm(mpg ~ wt + factor(cyl), data = mtcars) b <- bootstrap_model(model) print(head(b)) diff --git a/man/bootstrap_parameters.Rd b/man/bootstrap_parameters.Rd index 78adf6cf9..b2f2081c3 100644 --- a/man/bootstrap_parameters.Rd +++ b/man/bootstrap_parameters.Rd @@ -68,7 +68,7 @@ to obtain non-parametric p-values. \examples{ \dontrun{ -if (require("boot")) { +if (require("boot", quietly = TRUE)) { set.seed(2) model <- lm(Sepal.Length ~ Species * Petal.Width, data = iris) b <- bootstrap_parameters(model) diff --git a/man/ci.merMod.Rd b/man/ci.merMod.Rd index 59fff0b76..0e3a47643 100644 --- a/man/ci.merMod.Rd +++ b/man/ci.merMod.Rd @@ -111,9 +111,20 @@ \item{dof}{Degrees of Freedom. If not specified, for \code{ci_wald()}, defaults to model's residual degrees of freedom (i.e. \code{n-k}, where \code{n} is the number of observations and \code{k} is the number of parameters). For \code{p_value_wald()}, defaults to \code{Inf}.} -\item{method}{For mixed models, can be \code{\link[=p_value_wald]{"wald"}} (default), \code{\link[=p_value_ml1]{"ml1"}} or \code{\link[=p_value_betwithin]{"betwithin"}}. For linear mixed model, can also be \code{\link[=p_value_satterthwaite]{"satterthwaite"}}, \code{\link[=p_value_kenward]{"kenward"}} or \code{"boot"} (see \code{lme4::confint.merMod}). For (generalized) linear models, can be \code{"robust"} to compute confidence intervals based on robust covariance matrix estimation, and for generalized linear models and models from packages \pkg{lme4} or \pkg{glmmTMB}, may also be \code{"profile"}, \code{"uniroot"} or \code{"wald"} (default).} - -\item{...}{Arguments passed down to \code{standard_error_robust()} when confidence intervals or p-values based on robust standard errors should be computed.} +\item{method}{For mixed models, can be \code{\link[=p_value_wald]{"wald"}} +(default), \code{\link[=p_value_ml1]{"ml1"}} or +\code{\link[=p_value_betwithin]{"betwithin"}}. For linear mixed model, can +also be \code{\link[=p_value_satterthwaite]{"satterthwaite"}}, +\code{\link[=p_value_kenward]{"kenward"}} or \code{"boot"} (see +\code{lme4::confint.merMod}). For (generalized) linear models, can be +\code{"robust"} to compute confidence intervals based on robust covariance +matrix estimation, and for generalized linear models and models from +packages \pkg{lme4} or \pkg{glmmTMB}, may also be \code{"profile"}, +\code{"uniroot"} or \code{"wald"} (default).} + +\item{...}{Arguments passed down to \code{standard_error_robust()} when +confidence intervals or p-values based on robust standard errors should be +computed.} \item{component}{Should all parameters, parameters for the conditional model, or for the zero-inflated part of the model be returned? Applies to models diff --git a/man/compare_parameters.Rd b/man/compare_parameters.Rd index 24971ee69..6124d62aa 100644 --- a/man/compare_parameters.Rd +++ b/man/compare_parameters.Rd @@ -40,7 +40,9 @@ types.} \item{ci}{Confidence Interval (CI) level. Default to 0.95 (95\%).} -\item{effects}{Should parameters for fixed effects (\code{"fixed"}), random effects (\code{"random"}), or both (\code{"all"}) be returned? Only applies to mixed models. May be abbreviated.} +\item{effects}{Should parameters for fixed effects (\code{"fixed"}), random +effects (\code{"random"}), or both (\code{"all"}) be returned? Only applies +to mixed models. May be abbreviated.} \item{component}{Model component for which parameters should be shown. See documentation for related model class in \code{\link{model_parameters}}.} diff --git a/man/degrees_of_freedom.Rd b/man/degrees_of_freedom.Rd index 723368a14..e68dff0b6 100644 --- a/man/degrees_of_freedom.Rd +++ b/man/degrees_of_freedom.Rd @@ -54,12 +54,12 @@ dof(model) model <- glm(vs ~ mpg * cyl, data = mtcars, family = "binomial") dof(model) \dontrun{ -if (require("lme4")) { +if (require("lme4", quietly = TRUE)) { model <- lmer(Sepal.Length ~ Petal.Length + (1 | Species), data = iris) dof(model) } -if (require("rstanarm")) { +if (require("rstanarm", quietly = TRUE)) { model <- stan_glm( Sepal.Length ~ Petal.Length * Species, data = iris, diff --git a/man/equivalence_test.lm.Rd b/man/equivalence_test.lm.Rd index eed0b7fc0..6922f0146 100644 --- a/man/equivalence_test.lm.Rd +++ b/man/equivalence_test.lm.Rd @@ -42,7 +42,9 @@ to automatically define this range based on properties of the model's data.} \item{...}{Arguments passed to or from other methods.} -\item{effects}{Should parameters for fixed effects (\code{"fixed"}), random effects (\code{"random"}), or both (\code{"all"}) be returned? Only applies to mixed models. May be abbreviated.} +\item{effects}{Should parameters for fixed effects (\code{"fixed"}), random +effects (\code{"random"}), or both (\code{"all"}) be returned? Only applies +to mixed models. May be abbreviated.} } \value{ A data frame. @@ -147,7 +149,7 @@ equivalence_test(model) equivalence_test(model, rule = "cet") # plot method -if (require("see")) { +if (require("see", quietly = TRUE)) { result <- equivalence_test(model) plot(result) } diff --git a/man/model_parameters.Mclust.Rd b/man/model_parameters.Mclust.Rd index 2c2afdecf..653cd19d7 100644 --- a/man/model_parameters.Mclust.Rd +++ b/man/model_parameters.Mclust.Rd @@ -18,7 +18,7 @@ Format mixture models obtained for example by \code{mclust::Mclust}. } \examples{ library(parameters) -if (require("mclust")) { +if (require("mclust", quietly = TRUE)) { model <- mclust::Mclust(iris[1:4], verbose = FALSE) model_parameters(model) } diff --git a/man/model_parameters.averaging.Rd b/man/model_parameters.averaging.Rd index 9440237f9..4a57d19b5 100644 --- a/man/model_parameters.averaging.Rd +++ b/man/model_parameters.averaging.Rd @@ -98,7 +98,7 @@ Parameters from special regression models not listed under one of the previous c } \examples{ library(parameters) -if (require("brglm2")) { +if (require("brglm2", quietly = TRUE)) { data("stemcell") model <- bracl( research ~ as.numeric(religion) + gender, diff --git a/man/model_parameters.glht.Rd b/man/model_parameters.glht.Rd index 4ea041786..a7d82a30b 100644 --- a/man/model_parameters.glht.Rd +++ b/man/model_parameters.glht.Rd @@ -38,7 +38,7 @@ Parameters from Hypothesis Testing. } \examples{ \donttest{ -if (require("multcomp")) { +if (require("multcomp", quietly = TRUE)) { # multiple linear model, swiss data lmod <- lm(Fertility ~ ., data = swiss) mod <- glht( @@ -53,7 +53,7 @@ if (require("multcomp")) { ) model_parameters(mod) } -if (require("PMCMRplus")) { +if (require("PMCMRplus", quietly = TRUE)) { model <- kwAllPairsConoverTest(count ~ spray, data = InsectSprays) model_parameters(model) } diff --git a/man/model_parameters.lavaan.Rd b/man/model_parameters.lavaan.Rd index 9b67c6b25..6edde341f 100644 --- a/man/model_parameters.lavaan.Rd +++ b/man/model_parameters.lavaan.Rd @@ -47,7 +47,7 @@ There is also a \href{https://easystats.github.io/see/articles/parameters.html}{ library(parameters) # lavaan ------------------------------------- -if (require("lavaan")) { +if (require("lavaan", quietly = TRUE)) { # Confirmatory Factor Analysis (CFA) --------- @@ -82,7 +82,11 @@ if (require("lavaan")) { } \references{ \itemize{ - \item Rosseel Y (2012). lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48(2), 1-36. - \item Merkle EC , Rosseel Y (2018). blavaan: Bayesian Structural Equation Models via Parameter Expansion. Journal of Statistical Software, 85(4), 1-30. http://www.jstatsoft.org/v85/i04/ + \item Rosseel Y (2012). lavaan: An R Package for Structural Equation + Modeling. Journal of Statistical Software, 48(2), 1-36. + + \item Merkle EC , Rosseel Y (2018). blavaan: Bayesian Structural Equation + Models via Parameter Expansion. Journal of Statistical Software, 85(4), + 1-30. http://www.jstatsoft.org/v85/i04/ } } diff --git a/man/model_parameters.merMod.Rd b/man/model_parameters.merMod.Rd index e92fa3abe..9e3c0ac93 100644 --- a/man/model_parameters.merMod.Rd +++ b/man/model_parameters.merMod.Rd @@ -109,7 +109,9 @@ regressions} apply (see also robust estimation (i.e. \code{robust=TRUE}) of standardized parameters only works when \code{standardize="refit"}.} -\item{effects}{Should parameters for fixed effects (\code{"fixed"}), random effects (\code{"random"}), or both (\code{"all"}) be returned? Only applies to mixed models. May be abbreviated.} +\item{effects}{Should parameters for fixed effects (\code{"fixed"}), random +effects (\code{"random"}), or both (\code{"all"}) be returned? Only applies +to mixed models. May be abbreviated.} \item{group_level}{Logical, for multilevel models (i.e. models with random effects) and when \code{effects = "all"} or \code{effects = "random"}, @@ -126,9 +128,21 @@ mimic behaviour of other software packages, such as Stata. For \code{compare_parameters()}, \code{exponentiate = "nongaussian"} will only exponentiate coefficients for all models except those from Gaussian family.} -\item{details}{Logical, if \code{TRUE}, a summary of the random effects is included. See \code{\link{random_parameters}} for details.} - -\item{df_method}{Method for computing degrees of freedom for p values, standard errors and confidence intervals (CI). May be \code{"wald"} (default, see \code{\link{degrees_of_freedom}}), \code{"ml1"} (see \code{\link{dof_ml1}}), \code{"betwithin"} (see \code{\link{dof_betwithin}}), \code{"satterthwaite"} (see \code{\link{dof_satterthwaite}}) or \code{"kenward"} (see \code{\link{dof_kenward}}). The options \code{df_method = "boot"}, \code{df_method = "profile"} and \code{df_method = "uniroot"} only affect confidence intervals; in this case, bootstrapped resp. profiled confidence intervals are computed. \code{"uniroot"} only applies to models of class \code{glmmTMB}. Note that when \code{df_method} is not \code{"wald"}, robust standard errors etc. cannot be computed.} +\item{details}{Logical, if \code{TRUE}, a summary of the random effects is +included. See \code{\link{random_parameters}} for details.} + +\item{df_method}{Method for computing degrees of freedom for p values, +standard errors and confidence intervals (CI). May be \code{"wald"} +(default, see \code{\link{degrees_of_freedom}}), \code{"ml1"} (see +\code{\link{dof_ml1}}), \code{"betwithin"} (see +\code{\link{dof_betwithin}}), \code{"satterthwaite"} (see +\code{\link{dof_satterthwaite}}) or \code{"kenward"} (see +\code{\link{dof_kenward}}). The options \code{df_method = "boot"}, +\code{df_method = "profile"} and \code{df_method = "uniroot"} only affect +confidence intervals; in this case, bootstrapped resp. profiled confidence +intervals are computed. \code{"uniroot"} only applies to models of class +\code{glmmTMB}. Note that when \code{df_method} is not \code{"wald"}, +robust standard errors etc. cannot be computed.} \item{p_adjust}{Character vector, if not \code{NULL}, indicates the method to adjust p-values. See \code{\link[stats]{p.adjust}} for details. Further @@ -145,7 +159,12 @@ or for the zero-inflated part of the model be returned? Applies to models with zero-inflated component. \code{component} may be one of \code{"conditional"}, \code{"zi"}, \code{"zero-inflated"} or \code{"all"} (default). May be abbreviated.} -\item{wb_component}{Logical, if \code{TRUE} and models contains within- and between-effects (see \code{\link{demean}}), the \code{Component} column will indicate which variables belong to the within-effects, between-effects, and cross-level interactions. By default, the \code{Component} column indicates, which parameters belong to the conditional or zero-inflated component of the model.} +\item{wb_component}{Logical, if \code{TRUE} and models contains within- and +between-effects (see \code{\link{demean}}), the \code{Component} column +will indicate which variables belong to the within-effects, +between-effects, and cross-level interactions. By default, the +\code{Component} column indicates, which parameters belong to the +conditional or zero-inflated component of the model.} \item{robust}{Logical, if \code{TRUE}, robust standard errors are calculated (if possible), and confidence intervals and p-values are based on these @@ -190,6 +209,6 @@ if (require("lme4")) { } } \seealso{ -\code{\link[insight:standardize_names]{standardize_names()}} to rename - columns into a consistent, standardized naming scheme. +\code{\link[insight:standardize_names]{standardize_names()}} to + rename columns into a consistent, standardized naming scheme. } diff --git a/man/model_parameters.mira.Rd b/man/model_parameters.mira.Rd index 5e2fb5126..f15d25629 100644 --- a/man/model_parameters.mira.Rd +++ b/man/model_parameters.mira.Rd @@ -47,7 +47,7 @@ Format models of class \code{mira}, obtained from \code{mice::width.mids()}. } \examples{ library(parameters) -if (require("mice")) { +if (require("mice", quietly = TRUE)) { data(nhanes2) imp <- mice(nhanes2) fit <- with(data = imp, exp = lm(bmi ~ age + hyp + chl)) @@ -55,7 +55,7 @@ if (require("mice")) { } \dontrun{ # model_parameters() also works for models that have no "tidy"-method in mice -if (require("mice") && require("gee")) { +if (require("mice", quietly = TRUE) && require("gee", quietly = TRUE)) { data(warpbreaks) set.seed(1234) warpbreaks$tension[sample(1:nrow(warpbreaks), size = 10)] <- NA diff --git a/man/model_parameters.mlm.Rd b/man/model_parameters.mlm.Rd index c31aafa47..13157679c 100644 --- a/man/model_parameters.mlm.Rd +++ b/man/model_parameters.mlm.Rd @@ -119,7 +119,7 @@ Multinomial or cumulative link models, i.e. models where the } \examples{ library(parameters) -if (require("brglm2")) { +if (require("brglm2", quietly = TRUE)) { data("stemcell") model <- bracl( research ~ as.numeric(religion) + gender, diff --git a/man/model_parameters.principal.Rd b/man/model_parameters.principal.Rd index 2861e2fb1..e9e6eed51 100644 --- a/man/model_parameters.principal.Rd +++ b/man/model_parameters.principal.Rd @@ -60,7 +60,7 @@ For the structural models obtained with \pkg{psych}, the following indices are p \examples{ \donttest{ library(parameters) -if (require("psych")) { +if (require("psych", quietly = TRUE)) { # Principal Component Analysis (PCA) --------- pca <- psych::principal(attitude) model_parameters(pca) @@ -84,7 +84,7 @@ if (require("psych")) { } # FactoMineR --------- -if (require("FactoMineR")) { +if (require("FactoMineR", quietly = TRUE)) { model <- FactoMineR::PCA(iris[, 1:4], ncp = 2) model_parameters(model) attributes(model_parameters(model))$scores diff --git a/man/model_parameters.rma.Rd b/man/model_parameters.rma.Rd index 21c3826e8..1581d51bf 100644 --- a/man/model_parameters.rma.Rd +++ b/man/model_parameters.rma.Rd @@ -66,13 +66,13 @@ mydat <<- data.frame( effectsize = c(-0.393, 0.675, 0.282, -1.398), stderr = c(0.317, 0.317, 0.13, 0.36) ) -if (require("metafor")) { +if (require("metafor", quietly = TRUE)) { model <- rma(yi = effectsize, sei = stderr, method = "REML", data = mydat) model_parameters(model) } \dontrun{ # with subgroups -if (require("metafor")) { +if (require("metafor", quietly = TRUE)) { data(dat.bcg) dat <- escalc( measure = "RR", @@ -87,7 +87,7 @@ if (require("metafor")) { model_parameters(model) } -if (require("metaBMA")) { +if (require("metaBMA", quietly = TRUE)) { data(towels) m <- meta_random(logOR, SE, study, data = towels) model_parameters(m) diff --git a/man/n_clusters.Rd b/man/n_clusters.Rd index 47326b2ce..8f25b73cc 100644 --- a/man/n_clusters.Rd +++ b/man/n_clusters.Rd @@ -38,7 +38,8 @@ There is also a \href{https://easystats.github.io/see/articles/parameters.html}{ \examples{ library(parameters) \donttest{ -if (require("mclust") && require("NbClust") && require("cluster")) { +if (require("mclust", quietly = TRUE) && require("NbClust", quietly = TRUE) && + require("cluster", quietly = TRUE)) { n_clusters(iris[, 1:4], package = c("NbClust", "mclust", "cluster")) } } diff --git a/man/n_factors.Rd b/man/n_factors.Rd index 085f97e58..1790b0dad 100644 --- a/man/n_factors.Rd +++ b/man/n_factors.Rd @@ -51,14 +51,20 @@ A data frame. This function runs many existing procedures for determining how many factors to retain for your factor analysis (FA) or dimension reduction (PCA). It returns the number of factors based on the maximum consensus between methods. In case of ties, it will keep the simplest models and select the solution with the less factors. } \details{ -\code{n_components} is actually an alias for \code{n_factors}, with different defaults for the function arguments. +\code{n_components} is actually an alias for \code{n_factors}, with + different defaults for the function arguments. } \note{ -There is also a \href{https://easystats.github.io/see/articles/parameters.html}{\code{plot()}-method} implemented in the \href{https://easystats.github.io/see/}{\pkg{see}-package}. \code{n_components()} is a convenient short for \code{n_factors(type = "PCA")}. +There is also a + \href{https://easystats.github.io/see/articles/parameters.html}{\code{plot()}-method} + implemented in the + \href{https://easystats.github.io/see/}{\pkg{see}-package}. + \code{n_components()} is a convenient short for \code{n_factors(type = + "PCA")}. } \examples{ library(parameters) -if (require("nFactors") && require("EGAnet")) { +if (require("nFactors", quietly = TRUE) && require("EGAnet", quietly = TRUE)) { n_factors(mtcars, type = "PCA") result <- n_factors(mtcars[1:5], type = "FA") diff --git a/man/p_value.poissonmfx.Rd b/man/p_value.poissonmfx.Rd index a40666ae6..46aa96dde 100644 --- a/man/p_value.poissonmfx.Rd +++ b/man/p_value.poissonmfx.Rd @@ -24,13 +24,15 @@ \item{...}{Currently not used.} } \value{ -A data frame with at least two columns: the parameter names and the p-values. Depending on the model, may also include columns for model components etc. +A data frame with at least two columns: the parameter names and the + p-values. Depending on the model, may also include columns for model + components etc. } \description{ This function attempts to return, or compute, p-values of marginal effects models from package \pkg{mfx}. } \examples{ -if (require("mfx")) { +if (require("mfx", quietly = TRUE)) { set.seed(12345) n <- 1000 x <- rnorm(n) diff --git a/man/p_value.zcpglm.Rd b/man/p_value.zcpglm.Rd index a7653b79e..a0e3e211e 100644 --- a/man/p_value.zcpglm.Rd +++ b/man/p_value.zcpglm.Rd @@ -30,13 +30,15 @@ with zero-inflated component. \code{component} may be one of \code{"conditional" \item{verbose}{Toggle warnings and messages.} } \value{ -A data frame with at least two columns: the parameter names and the p-values. Depending on the model, may also include columns for model components etc. +A data frame with at least two columns: the parameter names and the + p-values. Depending on the model, may also include columns for model + components etc. } \description{ This function attempts to return, or compute, p-values of hurdle and zero-inflated models. } \examples{ -if (require("pscl")) { +if (require("pscl", quietly = TRUE)) { data("bioChemists") model <- zeroinfl(art ~ fem + mar + kid5 | kid5 + phd, data = bioChemists) p_value(model) diff --git a/man/p_value_kenward.Rd b/man/p_value_kenward.Rd index 4d685d3c7..ee4d6af09 100644 --- a/man/p_value_kenward.Rd +++ b/man/p_value_kenward.Rd @@ -43,14 +43,15 @@ to linear mixed models only. } \examples{ \donttest{ -if (require("lme4")) { +if (require("lme4", quietly = TRUE)) { model <- lmer(Petal.Length ~ Sepal.Length + (1 | Species), data = iris) p_value_kenward(model) } } } \references{ -Kenward, M. G., & Roger, J. H. (1997). Small sample inference for fixed effects from restricted maximum likelihood. Biometrics, 983-997. +Kenward, M. G., & Roger, J. H. (1997). Small sample inference for + fixed effects from restricted maximum likelihood. Biometrics, 983-997. } \seealso{ \code{dof_kenward()} and \code{se_kenward()} are small helper-functions diff --git a/man/p_value_satterthwaite.Rd b/man/p_value_satterthwaite.Rd index cd091b7f2..d3abaf503 100644 --- a/man/p_value_satterthwaite.Rd +++ b/man/p_value_satterthwaite.Rd @@ -42,7 +42,7 @@ Kenward-Roger or Satterthwaite are limited to linear mixed models only. } \examples{ \donttest{ -if (require("lme4")) { +if (require("lme4", quietly = TRUE)) { model <- lmer(Petal.Length ~ Sepal.Length + (1 | Species), data = iris) p_value_satterthwaite(model) } diff --git a/man/pool_parameters.Rd b/man/pool_parameters.Rd index 1a70888e9..3b023b0a7 100644 --- a/man/pool_parameters.Rd +++ b/man/pool_parameters.Rd @@ -33,7 +33,8 @@ one of \code{"conditional"}, \code{"precision"} (\pkg{betareg}), \code{"marginal"} (\pkg{mfx}), \code{"conditional"} or \code{"full"} (for \code{MuMIn::model.avg()}) or \code{"all"}.} -\item{details}{Logical, if \code{TRUE}, a summary of the random effects is included. See \code{\link{random_parameters}} for details.} +\item{details}{Logical, if \code{TRUE}, a summary of the random effects is +included. See \code{\link{random_parameters}} for details.} \item{verbose}{Toggle warnings and messages.} diff --git a/man/print.parameters_model.Rd b/man/print.parameters_model.Rd index a9ea2ee0b..41ca767f7 100644 --- a/man/print.parameters_model.Rd +++ b/man/print.parameters_model.Rd @@ -86,7 +86,7 @@ freedom. \examples{ \donttest{ library(parameters) -if (require("glmmTMB")) { +if (require("glmmTMB", quietly = TRUE)) { model <- glmmTMB( count ~ spp + mined + (1 | site), ziformula = ~mined, @@ -106,5 +106,6 @@ if (require("glmmTMB")) { } } \seealso{ -There is a dedicated method to use inside rmarkdown files, \code{\link[=print_md.parameters_model]{print_md()}}. +There is a dedicated method to use inside rmarkdown files, + \code{\link[=print_md.parameters_model]{print_md()}}. } diff --git a/man/simulate_model.Rd b/man/simulate_model.Rd index ee0460dcf..b8b8f2554 100644 --- a/man/simulate_model.Rd +++ b/man/simulate_model.Rd @@ -55,7 +55,7 @@ library(parameters) model <- lm(Sepal.Length ~ Species * Petal.Width + Petal.Length, data = iris) head(simulate_model(model)) \donttest{ -if (require("glmmTMB")) { +if (require("glmmTMB", quietly = TRUE)) { model <- glmmTMB( count ~ spp + mined + (1 | site), ziformula = ~mined, diff --git a/man/skewness.Rd b/man/skewness.Rd index 1acf544a3..4d6374577 100644 --- a/man/skewness.Rd +++ b/man/skewness.Rd @@ -26,15 +26,21 @@ kurtosis(x, na.rm = TRUE, type = "2", iterations = NULL, ...) \item{na.rm}{Remove missing values.} -\item{type}{Type of algorithm for computing skewness. May be one of \code{1} (or \code{"1"}, \code{"I"} or \code{"classic"}), \code{2} (or \code{"2"}, \code{"II"} or \code{"SPSS"} or \code{"SAS"}) or \code{3} (or \code{"3"}, \code{"III"} or \code{"Minitab"}). See 'Details'.} +\item{type}{Type of algorithm for computing skewness. May be one of \code{1} +(or \code{"1"}, \code{"I"} or \code{"classic"}), \code{2} (or \code{"2"}, +\code{"II"} or \code{"SPSS"} or \code{"SAS"}) or \code{3} (or \code{"3"}, +\code{"III"} or \code{"Minitab"}). See 'Details'.} -\item{iterations}{The number of bootstrap replicates for computing standard errors. If \code{NULL} (default), parametric standard errors are computed. See 'Details'.} +\item{iterations}{The number of bootstrap replicates for computing standard +errors. If \code{NULL} (default), parametric standard errors are computed. +See 'Details'.} \item{...}{Arguments passed to or from other methods.} \item{digits}{Number of decimal places.} -\item{test}{Logical, if \code{TRUE}, tests if skewness or kurtosis is significantly different from zero.} +\item{test}{Logical, if \code{TRUE}, tests if skewness or kurtosis is +significantly different from zero.} \item{object}{An object returned by \code{skewness()} or \code{kurtosis()}.} } @@ -51,10 +57,12 @@ a negative skewness values indicates a "left-skewed" distribution, and a positive skewness values indicates a "right-skewed" distribution. Examples for the relationship of skewness and distributions are: \itemize{ - \item Normal distribution (and other symmetric distribution) has a skewness of 0 + \item Normal distribution (and other symmetric distribution) has a skewness + of 0 \item Half-normal distribution has a skewness just below 1 \item Exponential distribution has a skewness of 2 - \item Lognormal distribution can have a skewness of any positive value, depending on its parameters + \item Lognormal distribution can have a skewness of any positive value, + depending on its parameters } (\cite{https://en.wikipedia.org/wiki/Skewness}) } diff --git a/man/smoothness.Rd b/man/smoothness.Rd index f382e18e0..1bcabc66a 100644 --- a/man/smoothness.Rd +++ b/man/smoothness.Rd @@ -9,11 +9,15 @@ smoothness(x, method = "cor", lag = 1, iterations = NULL, ...) \arguments{ \item{x}{Numeric vector (similar to a time series).} -\item{method}{Can be "diff" (the standard deviation of the standardized differences) or "cor" (default, lag-one autocorrelation).} +\item{method}{Can be "diff" (the standard deviation of the standardized +differences) or "cor" (default, lag-one autocorrelation).} -\item{lag}{An integer indicating which lag to use. If less than 1, will be interpreted as expressed in percentage of the length of the vector.} +\item{lag}{An integer indicating which lag to use. If less than 1, will be +interpreted as expressed in percentage of the length of the vector.} -\item{iterations}{The number of bootstrap replicates for computing standard errors. If \code{NULL} (default), parametric standard errors are computed. See 'Details'.} +\item{iterations}{The number of bootstrap replicates for computing standard +errors. If \code{NULL} (default), parametric standard errors are computed. +See 'Details'.} \item{...}{Arguments passed to or from other methods.} } diff --git a/man/standard_error_robust.Rd b/man/standard_error_robust.Rd index 4d002bcd6..6f8912f5a 100644 --- a/man/standard_error_robust.Rd +++ b/man/standard_error_robust.Rd @@ -68,13 +68,13 @@ These functions rely on the \pkg{sandwich} or \pkg{clubSandwich} package and will thus only work for those models supported by those packages. } \examples{ -if (require("sandwich")) { +if (require("sandwich", quietly = TRUE)) { # robust standard errors, calling sandwich::vcovHC(type="HC3") by default model <- lm(Petal.Length ~ Sepal.Length * Species, data = iris) standard_error_robust(model) } \dontrun{ -if (require("clubSandwich")) { +if (require("clubSandwich", quietly = TRUE)) { # cluster-robust standard errors, using clubSandwich iris$cluster <- factor(rep(LETTERS[1:8], length.out = nrow(iris))) standard_error_robust( diff --git a/tests/testthat/test-GLMMadaptive.R b/tests/testthat/test-GLMMadaptive.R index 2752312c8..927ce2088 100644 --- a/tests/testthat/test-GLMMadaptive.R +++ b/tests/testthat/test-GLMMadaptive.R @@ -135,9 +135,9 @@ if (require("testthat") && data("Salamanders") model <- mixed_model( count ~ spp + mined, - random = ~DOY | site, - zi_fixed = ~spp + mined, - zi_random = ~DOP | site, + random = ~ DOY | site, + zi_fixed = ~ spp + mined, + zi_random = ~ DOP | site, family = zi.negative.binomial(), data = Salamanders, control = list(nAGQ = 1) @@ -148,17 +148,21 @@ if (require("testthat") && expect_equal(c(nrow(params), ncol(params)), c(8, 9)) expect_equal( colnames(params), - c("Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high","Effects", "Group", "Component") + c("Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high", "Effects", "Group", "Component") ) expect_equal( params$Parameter, - c("SD (Intercept)", "SD (DOY)", "Cor (Intercept~site)", "SD (Observations)", - "SD (Intercept)", "SD (DOP)", "Cor (Intercept~site)", "SD (Observations)") + c( + "SD (Intercept)", "SD (DOY)", "Cor (Intercept~site)", "SD (Observations)", + "SD (Intercept)", "SD (DOP)", "Cor (Intercept~site)", "SD (Observations)" + ) ) expect_equal( params$Component, - c("conditional", "conditional", "conditional", "conditional", - "zero_inflated", "zero_inflated", "zero_inflated", "zero_inflated") + c( + "conditional", "conditional", "conditional", "conditional", + "zero_inflated", "zero_inflated", "zero_inflated", "zero_inflated" + ) ) expect_equal( params$Coefficient, diff --git a/tests/testthat/test-glmmTMB.R b/tests/testthat/test-glmmTMB.R index d8b6dc05a..063451f65 100644 --- a/tests/testthat/test-glmmTMB.R +++ b/tests/testthat/test-glmmTMB.R @@ -208,7 +208,7 @@ if (.runThisTest) { expect_equal(c(nrow(params), ncol(params)), c(4, 9)) expect_equal( colnames(params), - c("Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high","Effects", "Group", "Component") + c("Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high", "Effects", "Group", "Component") ) expect_equal( params$Parameter, @@ -230,20 +230,26 @@ if (.runThisTest) { expect_equal(c(nrow(params), ncol(params)), c(10, 12)) expect_equal( colnames(params), - c("Parameter", "Coefficient", "SE", "CI", "CI_low", - "CI_high", "z", "df_error", "p", "Effects", "Group", "Component") + c( + "Parameter", "Coefficient", "SE", "CI", "CI_low", + "CI_high", "z", "df_error", "p", "Effects", "Group", "Component" + ) ) expect_equal( params$Parameter, - c("(Intercept)", "child", "camper1", "(Intercept)", "child", + c( + "(Intercept)", "child", "camper1", "(Intercept)", "child", "camper1", "SD (Intercept)", "SD (Observations)", "SD (Intercept)", - "SD (Observations)") + "SD (Observations)" + ) ) expect_equal( params$Component, - c("conditional", "conditional", "conditional", "zero_inflated", + c( + "conditional", "conditional", "conditional", "zero_inflated", "zero_inflated", "zero_inflated", "conditional", "conditional", - "zero_inflated", "zero_inflated") + "zero_inflated", "zero_inflated" + ) ) expect_equal( params$Coefficient, @@ -293,7 +299,7 @@ if (.runThisTest) { m4 <- suppressWarnings(glmmTMB( count ~ child + camper + (1 + xb | persons), - ziformula = ~ child + camper + (1 + zg| persons), + ziformula = ~ child + camper + (1 + zg | persons), data = fish, family = truncated_poisson() )) @@ -303,17 +309,21 @@ if (.runThisTest) { expect_equal(c(nrow(params), ncol(params)), c(8, 9)) expect_equal( colnames(params), - c("Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high","Effects", "Group", "Component") + c("Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high", "Effects", "Group", "Component") ) expect_equal( params$Parameter, - c("SD (Intercept)", "SD (xb)", "Cor (Intercept~persons)", "SD (Observations)", - "SD (Intercept)", "SD (zg)", "Cor (Intercept~persons)", "SD (Observations)") + c( + "SD (Intercept)", "SD (xb)", "Cor (Intercept~persons)", "SD (Observations)", + "SD (Intercept)", "SD (zg)", "Cor (Intercept~persons)", "SD (Observations)" + ) ) expect_equal( params$Component, - c("conditional", "conditional", "conditional", "conditional", - "zero_inflated", "zero_inflated", "zero_inflated", "zero_inflated") + c( + "conditional", "conditional", "conditional", "conditional", + "zero_inflated", "zero_inflated", "zero_inflated", "zero_inflated" + ) ) expect_equal( params$Coefficient, @@ -327,27 +337,35 @@ if (.runThisTest) { expect_equal(c(nrow(params), ncol(params)), c(14, 12)) expect_equal( colnames(params), - c("Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high", - "z", "df_error", "p", "Effects", "Group", "Component") + c( + "Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high", + "z", "df_error", "p", "Effects", "Group", "Component" + ) ) expect_equal( params$Parameter, - c("(Intercept)", "child", "camper1", "(Intercept)", "child", + c( + "(Intercept)", "child", "camper1", "(Intercept)", "child", "camper1", "SD (Intercept)", "SD (xb)", "Cor (Intercept~persons)", "SD (Observations)", "SD (Intercept)", "SD (zg)", "Cor (Intercept~persons)", - "SD (Observations)") + "SD (Observations)" + ) ) expect_equal( params$Component, - c("conditional", "conditional", "conditional", "zero_inflated", + c( + "conditional", "conditional", "conditional", "zero_inflated", "zero_inflated", "zero_inflated", "conditional", "conditional", "conditional", "conditional", "zero_inflated", "zero_inflated", - "zero_inflated", "zero_inflated") + "zero_inflated", "zero_inflated" + ) ) expect_equal( params$Coefficient, - c(2.54713, -1.08747, 0.2723, 1.88964, 0.15712, -0.17007, 3.40563, - 1.21316, -1, 1, 2.73583, 1.56833, 1, 1), + c( + 2.54713, -1.08747, 0.2723, 1.88964, 0.15712, -0.17007, 3.40563, + 1.21316, -1, 1, 2.73583, 1.56833, 1, 1 + ), tolerance = 1e-2 ) }) diff --git a/tests/testthat/test-model_parameters.mixed.R b/tests/testthat/test-model_parameters.mixed.R index 2d773f17f..6c7ba6247 100644 --- a/tests/testthat/test-model_parameters.mixed.R +++ b/tests/testthat/test-model_parameters.mixed.R @@ -25,8 +25,10 @@ if (.runThisTest && params <- model_parameters(model) cs <- coef(summary(model)) expect_equal(c(nrow(params), ncol(params)), c(3, 10)) - expect_equal(colnames(params), c("Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high", - "z", "df_error", "p", "Effects")) + expect_equal(colnames(params), c( + "Parameter", "Coefficient", "SE", "CI", "CI_low", "CI_high", + "z", "df_error", "p", "Effects" + )) expect_equal(params$Parameter, rownames(cs)) # TODO: Not sure how to deal with bootstrapped mixed models... As it throws an unreasonable amount of singular fits... diff --git a/tests/testthat/test-model_parameters_std_mixed.R b/tests/testthat/test-model_parameters_std_mixed.R index 6dbe12bed..c156eb98a 100644 --- a/tests/testthat/test-model_parameters_std_mixed.R +++ b/tests/testthat/test-model_parameters_std_mixed.R @@ -25,7 +25,7 @@ if (.runThisTest) { test_that("model_parameters, standardize-posthoc", { params <- model_parameters(model, standardize = "posthoc") - expect_equal(c(nrow(params), ncol(params)), c(7,10)) + expect_equal(c(nrow(params), ncol(params)), c(7, 10)) expect_equal(params$Std_Coefficient, c(0, 0.49679, -0.49355, 0.34791, 1.74252, -0.25421, -0.18834), tolerance = 1e-3) expect_equal(params$SE, c(0, 0.66228, 0.70202, 0.05968, 0.13914, 0.09762, 0.0945), tolerance = 1e-3) expect_equal(params$CI_high, c(0, 1.79483, 0.88238, 0.46488, 2.01523, -0.06287, -0.00312), tolerance = 1e-3) diff --git a/tests/testthat/test-panelr.R b/tests/testthat/test-panelr.R index 70b20febb..f20c6ba94 100644 --- a/tests/testthat/test-panelr.R +++ b/tests/testthat/test-panelr.R @@ -1,9 +1,9 @@ .runThisTest <- Sys.getenv("RunAllparametersTests") == "yes" if (.runThisTest && - require("testthat") && - require("parameters") && - require("panelr")) { + require("testthat") && + require("parameters") && + require("panelr")) { data("WageData") wages <- panel_data(WageData, id = id, wave = t) m1 <- wbm(lwage ~ lag(union) + wks | blk + fem | blk * lag(union), data = wages) diff --git a/tests/testthat/test-pca.R b/tests/testthat/test-pca.R index 056ed08af..9f2f9c276 100644 --- a/tests/testthat/test-pca.R +++ b/tests/testthat/test-pca.R @@ -48,6 +48,7 @@ if (require("testthat") && require("parameters") && require("psych") && require( # predict ---------------------- + # N.B tests will fail if `GPArotation` package is not installed data(bfi) d <- na.omit(bfi[, 1:25])