From 700067beeaaf53221a07f060a1cd00e206e752e4 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 16 Sep 2023 16:29:28 +0200 Subject: [PATCH] CRAN submission 0.21.2 (#903) * CRAN submission 0.21.2 * styler * styler * lintr * lintr * clean up description * skip test on R < 4.2 * examplesIf * fix test * fix test * examplesIf * fix issues * revert * linte * update cran comments * update gitiognore * remove revdep * submitted --- .gitignore | 1 + CRAN-SUBMISSION | 6 +- DESCRIPTION | 5 +- NEWS.md | 2 +- R/1_model_parameters.R | 34 ++++---- R/2_ci.R | 21 +++-- R/bootstrap_model.R | 16 ++-- R/bootstrap_parameters.R | 18 ++--- R/cluster_discrimination.R | 12 ++- R/cluster_performance.R | 10 +-- R/convert_efa_to_cfa.R | 33 ++++---- R/display.R | 2 +- R/dominance_analysis.R | 32 ++++---- R/format.R | 6 +- R/n_factors.R | 7 +- R/principal_components.R | 8 ++ R/print.parameters_model.R | 10 +-- R/print_html.R | 4 +- R/print_md.R | 4 +- R/reduce_parameters.R | 4 +- R/utils_format.R | 16 ++-- cran-comments.md | 2 +- man/bootstrap_model.Rd | 16 ++-- man/bootstrap_parameters.Rd | 18 ++--- man/ci.default.Rd | 21 ++--- man/cluster_discrimination.Rd | 12 +-- man/cluster_performance.Rd | 10 +-- man/convert_efa_to_cfa.Rd | 27 +++---- man/display.parameters_model.Rd | 10 +-- man/dominance_analysis.Rd | 32 ++++---- man/model_parameters.default.Rd | 34 ++++---- man/print.parameters_model.Rd | 4 +- tests/testthat/test-model_parameters.anova.R | 77 ++++++++++--------- .../testthat/test-printing_reference_level.R | 10 +-- tests/testthat/test-quantreg.R | 3 +- 35 files changed, 255 insertions(+), 272 deletions(-) diff --git a/.gitignore b/.gitignore index 10dcfe05d..ded75a1d6 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ # Output files from R CMD check /*.Rcheck/ +revdep/ # RStudio files .Rproj.user/ diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index b8b2c021f..be214bfbb 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ -Version: 0.21.1 -Date: 2023-05-26 09:34:52 UTC -SHA: 7ad4819088d188babebe5de6880d1230782b32ec +Version: 0.21.2 +Date: 2023-09-16 12:58:15 UTC +SHA: a1a80b72020f0287b81563a419eddb36f59fa18d diff --git a/DESCRIPTION b/DESCRIPTION index b5a22cec2..d77d1950d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: parameters Title: Processing of Model Parameters -Version: 0.21.1.9 +Version: 0.21.2 Authors@R: c(person(given = "Daniel", family = "Lüdecke", @@ -81,7 +81,7 @@ Depends: Imports: bayestestR (>= 0.13.0), datawizard (>= 0.7.0), - insight (>= 0.19.3.2), + insight (>= 0.19.4), graphics, methods, stats, @@ -213,4 +213,3 @@ Config/Needs/website: r-lib/pkgdown, easystats/easystatstemplate Config/rcmdcheck/ignore-inconsequential-notes: true -Remotes: easystats/insight diff --git a/NEWS.md b/NEWS.md index e7e71641c..c52c21fde 100644 --- a/NEWS.md +++ b/NEWS.md @@ -11,7 +11,7 @@ accepts the `exponentiate` argument. * The `print()`, `print_html()`, `print_md()` and `format()` methods for - `model_parameters()` get an `add_reference` argument, to add the reference + `model_parameters()` get an `include_reference` argument, to add the reference category of categorical predictors to the parameters table. ## Bug fixes diff --git a/R/1_model_parameters.R b/R/1_model_parameters.R index cd73dc40b..160de9f1c 100644 --- a/R/1_model_parameters.R +++ b/R/1_model_parameters.R @@ -418,29 +418,25 @@ parameters <- model_parameters #' #' @inheritSection model_parameters Confidence intervals and approximation of degrees of freedom #' -#' @examples +#' @examplesIf require("boot", quietly = TRUE) && require("sandwich") && require("clubSandwich") && require("brglm2") #' library(parameters) #' model <- lm(mpg ~ wt + cyl, data = mtcars) #' #' model_parameters(model) #' #' # bootstrapped parameters -#' if (require("boot", quietly = TRUE)) { -#' model_parameters(model, bootstrap = TRUE) -#' } +#' model_parameters(model, bootstrap = TRUE) #' #' # standardized parameters #' model_parameters(model, standardize = "refit") #' #' # robust, heteroskedasticity-consistent standard errors -#' if (require("sandwich") && require("clubSandwich")) { -#' model_parameters(model, vcov = "HC3") +#' model_parameters(model, vcov = "HC3") #' -#' model_parameters(model, -#' vcov = "vcovCL", -#' vcov_args = list(cluster = mtcars$cyl) -#' ) -#' } +#' model_parameters(model, +#' vcov = "vcovCL", +#' vcov_args = list(cluster = mtcars$cyl) +#' ) #' #' # different p-value style in output #' model_parameters(model, p_digits = 5) @@ -454,15 +450,13 @@ parameters <- model_parameters #' model_parameters(model, exponentiate = TRUE) #' #' # bias-corrected logistic regression with penalized maximum likelihood -#' if (require("brglm2")) { -#' model <- glm( -#' vs ~ wt + cyl, -#' data = mtcars, -#' family = "binomial", -#' method = "brglmFit" -#' ) -#' model_parameters(model) -#' } +#' model <- glm( +#' vs ~ wt + cyl, +#' data = mtcars, +#' family = "binomial", +#' method = "brglmFit" +#' ) +#' model_parameters(model) #' } #' @return A data frame of indices related to the model's parameters. #' @export diff --git a/R/2_ci.R b/R/2_ci.R index 94dd1a278..df2b3b966 100644 --- a/R/2_ci.R +++ b/R/2_ci.R @@ -31,20 +31,19 @@ #' #' @inheritSection model_parameters Confidence intervals and approximation of degrees of freedom #' -#' @examples +#' @examplesIf require("glmmTMB") #' \donttest{ #' library(parameters) -#' if (require("glmmTMB")) { -#' model <- glmmTMB( -#' count ~ spp + mined + (1 | site), -#' ziformula = ~mined, -#' family = poisson(), -#' data = Salamanders -#' ) +#' data(Salamanders, package = "glmmTMB") +#' model <- glmmTMB::glmmTMB( +#' count ~ spp + mined + (1 | site), +#' ziformula = ~mined, +#' family = poisson(), +#' data = Salamanders +#' ) #' -#' ci(model) -#' ci(model, component = "zi") -#' } +#' ci(model) +#' ci(model, component = "zi") #' } #' @export ci.default <- function(x, ci = 0.95, dof = NULL, method = NULL, ...) { diff --git a/R/bootstrap_model.R b/R/bootstrap_model.R index a4c03d160..2f53c2895 100644 --- a/R/bootstrap_model.R +++ b/R/bootstrap_model.R @@ -40,18 +40,14 @@ #' #' @seealso [`bootstrap_parameters()`], [`simulate_model()`], [`simulate_parameters()`] #' -#' @examples +#' @examplesIf require("boot", quietly = TRUE) && require("emmeans", quietly = TRUE) #' \dontrun{ -#' if (require("boot", quietly = TRUE)) { -#' model <- lm(mpg ~ wt + factor(cyl), data = mtcars) -#' b <- bootstrap_model(model) -#' print(head(b)) +#' model <- lm(mpg ~ wt + factor(cyl), data = mtcars) +#' b <- bootstrap_model(model) +#' print(head(b)) #' -#' if (require("emmeans", quietly = TRUE)) { -#' est <- emmeans(b, consec ~ cyl) -#' print(model_parameters(est)) -#' } -#' } +#' est <- emmeans::emmeans(b, consec ~ cyl) +#' print(model_parameters(est)) #' } #' @export bootstrap_model <- function(model, diff --git a/R/bootstrap_parameters.R b/R/bootstrap_parameters.R index 851f157e6..c02b1a627 100644 --- a/R/bootstrap_parameters.R +++ b/R/bootstrap_parameters.R @@ -33,19 +33,15 @@ #' p-values can be biased, and it is suggested to use proper permutation tests #' to obtain non-parametric p-values. #' -#' @examples +#' @examplesIf require("boot", quietly = TRUE) && require("emmeans", quietly = TRUE) #' \dontrun{ -#' if (require("boot", quietly = TRUE)) { -#' set.seed(2) -#' model <- lm(Sepal.Length ~ Species * Petal.Width, data = iris) -#' b <- bootstrap_parameters(model) -#' print(b) +#' set.seed(2) +#' model <- lm(Sepal.Length ~ Species * Petal.Width, data = iris) +#' b <- bootstrap_parameters(model) +#' print(b) #' -#' if (require("emmeans")) { -#' est <- emmeans(b, trt.vs.ctrl ~ Species) -#' print(model_parameters(est)) -#' } -#' } +#' est <- emmeans::emmeans(b, trt.vs.ctrl ~ Species) +#' print(model_parameters(est)) #' } #' @export bootstrap_parameters <- function(model, diff --git a/R/cluster_discrimination.R b/R/cluster_discrimination.R index e8cd5ccbd..9e0265199 100644 --- a/R/cluster_discrimination.R +++ b/R/cluster_discrimination.R @@ -14,14 +14,12 @@ #' [`performance::check_clusterstructure()`] to check suitability of data for #' clustering. #' -#' @examples -#' if (requireNamespace("MASS", quietly = TRUE)) { -#' # Retrieve group classification from hierarchical cluster analysis -#' clustering <- cluster_analysis(iris[, 1:4], n = 3) +#' @examplesIf requireNamespace("MASS", quietly = TRUE) +#' # Retrieve group classification from hierarchical cluster analysis +#' clustering <- cluster_analysis(iris[, 1:4], n = 3) #' -#' # Goodness of group classification -#' cluster_discrimination(clustering) -#' } +#' # Goodness of group classification +#' cluster_discrimination(clustering) #' @export cluster_discrimination <- function(x, cluster_groups = NULL, ...) { UseMethod("cluster_discrimination") diff --git a/R/cluster_performance.R b/R/cluster_performance.R index 3752fc85e..9c7f506db 100644 --- a/R/cluster_performance.R +++ b/R/cluster_performance.R @@ -61,14 +61,12 @@ cluster_performance.hclust <- function(model, data, clusters, ...) { #' @rdname cluster_performance -#' @examples +#' @examplesIf require("dbscan", quietly = TRUE) #' # DBSCAN -#' if (require("dbscan", quietly = TRUE)) { -#' model <- dbscan::dbscan(iris[1:4], eps = 1.45, minPts = 10) +#' model <- dbscan::dbscan(iris[1:4], eps = 1.45, minPts = 10) #' -#' rez <- cluster_performance(model, iris[1:4]) -#' rez -#' } +#' rez <- cluster_performance(model, iris[1:4]) +#' rez #' @export cluster_performance.dbscan <- function(model, data, ...) { if (is.null(data)) { diff --git a/R/convert_efa_to_cfa.R b/R/convert_efa_to_cfa.R index 6d79fa5d9..739144bee 100644 --- a/R/convert_efa_to_cfa.R +++ b/R/convert_efa_to_cfa.R @@ -8,22 +8,21 @@ #' @param max_per_dimension Maximum number of variables to keep per dimension. #' @inheritParams principal_components #' -#' @examples +#' @examplesIf require("psych") && require("lavaan") #' \donttest{ #' library(parameters) -#' if (require("psych") && require("lavaan")) { -#' efa <- psych::fa(attitude, nfactors = 3) +#' data(attitude) +#' efa <- psych::fa(attitude, nfactors = 3) #' -#' model1 <- efa_to_cfa(efa) -#' model2 <- efa_to_cfa(efa, threshold = 0.3) -#' model3 <- efa_to_cfa(efa, max_per_dimension = 2) +#' model1 <- efa_to_cfa(efa) +#' model2 <- efa_to_cfa(efa, threshold = 0.3) +#' model3 <- efa_to_cfa(efa, max_per_dimension = 2) #' -#' suppressWarnings(anova( -#' lavaan::cfa(model1, data = attitude), -#' lavaan::cfa(model2, data = attitude), -#' lavaan::cfa(model3, data = attitude) -#' )) -#' } +#' suppressWarnings(anova( +#' lavaan::cfa(model1, data = attitude), +#' lavaan::cfa(model2, data = attitude), +#' lavaan::cfa(model3, data = attitude) +#' )) #' } #' @return Converted index. #' @export @@ -42,9 +41,10 @@ convert_efa_to_cfa.fa <- function(model, max_per_dimension = NULL, ...) { .efa_to_cfa(model_parameters(model, threshold = threshold, ...), - names = names, - max_per_dimension = max_per_dimension, - ...) + names = names, + max_per_dimension = max_per_dimension, + ... + ) } #' @export @@ -78,7 +78,7 @@ efa_to_cfa <- convert_efa_to_cfa #' @keywords internal -.efa_to_cfa <- function(loadings, names = NULL, max_per_dimension=NULL, ...) { +.efa_to_cfa <- function(loadings, names = NULL, max_per_dimension = NULL, ...) { loadings <- attributes(loadings)$loadings_long # Get dimension names @@ -100,7 +100,6 @@ efa_to_cfa <- convert_efa_to_cfa cfa <- NULL # Iterate over dimensions for (i in seq_along(names)) { - # Find correct subset items <- loadings[loadings$Component == unique(loadings$Component)[i], ] diff --git a/R/display.R b/R/display.R index e9549821a..036d28154 100644 --- a/R/display.R +++ b/R/display.R @@ -91,7 +91,7 @@ display.parameters_model <- function(object, font_size = "100%", line_padding = 4, column_labels = NULL, - add_reference = FALSE, + include_reference = FALSE, verbose = TRUE, ...) { if (identical(format, "html")) { diff --git a/R/dominance_analysis.R b/R/dominance_analysis.R index 98e83914d..90d991ecb 100644 --- a/R/dominance_analysis.R +++ b/R/dominance_analysis.R @@ -31,9 +31,9 @@ #' @param contrasts A named list of [`contrasts`] used by the model object. #' This list is required in order for the correct mapping of parameters to #' predictors in the output when the model creates indicator codes for factor -#' variables using [`model_matrix`]. By default, the `contrast` element from -#' the model object submitted is used. If the model object does not have a -#' `contrast` element the user can supply this named list. +#' variables using [`insight::get_modelmatrix()`]. By default, the `contrast` +#' element from the model object submitted is used. If the model object does +#' not have a `contrast` element the user can supply this named list. #' #' @param ... Not used at current. #' @@ -115,24 +115,22 @@ #' #' @author Joseph Luchman #' -#' @examples -#' if (require("domir") && require("performance")) { -#' data(mtcars) +#' @examplesIf require("domir") && require("performance") +#' data(mtcars) #' -#' # Dominance Analysis with Logit Regression -#' model <- glm(vs ~ cyl + carb + mpg, data = mtcars, family = binomial()) +#' # Dominance Analysis with Logit Regression +#' model <- glm(vs ~ cyl + carb + mpg, data = mtcars, family = binomial()) #' -#' performance::r2(model) -#' dominance_analysis(model) +#' performance::r2(model) +#' dominance_analysis(model) #' -#' # Dominance Analysis with Weighted Logit Regression -#' model_wt <- glm(vs ~ cyl + carb + mpg, -#' data = mtcars, -#' weights = wt, family = quasibinomial() -#' ) +#' # Dominance Analysis with Weighted Logit Regression +#' model_wt <- glm(vs ~ cyl + carb + mpg, +#' data = mtcars, +#' weights = wt, family = quasibinomial() +#' ) #' -#' dominance_analysis(model_wt, quote_args = "weights") -#' } +#' dominance_analysis(model_wt, quote_args = "weights") #' @export dominance_analysis <- function(model, sets = NULL, all = NULL, conditional = TRUE, complete = TRUE, diff --git a/R/format.R b/R/format.R index d006b6447..5c09ca3d0 100644 --- a/R/format.R +++ b/R/format.R @@ -15,7 +15,7 @@ format.parameters_model <- function(x, zap_small = FALSE, format = NULL, groups = NULL, - add_reference = FALSE, + include_reference = FALSE, ...) { # save attributes coef_name <- attributes(x)$coefficient_name @@ -168,7 +168,7 @@ format.parameters_model <- function(x, ci_width = ci_width, ci_brackets = ci_brackets, zap_small = zap_small, - add_reference = add_reference, + include_reference = include_reference, ... ) } else { @@ -185,7 +185,7 @@ format.parameters_model <- function(x, format = format, coef_name = coef_name, zap_small = zap_small, - add_reference = add_reference, + include_reference = include_reference, ... ) } diff --git a/R/n_factors.R b/R/n_factors.R index 342fe7398..8d4d1261e 100644 --- a/R/n_factors.R +++ b/R/n_factors.R @@ -124,7 +124,9 @@ n_factors <- function(x, } # Get number of observations - if (!is.data.frame(x)) { + if (is.data.frame(x)) { + nobs <- nrow(x) + } else { if (is.numeric(x) && !is.null(cor)) { nobs <- x package <- package[!package %in% c("pcdimension", "PCDimension")] @@ -133,8 +135,6 @@ n_factors <- function(x, "Please input the correlation matrix via the `cor` argument and the number of rows / observations via the first argument." ) } - } else { - nobs <- nrow(x) } # Get only numeric @@ -577,7 +577,6 @@ print.n_clusters <- print.n_factors cor = NULL, nobs = NULL, type = "FA") { - # Altnerative version of parralel analysis # Not used because already included in nFactors diff --git a/R/principal_components.R b/R/principal_components.R index 4245332a0..371befa30 100644 --- a/R/principal_components.R +++ b/R/principal_components.R @@ -420,6 +420,14 @@ principal_components.data.frame <- function(x, } else if (n >= ncol(x)) { n <- ncol(x) - 1 } + + ## TODO: the next if-statement was removed by Dom, but this breaks + ## performance code. Need to check, so we for now add this back + + # sanity check - we need at least two factors + if (n < 2 && ncol(x) >= 2) { + n <- 2 + } n } diff --git a/R/print.parameters_model.R b/R/print.parameters_model.R index debe8dd20..95910b731 100644 --- a/R/print.parameters_model.R +++ b/R/print.parameters_model.R @@ -87,7 +87,7 @@ #' labels will be used as parameters names. The latter only works for "labelled" #' data, i.e. if the data used to fit the model had `"label"` and `"labels"` #' attributes. See also section _Global Options to Customize Messages when Printing_. -#' @param add_reference Logical, if `TRUE`, the reference level of factors will +#' @param include_reference Logical, if `TRUE`, the reference level of factors will #' be added to the parameters table. This is only relevant for models with #' categorical predictors. The coefficient for the reference level is always #' `0` (except when `exponentiate = TRUE`, then the coefficient will be `1`), @@ -238,7 +238,7 @@ print.parameters_model <- function(x, groups = NULL, column_width = NULL, ci_brackets = c("[", "]"), - add_reference = FALSE, + include_reference = FALSE, ...) { # save original input orig_x <- x @@ -288,7 +288,7 @@ print.parameters_model <- function(x, ci_brackets = ci_brackets, format = "text", groups = groups, - add_reference = add_reference, + include_reference = include_reference, ... ) @@ -385,7 +385,7 @@ print.parameters_random <- function(x, digits = 2, ...) { ci_brackets = TRUE, format = "text", group = NULL, - add_reference = FALSE, + include_reference = FALSE, ...) { format( x, @@ -400,7 +400,7 @@ print.parameters_random <- function(x, digits = 2, ...) { zap_small = zap_small, format = format, group = group, - add_reference = add_reference, + include_reference = include_reference, ... ) } diff --git a/R/print_html.R b/R/print_html.R index 5be9f9b98..42bae3da7 100644 --- a/R/print_html.R +++ b/R/print_html.R @@ -22,7 +22,7 @@ print_html.parameters_model <- function(x, font_size = "100%", line_padding = 4, column_labels = NULL, - add_reference = FALSE, + include_reference = FALSE, verbose = TRUE, ...) { # check if user supplied digits attributes @@ -83,7 +83,7 @@ print_html.parameters_model <- function(x, ci_brackets = ci_brackets, format = "html", groups = groups, - add_reference = add_reference, + include_reference = include_reference, ... ) diff --git a/R/print_md.R b/R/print_md.R index d95e7fe58..264a42bef 100644 --- a/R/print_md.R +++ b/R/print_md.R @@ -19,7 +19,7 @@ print_md.parameters_model <- function(x, show_formula = FALSE, zap_small = FALSE, groups = NULL, - add_reference = FALSE, + include_reference = FALSE, verbose = TRUE, ...) { # check if user supplied digits attributes @@ -67,7 +67,7 @@ print_md.parameters_model <- function(x, ci_brackets = ci_brackets, format = "markdown", groups = groups, - add_reference = add_reference, + include_reference = include_reference, ... ) diff --git a/R/reduce_parameters.R b/R/reduce_parameters.R index e4827b65a..331b44f55 100644 --- a/R/reduce_parameters.R +++ b/R/reduce_parameters.R @@ -204,7 +204,9 @@ principal_components.merMod <- principal_components.lm insight::check_if_installed("DRR") - junk <- utils::capture.output(suppressMessages(rez <- DRR::drr(x, n))) + junk <- utils::capture.output(suppressMessages({ + rez <- DRR::drr(x, n) + })) features <- as.data.frame(rez$fitted.data) names(features) <- paste0("DRR", seq_len(ncol(features))) diff --git a/R/utils_format.R b/R/utils_format.R index 144f139ab..11dc10983 100644 --- a/R/utils_format.R +++ b/R/utils_format.R @@ -280,7 +280,7 @@ format = NULL, coef_name = NULL, zap_small = FALSE, - add_reference = FALSE, + include_reference = FALSE, ...) { # default brackets are parenthesis for HTML / MD if ((is.null(ci_brackets) || isTRUE(ci_brackets)) && (identical(format, "html") || identical(format, "markdown"))) { @@ -310,7 +310,7 @@ } # add the coefficient for the base-(reference)-level of factors? - if (add_reference) { + if (include_reference) { x <- .add_reference_level(x) } @@ -851,7 +851,7 @@ ci_width = "auto", ci_brackets = TRUE, zap_small = FALSE, - add_reference = FALSE, + include_reference = FALSE, ...) { final_table <- list() @@ -927,7 +927,7 @@ tables <- split(x, f = split_by) # sanity check - only preserve tables with any data in data frames - tables <- tables[sapply(tables, nrow) > 0] + tables <- tables[vapply(tables, nrow, numeric(1)) > 0] # fix table names for random effects, when we only have random @@ -993,10 +993,10 @@ # if (all(is.na(tables[[type]]$CI_high))) tables[[type]]$CI_high <- NULL # Don't print if empty col - tables[[type]][sapply(colnames(tables[[type]]), function(x) { + tables[[type]][vapply(colnames(tables[[type]]), function(x) { col <- tables[[type]][[x]] (all(col == "") | all(is.na(col))) && !grepl("_CI_(high|low)$", x) - })] <- NULL + }, logical(1))] <- NULL attr(tables[[type]], "digits") <- digits attr(tables[[type]], "ci_digits") <- ci_digits @@ -1052,7 +1052,7 @@ } # add the coefficient for the base-(reference)-level of factors? - if (add_reference) { + if (include_reference) { tables[[type]] <- .add_reference_level(tables[[type]]) } @@ -1151,7 +1151,7 @@ } # then check for correct column length - col_len <- sapply(final_table, function(i) length(colnames(i))) + col_len <- vapply(final_table, function(i) length(colnames(i)), numeric(1)) # remove non matching columns if (!all(col_len) == max(col_len)) { diff --git a/cran-comments.md b/cran-comments.md index 249895727..54662aff3 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,4 +1,4 @@ -Regular update. +Maintainance release. ## revdepcheck results diff --git a/man/bootstrap_model.Rd b/man/bootstrap_model.Rd index b538af287..39c329979 100644 --- a/man/bootstrap_model.Rd +++ b/man/bootstrap_model.Rd @@ -81,18 +81,16 @@ 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} \dontrun{ -if (require("boot", quietly = TRUE)) { - model <- lm(mpg ~ wt + factor(cyl), data = mtcars) - b <- bootstrap_model(model) - print(head(b)) +model <- lm(mpg ~ wt + factor(cyl), data = mtcars) +b <- bootstrap_model(model) +print(head(b)) - if (require("emmeans", quietly = TRUE)) { - est <- emmeans(b, consec ~ cyl) - print(model_parameters(est)) - } -} +est <- emmeans::emmeans(b, consec ~ cyl) +print(model_parameters(est)) } +\dontshow{\}) # examplesIf} } \seealso{ \code{\link[=bootstrap_parameters]{bootstrap_parameters()}}, \code{\link[=simulate_model]{simulate_model()}}, \code{\link[=simulate_parameters]{simulate_parameters()}} diff --git a/man/bootstrap_parameters.Rd b/man/bootstrap_parameters.Rd index 26e7d6ccf..1041eb8ac 100644 --- a/man/bootstrap_parameters.Rd +++ b/man/bootstrap_parameters.Rd @@ -76,19 +76,17 @@ 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} \dontrun{ -if (require("boot", quietly = TRUE)) { - set.seed(2) - model <- lm(Sepal.Length ~ Species * Petal.Width, data = iris) - b <- bootstrap_parameters(model) - print(b) +set.seed(2) +model <- lm(Sepal.Length ~ Species * Petal.Width, data = iris) +b <- bootstrap_parameters(model) +print(b) - if (require("emmeans")) { - est <- emmeans(b, trt.vs.ctrl ~ Species) - print(model_parameters(est)) - } -} +est <- emmeans::emmeans(b, trt.vs.ctrl ~ Species) +print(model_parameters(est)) } +\dontshow{\}) # examplesIf} } \references{ Davison, A. C., & Hinkley, D. V. (1997). Bootstrap methods and their diff --git a/man/ci.default.Rd b/man/ci.default.Rd index ed0a161d8..57ffe3539 100644 --- a/man/ci.default.Rd +++ b/man/ci.default.Rd @@ -225,18 +225,19 @@ which is converted into a p-value using \code{\link[bayestestR:pd_to_p]{bayestes } \examples{ +\dontshow{if (require("glmmTMB")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} \donttest{ library(parameters) -if (require("glmmTMB")) { - model <- glmmTMB( - count ~ spp + mined + (1 | site), - ziformula = ~mined, - family = poisson(), - data = Salamanders - ) +data(Salamanders, package = "glmmTMB") +model <- glmmTMB::glmmTMB( + count ~ spp + mined + (1 | site), + ziformula = ~mined, + family = poisson(), + data = Salamanders +) - ci(model) - ci(model, component = "zi") -} +ci(model) +ci(model, component = "zi") } +\dontshow{\}) # examplesIf} } diff --git a/man/cluster_discrimination.Rd b/man/cluster_discrimination.Rd index 6d0d1392f..161dd9dd2 100644 --- a/man/cluster_discrimination.Rd +++ b/man/cluster_discrimination.Rd @@ -20,13 +20,13 @@ determines the goodness of classification for each cluster group. See \code{MASS for details. } \examples{ -if (requireNamespace("MASS", quietly = TRUE)) { - # Retrieve group classification from hierarchical cluster analysis - clustering <- cluster_analysis(iris[, 1:4], n = 3) +\dontshow{if (requireNamespace("MASS", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +# Retrieve group classification from hierarchical cluster analysis +clustering <- cluster_analysis(iris[, 1:4], n = 3) - # Goodness of group classification - cluster_discrimination(clustering) -} +# Goodness of group classification +cluster_discrimination(clustering) +\dontshow{\}) # examplesIf} } \seealso{ \code{\link[=n_clusters]{n_clusters()}} to determine the number of clusters to extract, diff --git a/man/cluster_performance.Rd b/man/cluster_performance.Rd index 1ad7f2f3c..90e3ff15c 100644 --- a/man/cluster_performance.Rd +++ b/man/cluster_performance.Rd @@ -41,13 +41,13 @@ clusters <- cutree(model, 3) rez <- cluster_performance(model, data, clusters) rez +\dontshow{if (require("dbscan", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} # DBSCAN -if (require("dbscan", quietly = TRUE)) { - model <- dbscan::dbscan(iris[1:4], eps = 1.45, minPts = 10) +model <- dbscan::dbscan(iris[1:4], eps = 1.45, minPts = 10) - rez <- cluster_performance(model, iris[1:4]) - rez -} +rez <- cluster_performance(model, iris[1:4]) +rez +\dontshow{\}) # examplesIf} # Retrieve performance from parameters params <- model_parameters(kmeans(iris[1:4], 3)) cluster_performance(params) diff --git a/man/convert_efa_to_cfa.Rd b/man/convert_efa_to_cfa.Rd index bdaa4c51e..57871b866 100644 --- a/man/convert_efa_to_cfa.Rd +++ b/man/convert_efa_to_cfa.Rd @@ -41,20 +41,21 @@ 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} \donttest{ library(parameters) -if (require("psych") && require("lavaan")) { - efa <- psych::fa(attitude, nfactors = 3) - - model1 <- efa_to_cfa(efa) - model2 <- efa_to_cfa(efa, threshold = 0.3) - model3 <- efa_to_cfa(efa, max_per_dimension = 2) - - suppressWarnings(anova( - lavaan::cfa(model1, data = attitude), - lavaan::cfa(model2, data = attitude), - lavaan::cfa(model3, data = attitude) - )) -} +data(attitude) +efa <- psych::fa(attitude, nfactors = 3) + +model1 <- efa_to_cfa(efa) +model2 <- efa_to_cfa(efa, threshold = 0.3) +model3 <- efa_to_cfa(efa, max_per_dimension = 2) + +suppressWarnings(anova( + lavaan::cfa(model1, data = attitude), + lavaan::cfa(model2, data = attitude), + lavaan::cfa(model3, data = attitude) +)) } +\dontshow{\}) # examplesIf} } diff --git a/man/display.parameters_model.Rd b/man/display.parameters_model.Rd index 263fe680a..a94a13408 100644 --- a/man/display.parameters_model.Rd +++ b/man/display.parameters_model.Rd @@ -33,7 +33,7 @@ font_size = "100\%", line_padding = 4, column_labels = NULL, - add_reference = FALSE, + include_reference = FALSE, verbose = TRUE, ... ) @@ -75,7 +75,7 @@ zap_small = FALSE, format = NULL, groups = NULL, - add_reference = FALSE, + include_reference = FALSE, ... ) @@ -100,7 +100,7 @@ font_size = "100\%", line_padding = 4, column_labels = NULL, - add_reference = FALSE, + include_reference = FALSE, verbose = TRUE, ... ) @@ -123,7 +123,7 @@ show_formula = FALSE, zap_small = FALSE, groups = NULL, - add_reference = FALSE, + include_reference = FALSE, verbose = TRUE, ... ) @@ -236,7 +236,7 @@ places than \code{digits} are printed in scientific notation.} \item{column_labels}{Labels of columns for HTML tables. If \code{NULL}, automatic column names are generated. See 'Examples'.} -\item{add_reference}{Logical, if \code{TRUE}, the reference level of factors will +\item{include_reference}{Logical, if \code{TRUE}, the reference level of factors will be added to the parameters table. This is only relevant for models with categorical predictors. The coefficient for the reference level is always \code{0} (except when \code{exponentiate = TRUE}, then the coefficient will be \code{1}), diff --git a/man/dominance_analysis.Rd b/man/dominance_analysis.Rd index 70a1473b4..18732f606 100644 --- a/man/dominance_analysis.Rd +++ b/man/dominance_analysis.Rd @@ -51,9 +51,9 @@ from being evaluated before being applied to the model and causing an error.} \item{contrasts}{A named list of \code{\link{contrasts}} used by the model object. This list is required in order for the correct mapping of parameters to predictors in the output when the model creates indicator codes for factor -variables using \code{\link{model_matrix}}. By default, the \code{contrast} element from -the model object submitted is used. If the model object does not have a -\code{contrast} element the user can supply this named list.} +variables using \code{\link[insight:get_modelmatrix]{insight::get_modelmatrix()}}. By default, the \code{contrast} +element from the model object submitted is used. If the model object does +not have a \code{contrast} element the user can supply this named list.} \item{...}{Not used at current.} } @@ -124,23 +124,23 @@ When \code{performance::r2()} returns multiple values, only the first is used by default. } \examples{ -if (require("domir") && require("performance")) { - data(mtcars) +\dontshow{if (require("domir") && require("performance")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +data(mtcars) - # Dominance Analysis with Logit Regression - model <- glm(vs ~ cyl + carb + mpg, data = mtcars, family = binomial()) +# Dominance Analysis with Logit Regression +model <- glm(vs ~ cyl + carb + mpg, data = mtcars, family = binomial()) - performance::r2(model) - dominance_analysis(model) +performance::r2(model) +dominance_analysis(model) - # Dominance Analysis with Weighted Logit Regression - model_wt <- glm(vs ~ cyl + carb + mpg, - data = mtcars, - weights = wt, family = quasibinomial() - ) +# Dominance Analysis with Weighted Logit Regression +model_wt <- glm(vs ~ cyl + carb + mpg, + data = mtcars, + weights = wt, family = quasibinomial() +) - dominance_analysis(model_wt, quote_args = "weights") -} +dominance_analysis(model_wt, quote_args = "weights") +\dontshow{\}) # examplesIf} } \references{ \itemize{ diff --git a/man/model_parameters.default.Rd b/man/model_parameters.default.Rd index 43dbc0039..7684b34a1 100644 --- a/man/model_parameters.default.Rd +++ b/man/model_parameters.default.Rd @@ -390,28 +390,25 @@ 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} library(parameters) model <- lm(mpg ~ wt + cyl, data = mtcars) model_parameters(model) # bootstrapped parameters -if (require("boot", quietly = TRUE)) { - model_parameters(model, bootstrap = TRUE) -} +model_parameters(model, bootstrap = TRUE) # standardized parameters model_parameters(model, standardize = "refit") # robust, heteroskedasticity-consistent standard errors -if (require("sandwich") && require("clubSandwich")) { - model_parameters(model, vcov = "HC3") +model_parameters(model, vcov = "HC3") - model_parameters(model, - vcov = "vcovCL", - vcov_args = list(cluster = mtcars$cyl) - ) -} +model_parameters(model, + vcov = "vcovCL", + vcov_args = list(cluster = mtcars$cyl) +) # different p-value style in output model_parameters(model, p_digits = 5) @@ -425,16 +422,15 @@ model_parameters(model) model_parameters(model, exponentiate = TRUE) # bias-corrected logistic regression with penalized maximum likelihood -if (require("brglm2")) { - model <- glm( - vs ~ wt + cyl, - data = mtcars, - family = "binomial", - method = "brglmFit" - ) - model_parameters(model) -} +model <- glm( + vs ~ wt + cyl, + data = mtcars, + family = "binomial", + method = "brglmFit" +) +model_parameters(model) } +\dontshow{\}) # examplesIf} } \seealso{ \code{\link[insight:standardize_names]{insight::standardize_names()}} to diff --git a/man/print.parameters_model.Rd b/man/print.parameters_model.Rd index b66d83cd7..8df368867 100644 --- a/man/print.parameters_model.Rd +++ b/man/print.parameters_model.Rd @@ -22,7 +22,7 @@ groups = NULL, column_width = NULL, ci_brackets = c("[", "]"), - add_reference = FALSE, + include_reference = FALSE, ... ) @@ -132,7 +132,7 @@ columns across all table components are adjusted to have the same width.} \item{ci_brackets}{Logical, if \code{TRUE} (default), CI-values are encompassed in square brackets (else in parentheses).} -\item{add_reference}{Logical, if \code{TRUE}, the reference level of factors will +\item{include_reference}{Logical, if \code{TRUE}, the reference level of factors will be added to the parameters table. This is only relevant for models with categorical predictors. The coefficient for the reference level is always \code{0} (except when \code{exponentiate = TRUE}, then the coefficient will be \code{1}), diff --git a/tests/testthat/test-model_parameters.anova.R b/tests/testthat/test-model_parameters.anova.R index a05a82c8d..9533031d4 100644 --- a/tests/testthat/test-model_parameters.anova.R +++ b/tests/testthat/test-model_parameters.anova.R @@ -8,7 +8,7 @@ test_that("model_parameters.anova", { a <- anova(m, test = "Chisq") mp <- model_parameters(a) - expect_equal(colnames(mp), c("Parameter", "df", "Deviance", "df_error", "Deviance_error", "p")) + expect_named(mp, c("Parameter", "df", "Deviance", "df_error", "Deviance_error", "p")) expect_equal(mp$Deviance_error, c(43.22973, 29.67517, 19.23255, 10.48692), tolerance = 1e-3) expect_equal(mp$p, c(NA, 0.00023, 0.00123, 0.01262), tolerance = 1e-3) expect_snapshot(mp) @@ -18,7 +18,7 @@ test_that("model_parameters.anova", { skip_if_not_installed("car") a <- car::Anova(m, type = 3, test.statistic = "F") mp <- model_parameters(a) - expect_equal(colnames(mp), c("Parameter", "Sum_Squares", "df", "Mean_Square", "F", "p")) + expect_named(mp, c("Parameter", "Sum_Squares", "df", "Mean_Square", "F", "p")) expect_equal(mp[["F"]], c(53.40138, 60.42944, 13.96887, NA), tolerance = 1e-3) }) @@ -38,13 +38,13 @@ test_that("linear hypothesis tests", { expect_equal(p1, p2, ignore_attr = TRUE) expect_equal(p1, p3, ignore_attr = TRUE) expect_equal(p1, p4, ignore_attr = TRUE) - expect_equal(nrow(p1), 2) - expect_equal(p1$Parameter, c("(Intercept) = 0", "repwt = 1")) + expect_identical(nrow(p1), 2L) + expect_identical(p1$Parameter, c("(Intercept) = 0", "repwt = 1")) mod.duncan <- lm(prestige ~ income + education, data = Duncan) p <- parameters(car::linearHypothesis(mod.duncan, "1*income - 1*education + 1 = 1")) - expect_equal(nrow(p), 1) - expect_equal(p$Parameter, "income - education = 0") + expect_identical(nrow(p), 1L) + expect_identical(p$Parameter, "income - education = 0") }) test_that("print-model_parameters", { @@ -62,7 +62,7 @@ test_that("model_parameters_Anova.mlm", { a <- car::Anova(m, type = 3, test.statistic = "Pillai") mp <- model_parameters(a, verbose = FALSE) - expect_equal(colnames(mp), c("Parameter", "df", "Statistic", "df_num", "df_error", "F", "p")) + expect_named(mp, c("Parameter", "df", "Statistic", "df_num", "df_error", "F", "p")) expect_equal(mp[["F"]], c(158.2578, 6.60593, 3.71327, 3.28975), tolerance = 1e-3) expect_equal(mp$Statistic, c(0.9268, 0.67387, 0.22903, 0.4039), tolerance = 1e-3) }) @@ -75,7 +75,7 @@ test_that("model_parameters_Anova.mlm", { m <- MASS::polr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing) a <- car::Anova(m) mp <- model_parameters(a) - expect_equal(colnames(mp), c("Parameter", "Chi2", "df", "p")) + expect_named(mp, c("Parameter", "Chi2", "df", "p")) expect_equal(mp$Chi2, c(108.2392, 55.91008, 14.30621), tolerance = 1e-3) }) @@ -118,16 +118,16 @@ test_that("anova type | lm", { m <- lm(mpg ~ factor(cyl) * hp + disp, mtcars) a1 <- aov(m) - expect_equal(attr(model_parameters(a1), "anova_type"), 1) + expect_identical(attr(model_parameters(a1), "anova_type"), 1) a1 <- anova(m) - expect_equal(attr(model_parameters(a1), "anova_type"), 1) + expect_identical(attr(model_parameters(a1), "anova_type"), 1) a2 <- car::Anova(m, type = 2) a3 <- car::Anova(m, type = 3) - expect_equal(attr(model_parameters(a2), "anova_type"), 2) + expect_identical(attr(model_parameters(a2), "anova_type"), 2) expect_message( - expect_equal(attr(model_parameters(a3), "anova_type"), 3), + expect_identical(attr(model_parameters(a3), "anova_type"), 3), "Type 3 ANOVAs only give" ) @@ -151,15 +151,15 @@ test_that("anova type | mlm", { m <- lm(cbind(mpg, drat) ~ factor(cyl) * hp + disp, mtcars) a1 <- aov(m) - expect_equal(attr(model_parameters(a1), "anova_type"), 1) + expect_identical(attr(model_parameters(a1), "anova_type"), 1) a1 <- anova(m) - expect_equal(attr(model_parameters(a1), "anova_type"), 1) + expect_identical(attr(model_parameters(a1), "anova_type"), 1) a2 <- car::Anova(m, type = 2) a3 <- car::Anova(m, type = 3) - expect_equal(attr(model_parameters(a2), "anova_type"), 2) - expect_equal(attr(model_parameters(a3, verbose = FALSE), "anova_type"), 3) + expect_identical(attr(model_parameters(a2), "anova_type"), 2) + expect_identical(attr(model_parameters(a3, verbose = FALSE), "anova_type"), 3) }) test_that("anova type | glm", { @@ -168,13 +168,13 @@ test_that("anova type | glm", { m <- suppressWarnings(glm(am ~ factor(cyl) * hp + disp, mtcars, family = binomial())) a1 <- anova(m) - expect_equal(attr(model_parameters(a1), "anova_type"), 1) + expect_identical(attr(model_parameters(a1), "anova_type"), 1) a2 <- suppressWarnings(car::Anova(m, type = 2)) a3 <- suppressWarnings(car::Anova(m, type = 3)) - expect_equal(attr(model_parameters(a2), "anova_type"), 2) + expect_identical(attr(model_parameters(a2), "anova_type"), 2) expect_message( - expect_equal(attr(model_parameters(a3), "anova_type"), 3), + expect_identical(attr(model_parameters(a3), "anova_type"), 3), "Type 3 ANOVAs only give" ) }) @@ -185,37 +185,37 @@ test_that("anova type | lme4", { skip_if_not_installed("car") m1 <- lme4::lmer(mpg ~ factor(cyl) * hp + disp + (1 | gear), mtcars) - suppressMessages( + suppressMessages({ m2 <- lme4::glmer(carb ~ factor(cyl) * hp + disp + (1 | gear), mtcars, family = poisson() ) - ) + }) a1 <- anova(m1) - expect_equal(attr(model_parameters(a1), "anova_type"), 1) + expect_identical(attr(model_parameters(a1), "anova_type"), 1) a1 <- anova(m2) - expect_equal(attr(model_parameters(a1), "anova_type"), 1) + expect_identical(attr(model_parameters(a1), "anova_type"), 1) a3 <- anova(lmerTest::as_lmerModLmerTest(m1)) expect_message( - expect_equal(attr(model_parameters(a3), "anova_type"), 3), + expect_identical(attr(model_parameters(a3), "anova_type"), 3), "Type 3 ANOVAs only give" ) a2 <- car::Anova(m1, type = 2) a3 <- car::Anova(m1, type = 3) - expect_equal(attr(model_parameters(a2), "anova_type"), 2) + expect_identical(attr(model_parameters(a2), "anova_type"), 2) expect_message( - expect_equal(attr(model_parameters(a3), "anova_type"), 3), + expect_identical(attr(model_parameters(a3), "anova_type"), 3), "Type 3 ANOVAs only give" ) a2 <- car::Anova(m2, type = 2) a3 <- car::Anova(m2, type = 3) - expect_equal(attr(model_parameters(a2), "anova_type"), 2) + expect_identical(attr(model_parameters(a2), "anova_type"), 2) expect_message( - expect_equal(attr(model_parameters(a3), "anova_type"), 3), + expect_identical(attr(model_parameters(a3), "anova_type"), 3), "Type 3 ANOVAs only give" ) }) @@ -225,15 +225,15 @@ test_that("anova type | afex + Anova.mlm", { data(obk.long, package = "afex") - suppressMessages( + suppressMessages({ m <- afex::aov_ez("id", "value", obk.long, between = c("treatment", "gender"), within = c("phase", "hour"), observed = "gender" ) - ) + }) - expect_equal(attr(model_parameters(m), "anova_type"), 3) - expect_equal(attr(model_parameters(m$Anova, verbose = FALSE), "anova_type"), 3) + expect_identical(attr(model_parameters(m), "anova_type"), 3) + expect_identical(attr(model_parameters(m$Anova, verbose = FALSE), "anova_type"), 3) }) test_that("anova rms", { @@ -242,20 +242,21 @@ test_that("anova rms", { a <- anova(m) mp <- model_parameters(a) - expect_equal(attr(mp, "anova_type"), 2) - expect_equal(mp$Parameter, c("cyl", "disp", "hp", "drat", "Total", "Residuals")) - expect_equal(colnames(mp), c("Parameter", "Sum_Squares_Partial", "df", "Mean_Square", "F", "p")) + expect_identical(attr(mp, "anova_type"), 2) + expect_identical(mp$Parameter, c("cyl", "disp", "hp", "drat", "Total", "Residuals")) + expect_identical(colnames(mp), c("Parameter", "Sum_Squares_Partial", "df", "Mean_Square", "F", "p")) expect_equal(mp$Sum_Squares_Partial, data.frame(a)$Partial.SS, tolerance = 1e-3) }) test_that("anova rms", { skip_if_not_installed("rms") + skip_if(getRversion() < "4.2.0") m <- rms::orm(mpg ~ cyl + disp + hp + drat, data = mtcars) a <- anova(m) mp <- model_parameters(a) - expect_equal(attr(mp, "anova_type"), 2) - expect_equal(mp$Parameter, c("cyl", "disp", "hp", "drat", "Total")) - expect_equal(colnames(mp), c("Parameter", "Chi2", "df", "p")) + expect_identical(attr(mp, "anova_type"), 2) + expect_identical(mp$Parameter, c("cyl", "disp", "hp", "drat", "Total")) + expect_named(mp, c("Parameter", "Chi2", "df", "p")) expect_equal(mp$Chi2, data.frame(a)$Chi.Square, tolerance = 1e-3) }) diff --git a/tests/testthat/test-printing_reference_level.R b/tests/testthat/test-printing_reference_level.R index d847fcd4e..bec8507ea 100644 --- a/tests/testthat/test-printing_reference_level.R +++ b/tests/testthat/test-printing_reference_level.R @@ -5,7 +5,7 @@ # d <<- PlantGrowth # m <- lm(weight ~ group, data = d) # mp <- model_parameters(m) -# expect_snapshot(print(mp, add_reference = TRUE)) +# expect_snapshot(print(mp, include_reference = TRUE)) # data(mtcars) # d <<- mtcars @@ -13,19 +13,19 @@ # d$am <- as.factor(d$am) # m <- lm(mpg ~ hp + cyl + gear + am, data = d) # mp <- model_parameters(m) -# expect_snapshot(print(mp, add_reference = TRUE)) +# expect_snapshot(print(mp, include_reference = TRUE)) # data(iris) # d <<- iris # m <- lm(Sepal.Length ~ Sepal.Width * Species, data = d) # mp <- model_parameters(m) -# expect_snapshot(print(mp, add_reference = TRUE)) +# expect_snapshot(print(mp, include_reference = TRUE)) # data(mtcars) # d <<- mtcars # d$gear <- as.factor(d$gear) # m <- glm(vs ~ wt + gear, data = d, family = "binomial") -# expect_snapshot(print(model_parameters(m, exponentiate = TRUE, drop = "(Intercept)"), add_reference = TRUE)) +# expect_snapshot(print(model_parameters(m, exponentiate = TRUE, drop = "(Intercept)"), include_reference = TRUE)) # }) # test_that("reference for models with multiple components", { @@ -40,5 +40,5 @@ # family = glmmTMB::truncated_poisson() # ) -# print(model_parameters(m1), add_reference = TRUE) +# print(model_parameters(m1), include_reference = TRUE) # }) diff --git a/tests/testthat/test-quantreg.R b/tests/testthat/test-quantreg.R index 4fba67d15..2fa1ea166 100644 --- a/tests/testthat/test-quantreg.R +++ b/tests/testthat/test-quantreg.R @@ -1,4 +1,5 @@ skip_on_cran() +skip_if(getRversion() < "4.2.0") # rqss --------- @@ -20,7 +21,7 @@ skip_on_cran() test_that("mp_rq", { skip_if_not_installed("quantreg") data(stackloss) - m1 <- quantreg::rq(stack.loss ~ Air.Flow + Water.Temp, data = stackloss, tau = .25) + m1 <- quantreg::rq(stack.loss ~ Air.Flow + Water.Temp, data = stackloss, tau = 0.25) mp <- suppressWarnings(model_parameters(m1)) expect_identical(mp$Parameter, c("(Intercept)", "Air.Flow", "Water.Temp"))