diff --git a/.Rbuildignore b/.Rbuildignore index 759c3233..eb4d034d 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -19,7 +19,6 @@ ^CONTRIBUTING.md$ ^\.github$ ^\.vs$ -^doc$ ^Meta$ ^make_hex\.R$ ^hex\.png$ @@ -27,3 +26,4 @@ ^paper\.md$ ^pkgdown$ ^CRAN-SUBMISSION$ +^doc$ \ No newline at end of file diff --git a/.github/workflows/recheck.yml b/.github/workflows/recheck.yml new file mode 100644 index 00000000..1699640f --- /dev/null +++ b/.github/workflows/recheck.yml @@ -0,0 +1,18 @@ +on: + workflow_dispatch: + inputs: + which: + type: choice + description: Which dependents to check + options: + - strong + - most + +name: Reverse dependency check + +jobs: + revdep_check: + name: Reverse check ${{ inputs.which }} dependents + uses: r-devel/recheck/.github/workflows/recheck.yml@v1 + with: + which: ${{ inputs.which }} \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION index 6dd24355..2c0abd96 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -15,19 +15,20 @@ License: GPL (>= 3) Encoding: UTF-8 LazyData: true Imports: - crayon, + cli, generics, + broom, + broom.mixed, ggplot2 (>= 3.4.0), magrittr, pander, pkgconfig, - rlang (>= 0.3.0), + rlang, + sandwich, tibble Suggests: boot, - broom, - broom.mixed, - huxtable (>= 3.0.0), + huxtable, kableExtra, lme4, lmerTest, @@ -35,7 +36,6 @@ Suggests: methods, pbkrtest, RColorBrewer, - sandwich, scales, survey, weights, @@ -47,8 +47,8 @@ Enhances: brms, quantreg, rstanarm -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2.9000 VignetteBuilder: knitr Roxygen: list(markdown = TRUE) Depends: - R (>= 3.5.0) + R (>= 3.6.0) diff --git a/NAMESPACE b/NAMESPACE index af195796..f87b8415 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -20,90 +20,6 @@ if (!nzchar(system.file(package = "interactions"))) { if (!nzchar(system.file(package = "interactions"))) { export(sim_slopes) } - -if (getRversion() >= "3.6.0") { - S3method(generics::tidy, glht) -} else { - export(tidy.glht) -} - -if (getRversion() >= "3.6.0") { - S3method(generics::tidy, summary.glht) -} else { - export(tidy.summary.glht) -} - -if (getRversion() >= "3.6.0") { - S3method(knitr::knit_print, summ.glm) -} else { - export(knit_print.summ.glm) -} - -if (getRversion() >= "3.6.0") { - S3method(knitr::knit_print, summ.lm) -} else { - export(knit_print.summ.lm) -} - -if (getRversion() >= "3.6.0") { - S3method(knitr::knit_print, summ.merMod) -} else { - export(knit_print.summ.merMod) -} - -if (getRversion() >= "3.6.0") { - S3method(knitr::knit_print, summ.rq) -} else { - export(knit_print.summ.rq) -} - -if (getRversion() >= "3.6.0") { - S3method(knitr::knit_print, summ.svyglm) -} else { - export(knit_print.summ.svyglm) -} - -if (getRversion() >= "3.6.0") { - S3method(generics::glance, summ.lm) -} else { - export(glance.summ.lm) -} - -if (getRversion() >= "3.6.0") { - S3method(generics::glance, summ.glm) -} else { - export(glance.summ.glm) -} - -if (getRversion() >= "3.6.0") { - S3method(generics::glance, summ.svyglm) -} else { - export(glance.summ.svyglm) -} - -if (getRversion() >= "3.6.0") { - S3method(generics::glance, summ.merMod) -} else { - export(glance.summ.merMod) -} - -if (getRversion() >= "3.6.0") { - S3method(generics::glance, summ.rq) -} else { - export(glance.summ.rq) -} - -if (getRversion() >= "3.6.0") { - S3method(generics::tidy, summ) -} else { - export(tidy.summ) -} - -if (getRversion() >= "3.6.0") { - S3method(generics::tidy, summ.merMod) -} else { - export(tidy.summ.merMod) -} S3method("%just%",data.frame) S3method("%just%",default) S3method("%just%",list) @@ -126,8 +42,15 @@ S3method(get_formula,brmsfit) S3method(get_formula,default) S3method(get_formula,panelmodel) S3method(glance,summ.glm) +S3method(glance,summ.lm) S3method(glance,summ.merMod) +S3method(glance,summ.rq) S3method(glance,summ.svyglm) +S3method(knitr::knit_print,summ.glm) +S3method(knitr::knit_print,summ.lm) +S3method(knitr::knit_print,summ.merMod) +S3method(knitr::knit_print,summ.rq) +S3method(knitr::knit_print,summ.svyglm) S3method(make_predictions,brmsfit) S3method(make_predictions,default) S3method(make_predictions,merMod) @@ -159,6 +82,9 @@ S3method(summ,lm) S3method(summ,merMod) S3method(summ,rq) S3method(summ,svyglm) +S3method(tidy,summ) +S3method(tidy,summ.merMod) +S3method(tidy,summary.glht) export("%just%") export("%just%<-") export("%nin%") @@ -212,13 +138,11 @@ export(weights_tests) export(wgttest) export(wrap_str) export(wtd.sd) +import(broom) +import(broom.mixed) +import(cli) import(ggplot2) import(rlang) -importFrom(crayon,cyan) -importFrom(crayon,inverse) -importFrom(crayon,italic) -importFrom(crayon,red) -importFrom(crayon,underline) importFrom(generics,glance) importFrom(generics,tidy) importFrom(ggplot2,aes_string) @@ -234,6 +158,8 @@ importFrom(grDevices,rgb) importFrom(magrittr,"%<>%") importFrom(magrittr,"%>%") importFrom(pander,pandoc.table.return) +importFrom(rlang,check_installed) +importFrom(rlang,is_installed) importFrom(stats,"contrasts<-") importFrom(stats,AIC) importFrom(stats,BIC) diff --git a/NEWS.md b/NEWS.md index ac79a33c..6987b354 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,16 +1,52 @@ # jtools 2.2.3.9999 -Bug fix: +Bug fixes: * `predict_merMod()` was miscalculating predictions under a specific set of conditions: When the model was fit with `lme4::glmer()`, the link was not identity, standard errors were simultaneously being calculated, and the user included random effects. This error has been corrected ([#144](https://github.com/jacob-long/jtools/issues/144)) +* When printing `summ.glm()` results with `knitr`, the *p* value for the +omnibus chi-squared test is now included in the model statistics, like it +already is when using the function in the console. ([#138](https://github.com/jacob-long/jtools/issues/138) +* `effect_plot()` no longer fails with an error when models weights are +specified without a variable name. +([#156](https://github.com/jacob-long/jtools/issues/156)) -Enhancement: +Enhancements: * `summ()` will now produce model fit statistics for `glm.nb` models ([#142](https://github.com/jacob-long/jtools/issues/142)). +* `effect_plot()` now includes the argument `facet.by`. If you want to plot +your prediction variable at multiple values of some other variable, you can +pass the name of that variable to `facet.by`. It will, by default, create a +separate plot for each unique level of that variable using +`ggplot2::facet_wrap()`. If you only want specific levels of the `facet.by` +variable, you can specify them by giving a vector of values to the `at` argument. +More than most kinds of plots, you may need to do some further customization +to the results of `effect_plot()` since the plots may not fit the space well, +or you may want to rearrange into different row/column configurations, etc. I +expect this to be most useful for cases when you have a multilevel model and +there is a random slope specified for the `pred` variable. A version of this +feature was requested by Github user *5tokesy* (#147). +* `plot_coefs()` now handles `fixest_multi` objects from the `fixest` package +out of the box. (#123) +* The `omit.coefs` and `coefs` arguments to `plot_coefs()` can now be modified +using the new argument, `coefs.match`. You may use regular expressions to more +efficiently match coefficient names, which will be most useful when you have +models with many coefficients with predictable naming schemes. To have your +arguments interepreted this way, set `coefs.match = "regex"`. +([#122](https://github.com/jacob-long/jtools/issues/122)) + +Other changes: + +* Removed `tidy.glht()` method because the `broom` package now implements one. +(#139) +* Made `broom` and `broom.mixed` hard dependencies to help avoid user confusion +and a few errors that could occur when one was missing. (#149) +* `cli` is now used to format (colorizing, italicizing, etc.) console output +rather than `crayon`. Please report any issues if formatting doesn't work +right for you; there shouldn't be any changes from past releases. # jtools 2.2.2 diff --git a/R/effect_plot.R b/R/effect_plot.R index 95e1990c..83c4e5f8 100644 --- a/R/effect_plot.R +++ b/R/effect_plot.R @@ -174,6 +174,13 @@ #' @param partial.residuals Instead of plotting the observed data, you may plot #' the partial residuals (controlling for the effects of variables besides #' `pred`). +#' @param facet.by A variable in the data by which you want to plot the +#' effects separately. This will cause the plot to include multiple panels, +#' basically a separate plot for each unique value of the variable in +#' `facet.by`. This will be most useful when plotting effects from multilevel +#' models (e.g., as fit by `lme4`'s models) with a random slope for the +#' `pred` variable. You should generally only want to use this if you expect +#' the different panels to look meaningfully different. Default is `NULL`. #' #' @details This function provides a means for plotting effects for the #' purpose of exploring regression estimates. You must have the @@ -259,20 +266,48 @@ effect_plot <- function(model, pred, pred.values = NULL, centered = "all", point.size = 1.5, point.alpha = 0.6, jitter = 0, rug = FALSE, rug.sides = "lb", force.cat = FALSE, cat.geom = c("point", "line", "bar"), cat.interval.geom = c("errorbar", "linerange"), cat.pred.point.size = 3.5, - partial.residuals = FALSE, color.class = colors, ...) { + partial.residuals = FALSE, color.class = colors, facet.by = NULL, ...) { # Evaluate the pred arg - pred <- quo_name(enexpr(pred)) - + pred <- as_name(enquo(pred)) + + # Get the data right now rather than checking for its presence several times + if (is.null(data)) { + data <- get_data(model) + } + + # Evaluate the facet.by arg, knowing it may be NULL + facet.by <- enquo(facet.by) + if (!quo_is_null(facet.by)) { # check for NULL + facet.by <- as_name(facet.by) + if (is.null(at) || facet.by %nin% names(at)) { + # If user isn't telling me the levels, then grab them all + if (facet.by %nin% names(data)) { + # Assume issue is variable isn't in the model formula for some reason + the_formula <- stats::formula(model) + the_formula <- update(the_formula, paste(". ~ . +", facet.by)) + data <- get_data(model, formula = the_formula) + } + at[[facet.by]] <- unique(data[[facet.by]]) + if (length(at[[facet.by]]) > 10) { + msg_wrap(facet.by, " has ", length(at[[facet.by]]), " levels. This may + result in a difficult-to-see plot and/or a slow loading time + while the plot is generated. If you'd like to see just a + subset of the levels, you can specify them in the `at` + argument (e.g., at = list(", facet.by, " = c(", + dput(at[[facet.by]][1]), ", ", dput(at[[facet.by]][2]), ", ", + dput(at[[facet.by]][3]), "))", brk = "") + } + } + } else {facet.by <- NULL} # don't make it a quosure anymore + # Have a sensible interval default for categorical predictors - if ("interval" %nin% names(match.call())[-1] && - !(is.numeric(get_data(model, warn = FALSE)[[pred]]) && + if ("interval" %nin% names(match.call())[-1] && !(is.numeric(data[[pred]]) && force.cat == FALSE)) { interval <- TRUE } if (force.cat == TRUE && is.null(pred.values)) { - if (is.null(data)) {data <- get_data(model)} pred.values <- sort(unique(suppressMessages(data[[pred]]))) } @@ -290,6 +325,7 @@ effect_plot <- function(model, pred, pred.values = NULL, centered = "all", set.offset = set.offset, return.orig.data = TRUE, partial.residuals = partial.residuals, data = data, ...) + # Putting these outputs into separate objects pm <- pred_out[[1]] d <- pred_out[[2]] @@ -318,7 +354,7 @@ effect_plot <- function(model, pred, pred.values = NULL, centered = "all", weights = get_weights(model, d)$weights_name, rug = rug, rug.sides = rug.sides, point.size = point.size, point.alpha = point.alpha, - point.color = colors) + point.color = colors, facet.by = facet.by) } else { plot_cat(predictions = pm, pred = pred, data = d, geom = cat.geom, pred.values = pred.values, @@ -329,7 +365,7 @@ effect_plot <- function(model, pred, pred.values = NULL, centered = "all", resp = get_response_name(model, ...), jitter = jitter, interval.geom = cat.interval.geom, line.thickness = line.thickness, point.size = point.size, pred.point.size = cat.pred.point.size, - point.alpha = point.alpha, point.color = colors) + point.alpha = point.alpha, point.color = colors, facet.by = facet.by) } } @@ -340,11 +376,12 @@ plot_effect_continuous <- main.title = NULL, colors = NULL, line.thickness = 1.1, jitter = 0.1, resp = NULL, weights = NULL, rug = FALSE, rug.sides = "b", - point.size = 1, point.alpha = 0.6, point.color = "black") { + point.size = 1, point.alpha = 0.6, point.color = "black", + facet.by = NULL) { pm <- predictions d <- data - + if (is.null(x.label)) { x.label <- pred } @@ -353,16 +390,12 @@ plot_effect_continuous <- y.label <- resp } - pred <- sym(pred) - resp <- sym(resp) - if (!is.null(weights)) {weights <- sym(weights)} - # If only 1 jitter arg, just duplicate it if (length(jitter) == 1) {jitter <- rep(jitter, 2)} # Starting plot object - p <- ggplot(pm, aes(x = !! pred, y = !! resp)) - + p <- ggplot(pm, aes(x = .data[[pred]], y = .data[[resp]])) + # Plot observed data — do this first to plot the line over the points if (plot.points == TRUE) { @@ -374,7 +407,8 @@ plot_effect_continuous <- # Need to use layer function to programmatically define constant aesthetics p <- p + layer(geom = "point", data = d, stat = "identity", inherit.aes = FALSE, show.legend = FALSE, - mapping = aes(x = !! pred, y = !! resp, size = !! weights), + mapping = aes(x = .data[[pred]], y = .data[[resp]], + size = .data[[weights]]), position = position_jitter(width = jitter[1], height = jitter[2]), params = constants) + @@ -388,14 +422,14 @@ plot_effect_continuous <- # Plot intervals if requested if (interval == TRUE) { p <- p + geom_ribbon(data = pm, - aes(ymin = !! sym("ymin"), ymax = !! sym("ymax")), + aes(ymin = .data$ymin, ymax = .data$ymax), alpha = 1/5, show.legend = FALSE, fill = colors) } # Rug plot for marginal distributions if (rug == TRUE) { p <- p + geom_rug(data = d, - mapping = aes(x = !! pred, y = !! resp), alpha = 0.6, + mapping = aes(x = .data[[pred]], y = .data[[resp]]), alpha = 0.6, position = position_jitter(width = jitter[1]), sides = rug.sides, inherit.aes = TRUE, color = colors) } @@ -421,6 +455,10 @@ plot_effect_continuous <- } } + if (!is.null(facet.by)) { + p <- p + facet_wrap(facet.by) + } + # Give the plot the user-specified title if there is one if (!is.null(main.title)) { p <- p + ggtitle(main.title) @@ -430,7 +468,7 @@ plot_effect_continuous <- return(p) -} + } plot_cat <- function(predictions, pred, data = NULL, geom = c("point", "line", "bar", "boxplot"), pred.values = NULL, @@ -439,7 +477,7 @@ plot_cat <- function(predictions, pred, data = NULL, resp = NULL, jitter = 0.1, geom.alpha = NULL, dodge.width = NULL, errorbar.width = NULL, interval.geom = c("errorbar", "linerange"), line.thickness = 1.1, point.size = 1, pred.point.size = 3.5, - point.alpha = 0.6, point.color = "black") { + point.alpha = 0.6, point.color = "black", facet.by = NULL) { pm <- predictions d <- data @@ -503,7 +541,7 @@ plot_cat <- function(predictions, pred, data = NULL, } - p <- ggplot(pm, aes(x = !! pred, y = !! resp, group = 1)) + p <- ggplot(pm, aes(x = .data[[pred]], y = .data[[resp]], group = 1)) if (geom == "bar") { p <- p + geom_bar(stat = "identity", position = "dodge", alpha = a_level, @@ -522,13 +560,13 @@ plot_cat <- function(predictions, pred, data = NULL, # Plot intervals if requested if (interval == TRUE && interval.geom[1] == "errorbar") { - p <- p + geom_errorbar(aes(ymin = !! sym("ymin"), ymax = !! sym("ymax")), + p <- p + geom_errorbar(aes(ymin = .data$ymin, ymax = .data$ymax), alpha = 1, show.legend = FALSE, position = position_dodge(dodge.width), width = errorbar.width, linewidth = line.thickness, color = colors) } else if (interval == TRUE && interval.geom[1] %in% c("line", "linerange")) { - p <- p + geom_linerange(aes(ymin = !! sym("ymin"), ymax = !! sym("ymax")), + p <- p + geom_linerange(aes(ymin = .data$ymin, ymax = .data$ymax), alpha = 0.8, show.legend = FALSE, position = position_dodge(dodge.width), linewidth = line.thickness, color = colors) @@ -546,7 +584,8 @@ plot_cat <- function(predictions, pred, data = NULL, # Need to use layer function to programmatically define constant aesthetics p <- p + layer(geom = "point", data = d, stat = "identity", inherit.aes = FALSE, show.legend = FALSE, - mapping = aes(x = !! pred, y = !! resp, size = !! weights), + mapping = aes(x = .data[[pred]], y = .data[[resp]], + size = .data[[weights]]), position = position_jitter(width = jitter[1], height = jitter[2]), params = constants) + @@ -558,6 +597,10 @@ plot_cat <- function(predictions, pred, data = NULL, p <- p + theme_nice() + drop_x_gridlines() + labs(x = x.label, y = y.label) # better labels for axes + if (!is.null(facet.by)) { + p <- p + facet_wrap(facet.by) + } + # Give the plot the user-specified title if there is one if (!is.null(main.title)) { p <- p + ggtitle(main.title) @@ -566,5 +609,4 @@ plot_cat <- function(predictions, pred, data = NULL, # Return the plot return(p) - } diff --git a/R/export_summ.R b/R/export_summ.R index 5d53fc3b..c576f6de 100644 --- a/R/export_summ.R +++ b/R/export_summ.R @@ -150,13 +150,7 @@ export_summs <- function(..., to.file = NULL, file.name = NULL) { - if (!requireNamespace("huxtable", quietly = TRUE)) { - stop_wrap("Install the huxtable package to use the export_summs function.") - } - - if (!requireNamespace("broom", quietly = TRUE)) { - stop_wrap("Install the broom package to use the export_summs function.") - } + rlang::check_installed("huxtable") # Capture arguments dots <- list(...) @@ -361,12 +355,7 @@ export_summs <- function(..., } #' @rdname glance.summ -#' @rawNamespace -#' if (getRversion() >= "3.6.0") { -#' S3method(generics::tidy, summ) -#' } else { -#' export(tidy.summ) -#' } +#' @export tidy.summ <- function(x, conf.int = FALSE, conf.level = .95, ...) { @@ -477,12 +466,7 @@ tidy.summ <- function(x, conf.int = FALSE, conf.level = .95, ...) { } #' @rdname glance.summ -#' @rawNamespace -#' if (getRversion() >= "3.6.0") { -#' S3method(generics::tidy, summ.merMod) -#' } else { -#' export(tidy.summ.merMod) -#' } +#' @export tidy.summ.merMod <- function(x, conf.int = FALSE, conf.level = .95, ...) { @@ -586,31 +570,7 @@ tidy.summ.merMod <- function(x, conf.int = FALSE, conf.level = .95, ...) { #' \code{\link[generics]{glance}} #' #' @rdname glance.summ -#' @rawNamespace -#' if (getRversion() >= "3.6.0") { -#' S3method(generics::glance, summ.lm) -#' } else { -#' export(glance.summ.lm) -#' } -#' -#' if (getRversion() >= "3.6.0") { -#' S3method(generics::glance, summ.glm) -#' } else { -#' export(glance.summ.glm) -#' } -#' -#' if (getRversion() >= "3.6.0") { -#' S3method(generics::glance, summ.svyglm) -#' } else { -#' export(glance.summ.svyglm) -#' } -#' -#' if (getRversion() >= "3.6.0") { -#' S3method(generics::glance, summ.merMod) -#' } else { -#' export(glance.summ.merMod) -#' } - +#' @export glance.summ.lm <- function(x, ...) { diff --git a/R/internal.R b/R/internal.R index 6c115dd8..fb5940dd 100644 --- a/R/internal.R +++ b/R/internal.R @@ -348,6 +348,7 @@ test_coefs.default <- function(x, the_vcov = NULL, df = NULL, ...) { } +#' @exportS3Method NULL test_coefs.glm <- function(x, the_vcov = NULL, df = Inf, ...) { # Only difference is default DF test_coefs.default(x, the_vcov = the_vcov, df = df, ...) @@ -417,31 +418,9 @@ predict_rob <- function(model, .vcov = vcov(model), newdata = NULL, } -## Kludge to fix glht compatibility -#' @rawNamespace -#' if (getRversion() >= "3.6.0") { -#' S3method(generics::tidy, glht) -#' } else { -#' export(tidy.glht) -#' } -tidy.glht <- function (x, conf.int = FALSE, conf.level = 0.95, ...) { - if (!conf.int) { - tibble(lhs = rownames(x$linfct), rhs = x$rhs, estimate = stats::coef(x)) - } else { - confs <- as.data.frame(confint(x, level = conf.level)$confint) - tibble(lhs = rownames(x$linfct), rhs = x$rhs, estimate = stats::coef(x), - conf.low = confs$lwr, conf.high = confs$upr) - } -} - #' @importFrom tibble tibble as_tibble #' @importFrom stats confint -#' @rawNamespace -#' if (getRversion() >= "3.6.0") { -#' S3method(generics::tidy, summary.glht) -#' } else { -#' export(tidy.summary.glht) -#' } +#' @export tidy.summary.glht <- function(x, conf.int = FALSE, conf.level = 0.95, ...) { lhs_rhs <- tibble(lhs = rownames(x$linfct), rhs = x$rhs) coef <- as_tibble(x$test[c("coefficients", "sigma", @@ -455,4 +434,10 @@ tidy.summary.glht <- function(x, conf.int = FALSE, conf.level = 0.95, ...) { out$conf.high <- confs$upr } out -} \ No newline at end of file +} + +#' @import broom +NULL + +#' @import broom.mixed +NULL diff --git a/R/make_new_data.R b/R/make_new_data.R index bed8e72d..6198d8aa 100644 --- a/R/make_new_data.R +++ b/R/make_new_data.R @@ -173,6 +173,8 @@ get_weights <- function(model, data) { wname <- NULL } else { wname <- all.vars(as.formula(paste("~", wname))) + # this can also make it character(0) + if (length(wname) == 0) {wname <- NULL} } if ("(weights)" %in% colnames(data) && !is.null(wname)) { @@ -398,10 +400,12 @@ get_family <- function(model, ...) { UseMethod("get_family") } +#' @exportS3Method NULL get_family.default <- function(model, ...) { family(model) } +#' @exportS3Method NULL get_family.brmsfit <- function(model, resp = NULL, ...) { form <- formula(model) fam <- family(model) diff --git a/R/make_predictions.R b/R/make_predictions.R index 25c06de3..77cd098d 100644 --- a/R/make_predictions.R +++ b/R/make_predictions.R @@ -14,10 +14,24 @@ prepare_return_data <- function(model, data, return.orig.data, if (return.orig.data == FALSE && partial.residuals == FALSE) { o <- tibble::as_tibble(pm) } else { - if (is.null(formula)) {formula <- get_formula(model)} + # Want to make sure I return the full original data if it's already given, + # otherwise fetch it again + if (is.null(data)) { + if (is.null(formula)) { + formula <- get_formula(model) + } + suppressMessages(d <- get_data(model, formula = formula)) + } else if (!is.null(data)) { + if (!is.null(formula)) { + # I'll assume formula was specified so that I would fetch more variables + suppressMessages(d <- get_data(model, formula = formula)) + } else { + formula <- get_formula(model) + d <- data + } + } if (return.orig.data == TRUE && partial.residuals == FALSE) { - o <- list(predictions = tibble::as_tibble(pm), data = - suppressMessages(d <- get_data(model, formula = formula))) + o <- list(predictions = tibble::as_tibble(pm), data = d) if ("is_dpar" %in% names(attributes(formula))) {return(o)} resp <- as.character(deparse(get_lhs(formula))) # If left-hand side is transformed, make new column in original data for @@ -50,7 +64,7 @@ prepare_return_data <- function(model, data, return.orig.data, ) ) } - } + } return(o) } @@ -136,7 +150,6 @@ prepare_return_data <- function(model, data, return.orig.data, #' @export #' - make_predictions.default <- function(model, pred, pred.values = NULL, at = NULL, data = NULL, center = TRUE, interval = TRUE, int.type = c("confidence", "prediction"), int.width = .95, diff --git a/R/mer_utils.r b/R/mer_utils.r index b4fb62b2..63a2ee07 100644 --- a/R/mer_utils.r +++ b/R/mer_utils.r @@ -1,18 +1,11 @@ -# Taken from sjstats so I don't have to list it as import - +# Based on defunct sjstats implementation. Could consider `performance` in future icc <- function(fit, obj.name) { - # check if suggested package is available - if (!requireNamespace("lme4", quietly = TRUE)) { - stop("Package `lme4` needed for this function to work. Please install it.", - call. = FALSE) - } + + check_installed("lme4", reason = "This function requires lme4.") # get family fitfam <- stats::family(fit)$family - # is neg. binomial? Dropped sjstats' internal function in favor of regexp - # is_negbin <- - # sjmisc::str_contains(fitfam, "Negative Binomial", ignore.case = TRUE) is_negbin <- grepl(ignore.case = TRUE, pattern = "Negative Binomial", x = fitfam) @@ -97,10 +90,6 @@ icc <- function(fit, obj.name) { attr(ri.icc, "rho.01") <- rho.01 attr(ri.icc, "tau.11") <- tau.11 attr(ri.icc, "sigma_2") <- resid_var - # finally, save name of fitted model object. May be needed for - # the 'se()' function, which accesses the global environment - ## Not sure what sjstats is going for here but breaks my code -- Jacob - # attr(ri.icc, ".obj.name") <- obj.name # return results return(ri.icc) diff --git a/R/plot_coefs.R b/R/plot_coefs.R index 292d548e..e47ce11f 100644 --- a/R/plot_coefs.R +++ b/R/plot_coefs.R @@ -64,6 +64,13 @@ #' dependent variable, that can be specified here. If NULL, it is assumed you #' want coefficients for the location/mean parameter, not the distributional #' parameter(s). +#' @param coefs.match This modifies the way the `coefs` and `omit.coefs` +#' arguments are interpreted. The default `"exact"` which represents the +#' legacy behavior, will include/exclude coefficients that match exactly +#' with your inputs to those functions. If `"regex"`, `coefs` and +#' `omit.coefs` are used as the `pattern` argument for [grepl()] matching +#' the coefficient names. Note that using `"regex"` means you will be unable +#' to override the default coefficient names via a named vector. #' @return A ggplot object. #' @details A note on the distinction between `plot_summs` and `plot_coefs`: #' `plot_summs` only accepts models supported by [summ()] and allows users @@ -120,7 +127,8 @@ plot_summs <- function(..., ci_level = .95, model.names = NULL, coefs = NULL, line.size = c(0.8, 2), legend.title = "Model", groups = NULL, facet.rows = NULL, facet.cols = NULL, facet.label.pos = "top", color.class = colors, - resp = NULL, dpar = NULL) { + resp = NULL, dpar = NULL, + coefs.match = c("exact", "regex")) { # Capture arguments dots <- list(...) @@ -151,7 +159,7 @@ plot_summs <- function(..., ci_level = .95, model.names = NULL, coefs = NULL, groups = list(groups), facet.rows = facet.rows, facet.cols = facet.cols, facet.label.pos = facet.label.pos, color.class = color.class, resp = resp, dpar = dpar, - ex_args)) + coefs.match = coefs.match, ex_args)) do.call("plot_coefs", args = args) @@ -171,11 +179,8 @@ plot_coefs <- function(..., ci_level = .95, inner_ci_level = NULL, line.size = c(0.8, 2), legend.title = "Model", groups = NULL, facet.rows = NULL, facet.cols = NULL, facet.label.pos = "top", color.class = colors, - resp = NULL, dpar = NULL) { - - if (!requireNamespace("broom", quietly = TRUE)) { - stop_wrap("Install the broom package to use the plot_coefs function.") - } + resp = NULL, dpar = NULL, + coefs.match = c("exact", "regex")) { if (!is.numeric(line.size[1])) stop_wrap("line.size must be a number (or two numbers in a vector).") @@ -190,7 +195,7 @@ plot_coefs <- function(..., ci_level = .95, inner_ci_level = NULL, dots <- list(...) # If first element of list is a list, assume the list is a list of models - if (inherits(dots[[1]], 'list')) { + if (inherits(dots[[1]], "list") || inherits(dots[[1]], "fixest_multi")) { mods <- dots[[1]] if (is.null(model.names) && !is.null(names(mods))) { if (is.null(model.names)) model.names <- names(mods) @@ -223,6 +228,8 @@ plot_coefs <- function(..., ci_level = .95, inner_ci_level = NULL, ex_args <- NULL } + coefs.match <- match.arg(coefs.match) + if (!is.null(omit.coefs) && !is.null(coefs)) { if (any(omit.coefs %nin% c("(Intercept)", "Intercept"))) { msg_wrap("coefs argument overrides omit.coefs argument. Displaying @@ -239,7 +246,8 @@ plot_coefs <- function(..., ci_level = .95, inner_ci_level = NULL, # Create tidy data frame combining each model's tidy output tidies <- make_tidies(mods = mods, ex_args = ex_args, ci_level = ci_level, model.names = model.names, omit.coefs = omit.coefs, - coefs = coefs, resp = resp, dpar = dpar) + coefs = coefs, resp = resp, dpar = dpar, + coefs.match = coefs.match) n_models <- length(unique(tidies$model)) @@ -249,7 +257,8 @@ plot_coefs <- function(..., ci_level = .95, inner_ci_level = NULL, tidies_inner <- make_tidies(mods = mods, ex_args = ex_args, ci_level = inner_ci_level, model.names = model.names, - omit.coefs = omit.coefs, coefs = coefs) + omit.coefs = omit.coefs, coefs = coefs, + coefs.match = coefs.match) tidies_inner$conf.low.inner <- tidies_inner$conf.low tidies_inner$conf.high.inner <- tidies_inner$conf.high @@ -425,7 +434,7 @@ plot_coefs <- function(..., ci_level = .95, inner_ci_level = NULL, } make_tidies <- function(mods, ex_args, ci_level, model.names, omit.coefs, - coefs, resp = NULL, dpar = NULL) { + coefs, resp = NULL, dpar = NULL, coefs.match = NULL) { # Need to handle complexities of resp and dpar arguments dpars <- NULL @@ -433,11 +442,6 @@ make_tidies <- function(mods, ex_args, ci_level, model.names, omit.coefs, resps <- NULL if ("brmsfit" %in% sapply(mods, class)) { - if (!requireNamespace("broom.mixed")) { - stop_wrap("Please install the broom.mixed package to process `brmsfit` - objects.") - } - mv_fits <- sapply(mods, function(x) "mvbrmsformula" %in% class(formula(x))) if (any(mv_fits)) { if (!is.null(resp) && length(resp) %nin% c(sum(mv_fits), 1)) { @@ -478,26 +482,11 @@ make_tidies <- function(mods, ex_args, ci_level, model.names, omit.coefs, tidies <- as.list(rep(NA, times = length(mods))) for (i in seq_along(mods)) { - - # Major kludge for methods clash between broom and broom.mixed - # Making namespace environment with broom.mixed before generics - # to try to put those methods in the search path - # Will drop after update to broom 0.7.0 - if (requireNamespace("broom.mixed")) { - nse <- as.environment(unlist(sapply(c(asNamespace("broom.mixed"), - asNamespace("generics")), - as.list))) - } else { - nse <- asNamespace("generics") - } + + nse <- asNamespace("generics") method_stub <- find_S3_class("tidy", mods[[i]], package = "generics") - if (getRversion() < "3.5") { - # getS3method() only available in R >= 3.3 - the_method <- get(paste0("tidy.", method_stub), nse, - mode = "function") - } else { - the_method <- utils::getS3method("tidy", method_stub, envir = nse) - } + the_method <- utils::getS3method("tidy", method_stub, envir = nse) + if (!is.null(ex_args)) { method_args <- formals(the_method) @@ -576,6 +565,13 @@ make_tidies <- function(mods, ex_args, ci_level, model.names, omit.coefs, # Combine the tidy frames into one, long frame tidies <- do.call(rbind, tidies) + + # Check if we have any rows. Mostly so I can give a more informative message + # if it goes to zero due to the coef filters later. + if (nrow(tidies) == 0) { + stop_wrap("The coefficient table for your model(s) is empty. It's not due to + the `coefs` or `omit.coefs` arguments.") + } # For consistency in creating the factors apply contrived names to model.names if (is.null(model.names)) { @@ -584,7 +580,12 @@ make_tidies <- function(mods, ex_args, ci_level, model.names, omit.coefs, # Drop omitted coefficients if (!is.null(omit.coefs)) { - tidies <- tidies[tidies$term %nin% omit.coefs,] + if (coefs.match == "exact") { + tidies <- tidies[tidies$term %nin% omit.coefs,] + } else { + # this rowSums/sapply approach lets me deal with vector inputs + tidies <- tidies[rowSums(sapply(omit.coefs, grepl, tidies$term)) == 0,] + } } # Creating factors with consistent ordering for coefficients too @@ -592,11 +593,27 @@ make_tidies <- function(mods, ex_args, ci_level, model.names, omit.coefs, coefs <- unique(tidies$term) names(coefs) <- coefs } else { - tidies <- tidies[tidies$term %in% coefs,] - if (is.null(names(coefs))) { + if (coefs.match == "exact") { + tidies <- tidies[tidies$term %in% coefs,] + if (is.null(names(coefs))) { + names(coefs) <- coefs + } + } else { + # User can't really pass preferred names for coefficients with partial + # matching so I need to grab the names and name the vector. + the_coefs <- tidies$term[rowSums(sapply(coefs, grepl, tidies$term)) > 0] + # Now filter the data frame + tidies <- tidies[rowSums(sapply(coefs, grepl, tidies$term)) > 0,] + coefs <- the_coefs names(coefs) <- coefs } } + + if (nrow(tidies) == 0) { + stop_wrap("After applying filters from the `coefs` and `omit.coefs` + arguments, there are no coefficients left. Check for errors + in your inputs to those arguments.") + } # For some reason, the order of the legend and the dodged colors # only line up when they are reversed here and in the limits arg of diff --git a/R/programming_helpers.R b/R/programming_helpers.R index 733594ed..6ccca9cd 100644 --- a/R/programming_helpers.R +++ b/R/programming_helpers.R @@ -288,7 +288,7 @@ give_back <- function(x) { } c_orange <- function(...) { if (!is.rstudio()) { - orange <- crayon::make_style("orange") + orange <- cli::make_ansi_style("orange") orange(...) } else { give_back(...) @@ -296,14 +296,14 @@ c_orange <- function(...) { } c_red <- function(...) { if (!is.rstudio()) { - crayon::red(...) + cli::col_red(...) } else { give_back(...) } } c_cyan <- function(...) { if (!is.rstudio()) { - crayon::cyan(...) + cli::col_cyan(...) } else { give_back(...) } @@ -399,7 +399,6 @@ warn_wrap <- function(..., brk = "\n", class = NULL, call. = FALSE) { # Like cat_wrap but for errors #' @rdname wrap_str -#' @importFrom crayon red #' @export stop_wrap <- function(..., brk = "\n", trace = rlang::trace_back(bottom = rlang::caller_env()), @@ -413,7 +412,6 @@ stop_wrap <- function(..., brk = "\n", } # Like cat_wrap but for messages -#' @importFrom crayon cyan #' @rdname wrap_str #' @export msg_wrap <- function(..., class = NULL, brk = "\n") { diff --git a/R/summ.R b/R/summ.R index 9147c894..7823708d 100755 --- a/R/summ.R +++ b/R/summ.R @@ -20,7 +20,8 @@ #' #' @export #' @importFrom stats nobs -#' +#' @import cli +#' summ <- function(model, ...) { @@ -396,7 +397,6 @@ summ.lm <- function( ### PRINT METHOD #' @export -#' @importFrom crayon underline inverse italic print.summ.lm <- function(x, ...) { @@ -413,11 +413,11 @@ print.summ.lm <- function(x, ...) { } if (x$model.fit == TRUE && !is.null(x$modpval)) { - stats <- paste(italic("F"), "(", x$fnum, ",", x$fden, ") = ", - num_print(x$fstat, digits = x$digits), ", ", italic("p"), " = ", + stats <- paste(style_italic("F"), "(", x$fnum, ",", x$fden, ") = ", + num_print(x$fstat, digits = x$digits), ", ", style_italic("p"), " = ", num_print(x$modpval, digits = x$digits), "\n", - italic("R\u00B2 = "), num_print(x$rsq, digits = x$digits), "\n", - italic("Adj. R\u00B2 = "), num_print(x$arsq, digits = x$digits), + style_italic("R\u00B2 = "), num_print(x$rsq, digits = x$digits), "\n", + style_italic("Adj. R\u00B2 = "), num_print(x$arsq, digits = x$digits), sep = "") print_mod_fit(stats) } @@ -442,12 +442,7 @@ print.summ.lm <- function(x, ...) { #' @param options Chunk options. #' @param ... Ignored. #' @rdname knit_print.summ -#' @rawNamespace -#' if (getRversion() >= "3.6.0") { -#' S3method(knitr::knit_print, summ.lm) -#' } else { -#' export(knit_print.summ.lm) -#' } +#' @exportS3Method knitr::knit_print knit_print.summ.lm <- function(x, options = NULL, ...) { @@ -851,9 +846,9 @@ print.summ.glm <- function(x, ...) { type <- "Linear regression" } else { type <- paste("Generalized linear model\n ", - italic("Family:"), + style_italic("Family:"), as.character(x$lmFamily[1]), "\n ", - italic("Link function:"), + style_italic("Link function:"), as.character(x$lmFamily[2]), sep = " ") } print_mod_info(missing = x$missing, n = x$n, dv = x$dv, type = type) @@ -862,13 +857,13 @@ print.summ.glm <- function(x, ...) { if (x$model.fit == TRUE) { stats <- paste("\u03C7\u00B2(", x$chisq$df, ") = ", num_print(x$chisq$chi, x$digits), ", ", - italic("p"), " = ", num_print(x$chisq$p, x$digits), "\n", - italic("Pseudo-R\u00B2 (Cragg-Uhler)"), " = ", + style_italic("p"), " = ", num_print(x$chisq$p, x$digits), "\n", + style_italic("Pseudo-R\u00B2 (Cragg-Uhler)"), " = ", num_print(x$rsq, digits = x$digits), "\n", - italic("Pseudo-R\u00B2 (McFadden)"), " = ", + style_italic("Pseudo-R\u00B2 (McFadden)"), " = ", num_print(x$rsqmc, digits = x$digits), "\n", - italic("AIC"), " = ", num_print(x$aic, x$digits), - ", ", italic("BIC"), " = ", num_print(x$bic, x$digits), + style_italic("AIC"), " = ", num_print(x$aic, x$digits), + ", ", style_italic("BIC"), " = ", num_print(x$bic, x$digits), sep = "") print_mod_fit(stats) } @@ -893,12 +888,7 @@ print.summ.glm <- function(x, ...) { #' @rdname knit_print.summ -#' @rawNamespace -#' if (getRversion() >= "3.6.0") { -#' S3method(knitr::knit_print, summ.glm) -#' } else { -#' export(knit_print.summ.glm) -#' } +#' @exportS3Method knitr::knit_print knit_print.summ.glm <- function(x, options = NULL, ...) { @@ -964,10 +954,12 @@ knit_print.summ.glm <- function(x, options = NULL, ...) { chi <- "chi\u00B2(" } stats <- data.frame(stat = c(paste0(chi, x$chisq$df, ")"), + "p", "Pseudo-R\u00B2 (Cragg-Uhler)", "Pseudo-R\u00B2 (McFadden)", "AIC", "BIC"), value = c(num_print(x$chisq$chi, x$digits), + num_print(x$chisq$p, x$digits), num_print(x$rsq, digits = x$digits), num_print(x$rsqmc, digits = x$digits), num_print(x$aic, x$digits), @@ -1338,8 +1330,8 @@ print.summ.svyglm <- function(x, ...) { } else { # Otherwise just treat it like glm type <- paste("Analysis of complex survey design", "\n", - italic("Family:"), as.character(x$lmFamily[1]), - "\n", italic("Link function:"), as.character(x$lmFamily[2]), + style_italic("Family:"), as.character(x$lmFamily[1]), + "\n", style_italic("Link function:"), as.character(x$lmFamily[2]), sep = " ") } print_mod_info(missing = x$missing, n = x$n, dv = x$dv, type = type) @@ -1349,17 +1341,17 @@ print.summ.svyglm <- function(x, ...) { if (as.character(x$lmFamily[1]) == "gaussian" && as.character(x$lmFamily[2]) == "identity") { # If it's a linear model, show regular lm fit stats - stats <- paste(italic("R\u00B2"), " = ", + stats <- paste(style_italic("R\u00B2"), " = ", num_print(x$rsq, digits = x$digits), "\n", - italic("Adj. R\u00B2"), " = ", + style_italic("Adj. R\u00B2"), " = ", num_print(x$arsq, digits = x$digits), sep = "") } else { # If it isn't linear, show GLM fit stats - stats <- paste(italic("Pseudo-R\u00B2 (Cragg-Uhler)"), " = ", + stats <- paste(style_italic("Pseudo-R\u00B2 (Cragg-Uhler)"), " = ", num_print(x$rsq, digits = x$digits), "\n", - italic("Pseudo-R\u00B2 (McFadden)"), " = ", + style_italic("Pseudo-R\u00B2 (McFadden)"), " = ", num_print(x$rsqmc, digits = x$digits), "\n", - italic("AIC"), " = ", num_print(x$aic, x$digits), sep = "") + style_italic("AIC"), " = ", num_print(x$aic, x$digits), sep = "") } print_mod_fit(stats) } @@ -1385,12 +1377,7 @@ print.summ.svyglm <- function(x, ...) { } #' @rdname knit_print.summ -#' @rawNamespace -#' if (getRversion() >= "3.6.0") { -#' S3method(knitr::knit_print, summ.svyglm) -#' } else { -#' export(knit_print.summ.svyglm) -#' } +#' @exportS3Method knitr::knit_print knit_print.summ.svyglm <- function(x, options = NULL, ...) { @@ -1680,6 +1667,7 @@ knit_print.summ.svyglm <- function(x, options = NULL, ...) { #' #' @importFrom stats coef coefficients lm predict sd cooks.distance pf logLik #' AIC BIC family fitted pt residuals terms model.weights +#' @importFrom rlang check_installed is_installed #' @export #' @aliases j_summ.merMod #' @@ -1759,15 +1747,16 @@ summ.merMod <- function( if (requireNamespace("lmerTest", quietly = TRUE)) { satt <- TRUE } else { - stop_wrap("You have requested Satterthwaite p values but you do - not have the lmerTest package installed.") + check_installed("lmerTest", reason = + "The lmerTest package is required for Satterthwaite d.f.") } } else if (t.df %in% c("k-r", "kenward-roger", "Kenward-Roger")) { if (requireNamespace("pbkrtest", quietly = TRUE)) { pbkr <- TRUE } else { - stop_wrap("You have requested Kenward-Roger p values but you do - not have the pbkrtest package installed.") + check_installed("pbkrtest", reason = + "The pbkrtest package is required for Kenward-Roger d.f." + ) } } else if (is.numeric(t.df) || t.df %in% c("resid", "residual")) { manual_df <- TRUE @@ -2006,29 +1995,29 @@ print.summ.merMod <- function(x, ...) { type <- "Mixed effects linear regression" } else { type <- paste("Mixed effects generalized linear regression", "\n", - italic("Error Distribution: "), + style_italic("Error Distribution: "), as.character(x$lmFamily[1]), "\n", - italic("Link function: "), as.character(x$lmFamily[2]), + style_italic("Link function: "), as.character(x$lmFamily[2]), sep = "") } print_mod_info(missing = x$missing, n = x$n, dv = x$dv, type = type) } if (x$model.fit == T) { - stats <- paste(italic("AIC"), " = ", num_print(x$aic, x$digits), - ", ", italic("BIC"), " = ", + stats <- paste(style_italic("AIC"), " = ", num_print(x$aic, x$digits), + ", ", style_italic("BIC"), " = ", num_print(x$bic, x$digits), sep = "") if (x$r.squared == TRUE) { - stats <- paste(stats, "\n", italic("Pseudo-R\u00B2 (fixed effects)"), + stats <- paste(stats, "\n", style_italic("Pseudo-R\u00B2 (fixed effects)"), " = ", num_print(x$rsq$Marginal, x$digits), "\n", - italic("Pseudo-R\u00B2 (total)"), " = ", + style_italic("Pseudo-R\u00B2 (total)"), " = ", num_print(x$rsq$Conditional, x$digits), sep = "") } print_mod_fit(stats) } if (x$model.coefs == TRUE) { - cat(underline("FIXED EFFECTS:\n")) + cat(style_underline("FIXED EFFECTS:\n")) print(md_table(ctable, format = getOption("summ.table.format", "multiline"), sig.digits = FALSE, digits = x$digits)) @@ -2037,8 +2026,8 @@ print.summ.merMod <- function(x, ...) { if (x$p_calc == "residual") { - cat(italic$cyan("\nNote: p values calculated based on residual d.f. =", - x$df, "\n")) + cat(style_italic(col_cyan( + "\nNote: p values calculated based on residual d.f. =", x$df, "\n"))) if (is.null(x$t.df)) { msg_wrap("Using p values with lmer based on residual d.f. may inflate @@ -2050,18 +2039,18 @@ print.summ.merMod <- function(x, ...) { } else if (x$p_calc %in% c("k-r", "Kenward-Roger", "kenward-roger")) { cat("\n") - cat_wrap(italic$cyan("p values calculated using Kenward-Roger standard - errors and d.f."), brk = "\n") + cat_wrap(style_italic(col_cyan("p values calculated using Kenward-Roger + standard errors and d.f.")), brk = "\n") } else if (x$p_calc %in% c("s", "Satterthwaite", "satterthwaite")) { cat("\n") - cat_wrap(italic$cyan("p values calculated using Satterthwaite - d.f."), brk = "\n") + cat_wrap(style_italic(col_cyan("p values calculated using Satterthwaite + d.f.")), brk = "\n") } else if (x$p_calc == "manual") { - cat(italic("\nNote: p values calculated based on user-defined d.f. ="), + cat(style_italic("\nNote: p values calculated based on user-defined d.f. ="), x$df, "\n") } @@ -2069,7 +2058,7 @@ print.summ.merMod <- function(x, ...) { } if (x$re.table == TRUE) { - cat(underline("\nRANDOM EFFECTS:\n")) + cat(style_underline("\nRANDOM EFFECTS:\n")) rtable <- round_df_char(j$rcoeftable, digits = x$digits, na_vals = "") #rownames(rtable) <- rep("", times = nrow(rtable)) # print(rtable, row.names = FALSE) @@ -2079,7 +2068,7 @@ print.summ.merMod <- function(x, ...) { } if (x$groups.table == TRUE) { - cat(underline("\nGrouping variables:\n")) + cat(style_underline("\nGrouping variables:\n")) gtable <- round_df_char(j$gvars, digits = x$digits, na_vals = "") gtable[, "# groups"] <- as.integer(gtable[, "# groups"]) #rownames(gtable) <- rep("", times = nrow(gtable)) @@ -2098,12 +2087,7 @@ print.summ.merMod <- function(x, ...) { } #' @rdname knit_print.summ -#' @rawNamespace -#' if (getRversion() >= "3.6.0") { -#' S3method(knitr::knit_print, summ.merMod) -#' } else { -#' export(knit_print.summ.merMod) -#' } +#' @exportS3Method knitr::knit_print knit_print.summ.merMod <- function(x, options = NULL, ...) { diff --git a/R/summ_helpers.R b/R/summ_helpers.R index b411a5b8..345b8581 100644 --- a/R/summ_helpers.R +++ b/R/summ_helpers.R @@ -86,7 +86,7 @@ round_df_char <- function(df, digits, pad = " ", na_vals = NA) { #' @param type One of `"HC3"`, `"const"`, `"HC"`, `"HC0"`, `"HC1"`, #' `"HC2"`, `"HC4"`, `"HC4m"`, `"HC5"`. See [sandwich::vcovHC()] for some #' more details on these choices. Note that some of these do not work for -#' clustered standard errors (see sandwich::vcovCL()]). +#' clustered standard errors (see [sandwich::vcovCL()]). #' @param data The data used to fit the model. Default is to just get the #' `model.frame` from `model`. #' @param cluster If you want clustered standard errors, either a string naming @@ -113,11 +113,6 @@ round_df_char <- function(df, digits, pad = " ", na_vals = NA) { get_robust_se <- function(model, type = "HC3", cluster = NULL, data = model.frame(model), vcov = NULL) { - if (!requireNamespace("sandwich", quietly = TRUE)) { - stop_wrap("When using robust SEs you need to have the \'sandwich\' - package.", call. = FALSE) - } - if (type == TRUE) { type <- "HC3" } @@ -439,16 +434,16 @@ vif <- function(mod, vcov = NULL, mod.matrix = NULL, ...) { print_mod_info <- function(missing, n, dv, type) { if (is.null(missing) || missing == 0) { - cat(underline("MODEL INFO:"), "\n", - italic("Observations:"), " ", n, "\n", - italic("Dependent Variable:"), " ", dv, "\n", sep = "") + cat(style_underline("MODEL INFO:"), "\n", + style_italic("Observations:"), " ", n, "\n", + style_italic("Dependent Variable:"), " ", dv, "\n", sep = "") } else { - cat(underline("MODEL INFO:"), "\n", - italic("Observations:"), " ", n, " (", missing, + cat(style_underline("MODEL INFO:"), "\n", + style_italic("Observations:"), " ", n, " (", missing, " missing obs. deleted)", "\n", - italic("Dependent Variable:"), " ", dv, "\n", sep = "") + style_italic("Dependent Variable:"), " ", dv, "\n", sep = "") } - cat(italic("Type:"), type, "\n\n") + cat(style_italic("Type:"), type, "\n\n") } ## Take model info and save as list @@ -464,7 +459,7 @@ mod_info_list <- function(missing, n, dv, type) { ## Print model fit info print_mod_fit <- function(stats) { - cat(underline("MODEL FIT:"), "\n", sep = "") + cat(style_underline("MODEL FIT:"), "\n", sep = "") cat(stats, "\n\n") } @@ -474,7 +469,7 @@ print_se_info <- function(robust, use_cluster, manual = NULL, vcov = NULL, ...) if (identical(FALSE, robust) && is.null(vcov)) { - cat(italic("Standard errors:", ifelse(is.null(manual), + cat(style_italic("Standard errors:", ifelse(is.null(manual), no = manual, yes = "MLE")), "\n", sep = "") @@ -482,15 +477,15 @@ print_se_info <- function(robust, use_cluster, manual = NULL, vcov = NULL, ...) if (robust == TRUE) {robust <- "HC3"} - cat(italic("Standard errors:"), sep = "") + cat(style_italic("Standard errors:"), sep = "") if (use_cluster == FALSE) { - cat(" Robust, ", italic("type = "), robust, "\n", sep = "") + cat(" Robust, ", style_italic("type = "), robust, "\n", sep = "") } else if (use_cluster == TRUE) { - cat(" Cluster-robust, ", italic("type = "), robust, "\n", sep = "") + cat(" Cluster-robust, ", style_italic("type = "), robust, "\n", sep = "") } diff --git a/R/summ_rq.R b/R/summ_rq.R index 59622117..e90f6bf2 100644 --- a/R/summ_rq.R +++ b/R/summ_rq.R @@ -225,7 +225,6 @@ summ.rq <- function(model, scale = FALSE, ### PRINT METHOD #' @export -#' @importFrom crayon underline inverse italic print.summ.rq <- function(x, ...) { @@ -249,13 +248,13 @@ print.summ.rq <- function(x, ...) { "fnc" = "Frisch-Newton (user-specified equality constraints)") type <- paste0("Quantile regression", - "\n ", italic("Quantile (tau): "), j$model$tau, "\n ", - italic("Method: "), method) + "\n ", style_italic("Quantile (tau): "), j$model$tau, "\n ", + style_italic("Method: "), method) print_mod_info(missing = x$missing, n = x$n, dv = x$dv, type = type) } if (x$model.fit == TRUE) { - stats <- paste(italic("R\u00B9"), paste0("(", j$model$tau, ")"), " = ", + stats <- paste(style_italic("R\u00B9"), paste0("(", j$model$tau, ")"), " = ", num_print(x$r1, digits = x$digits), sep = "") print_mod_fit(stats) } @@ -280,12 +279,7 @@ print.summ.rq <- function(x, ...) { } #' @rdname knit_print.summ -#' @rawNamespace -#' if (getRversion() >= "3.6.0") { -#' S3method(knitr::knit_print, summ.rq) -#' } else { -#' export(knit_print.summ.rq) -#' } +#' @exportS3Method knitr::knit_print knit_print.summ.rq <- function(x, options = NULL, ...) { @@ -341,7 +335,7 @@ knit_print.summ.rq <- function(x, options = NULL, ...) { } if (x$model.fit == T && !is.null(x$modpval)) { - stats <- paste(italic("R\u00B9"), paste0("(", j$model$tau, ")"), " = ", + stats <- paste(style_italic("R\u00B9"), paste0("(", j$model$tau, ")"), " = ", num_print(x$r1, digits = x$digits), sep = "") stats <- data.frame(stat = c(paste0("R\u00B9 ", "(", j$model$tau, ")")), value = c(num_print(x$r1, digits = x$digits)) @@ -414,12 +408,7 @@ rq.fit.br <- function(x, y, tau = 0.5, alpha = 0.1, ci = FALSE, #' @rdname glance.summ -#' @rawNamespace -#' if (getRversion() >= "3.6.0") { -#' S3method(generics::glance, summ.rq) -#' } else { -#' export(glance.summ.rq) -#' } +#' @export glance.summ.rq <- function(x, ...) { diff --git a/R/svytools.R b/R/svytools.R index 62d01a04..87baf7e3 100644 --- a/R/svytools.R +++ b/R/svytools.R @@ -332,11 +332,7 @@ print.wgttest <- function(x, ...) { pf_sv_test <- function(model, data = NULL, weights, sims = 1000, digits = getOption("jtools-digits", default = 3)) { - if (!requireNamespace("boot", quietly = TRUE)) { - stop("This function relies on the boot package.\n", - "Please install it and try again.", - call. = FALSE) - } + check_installed("boot", reason = "This function requires the boot package.") # Need to parse the arguments if (length(as.character(substitute(weights))) == 1 && @@ -697,10 +693,9 @@ svycor <- function(formula, design, na.rm = FALSE, return(c) } else { - if (!requireNamespace("weights", quietly = TRUE)) { - stop("p-value calculations require the 'weights' package.") - } - + check_installed("weights", reason = + "p-value calculations require the 'weights' package." + ) # Use wtd.cor wcors <- weights::wtd.cor(mf, weight = wts, bootse = TRUE, mean1 = mean1, bootn = bootn, bootp = TRUE) @@ -716,10 +711,7 @@ svycor <- function(formula, design, na.rm = FALSE, } - - #' @export - print.svycor <- function(x, ...) { if (x$sig.stats == FALSE) { diff --git a/R/theme_apa.R b/R/theme_apa.R index 6c288f92..da0d94ef 100644 --- a/R/theme_apa.R +++ b/R/theme_apa.R @@ -106,7 +106,7 @@ theme_apa <- function(legend.pos = "right", legend.use.title = FALSE, strip.text.x = ggplot2::element_text(size = facet.title.size), # facet labs strip.text.y = ggplot2::element_text(size = facet.title.size), # facet titles - strip.background = ggplot2::element_rect(colour = "white", fill = "white"), + strip.background = ggplot2::element_rect(colour = NA, fill = NA), panel.background = ggplot2::element_rect(fill = "white"), plot.title.position = "panel", # complete = TRUE diff --git a/man/center.Rd b/man/center.Rd index 3a6196cf..1ae5628d 100644 --- a/man/center.Rd +++ b/man/center.Rd @@ -52,7 +52,7 @@ standardize(mtcars, vars = "qsec") } \seealso{ -Other standardization: +standardization, scaling, and centering tools \code{\link{center_mod}()}, \code{\link{gscale}()}, \code{\link{scale_mod}()}, diff --git a/man/center_mod.Rd b/man/center_mod.Rd index 299f43da..608d09da 100644 --- a/man/center_mod.Rd +++ b/man/center_mod.Rd @@ -106,7 +106,7 @@ ed.). Mahwah, NJ: Lawrence Erlbaum Associates, Inc. \code{\link{interact_plot}} creates attractive, user-configurable plots of interaction models. -Other standardization: +standardization, scaling, and centering tools \code{\link{center}()}, \code{\link{gscale}()}, \code{\link{scale_mod}()}, diff --git a/man/effect_plot.Rd b/man/effect_plot.Rd index be8f3b19..31f2e4e6 100644 --- a/man/effect_plot.Rd +++ b/man/effect_plot.Rd @@ -38,6 +38,7 @@ effect_plot( cat.pred.point.size = 3.5, partial.residuals = FALSE, color.class = colors, + facet.by = NULL, ... ) } @@ -214,6 +215,14 @@ the partial residuals (controlling for the effects of variables besides \item{color.class}{Deprecated. Now known as \code{colors}.} +\item{facet.by}{A variable in the data by which you want to plot the +effects separately. This will cause the plot to include multiple panels, +basically a separate plot for each unique value of the variable in +\code{facet.by}. This will be most useful when plotting effects from multilevel +models (e.g., as fit by \code{lme4}'s models) with a random slope for the +\code{pred} variable. You should generally only want to use this if you expect +the different panels to look meaningfully different. Default is \code{NULL}.} + \item{...}{extra arguments passed to \code{make_predictions()}} } \value{ diff --git a/man/get_robust_se.Rd b/man/get_robust_se.Rd index 3b5ccb15..57d7e3c0 100644 --- a/man/get_robust_se.Rd +++ b/man/get_robust_se.Rd @@ -18,7 +18,7 @@ get_robust_se( \item{type}{One of \code{"HC3"}, \code{"const"}, \code{"HC"}, \code{"HC0"}, \code{"HC1"}, \code{"HC2"}, \code{"HC4"}, \code{"HC4m"}, \code{"HC5"}. See \code{\link[sandwich:vcovHC]{sandwich::vcovHC()}} for some more details on these choices. Note that some of these do not work for -clustered standard errors (see sandwich::vcovCL()]).} +clustered standard errors (see \code{\link[sandwich:vcovCL]{sandwich::vcovCL()}}).} \item{cluster}{If you want clustered standard errors, either a string naming the column in \code{data} that represents the clusters or a vector of clusters diff --git a/man/gscale.Rd b/man/gscale.Rd index c049e5b1..5ffd1edc 100644 --- a/man/gscale.Rd +++ b/man/gscale.Rd @@ -163,9 +163,9 @@ open access) regression models. On request, it will center and/or standardize variables before printing its output. -Other standardization: -\code{\link{center_mod}()}, +standardization, scaling, and centering tools \code{\link{center}()}, +\code{\link{center_mod}()}, \code{\link{scale_mod}()}, \code{\link{standardize}()} } diff --git a/man/knit_print.summ.Rd b/man/knit_print.summ.Rd index 1d33e645..5544ca81 100644 --- a/man/knit_print.summ.Rd +++ b/man/knit_print.summ.Rd @@ -8,15 +8,15 @@ \alias{knit_print.summ.rq} \title{knitr methods for summ} \usage{ -knit_print.summ.lm(x, options = NULL, ...) +\method{knit_print}{summ.lm}(x, options = NULL, ...) -knit_print.summ.glm(x, options = NULL, ...) +\method{knit_print}{summ.glm}(x, options = NULL, ...) -knit_print.summ.svyglm(x, options = NULL, ...) +\method{knit_print}{summ.svyglm}(x, options = NULL, ...) -knit_print.summ.merMod(x, options = NULL, ...) +\method{knit_print}{summ.merMod}(x, options = NULL, ...) -knit_print.summ.rq(x, options = NULL, ...) +\method{knit_print}{summ.rq}(x, options = NULL, ...) } \arguments{ \item{x}{The \code{summ} object} diff --git a/man/plot_summs.Rd b/man/plot_summs.Rd index 8e037a15..130108ae 100644 --- a/man/plot_summs.Rd +++ b/man/plot_summs.Rd @@ -26,7 +26,8 @@ plot_summs( facet.label.pos = "top", color.class = colors, resp = NULL, - dpar = NULL + dpar = NULL, + coefs.match = c("exact", "regex") ) plot_coefs( @@ -50,7 +51,8 @@ plot_coefs( facet.label.pos = "top", color.class = colors, resp = NULL, - dpar = NULL + dpar = NULL, + coefs.match = c("exact", "regex") ) } \arguments{ @@ -137,6 +139,14 @@ you only need to provide a vector of length 2 for \code{resp}.} dependent variable, that can be specified here. If NULL, it is assumed you want coefficients for the location/mean parameter, not the distributional parameter(s).} + +\item{coefs.match}{This modifies the way the \code{coefs} and \code{omit.coefs} +arguments are interpreted. The default \code{"exact"} which represents the +legacy behavior, will include/exclude coefficients that match exactly +with your inputs to those functions. If \code{"regex"}, \code{coefs} and +\code{omit.coefs} are used as the \code{pattern} argument for \code{\link[=grepl]{grepl()}} matching +the coefficient names. Note that using \code{"regex"} means you will be unable +to override the default coefficient names via a named vector.} } \value{ A ggplot object. diff --git a/man/roxygen/meta.R b/man/roxygen/meta.R index fdf87079..6d9f21ec 100644 --- a/man/roxygen/meta.R +++ b/man/roxygen/meta.R @@ -1,3 +1,6 @@ -rd_family_title <- list( - standardization = "Standardization, scaling, and centering tools" +# finally solved this being ignored thanks to https://stackoverflow.com/q/60493979 +list( + rd_family_title = list( + standardization = "standardization, scaling, and centering tools" + ) ) \ No newline at end of file diff --git a/man/scale_mod.Rd b/man/scale_mod.Rd index f5c9befb..c5552117 100644 --- a/man/scale_mod.Rd +++ b/man/scale_mod.Rd @@ -134,9 +134,9 @@ ed.). Mahwah, NJ: Lawrence Erlbaum Associates, Inc. \code{\link{interact_plot}} creates attractive, user-configurable plots of interaction models. -Other standardization: -\code{\link{center_mod}()}, +standardization, scaling, and centering tools \code{\link{center}()}, +\code{\link{center_mod}()}, \code{\link{gscale}()}, \code{\link{standardize}()} } diff --git a/man/standardize.Rd b/man/standardize.Rd index b0f8b26b..16c872a9 100644 --- a/man/standardize.Rd +++ b/man/standardize.Rd @@ -53,9 +53,9 @@ standardize(mtcars, vars = "qsec") } \seealso{ -Other standardization: -\code{\link{center_mod}()}, +standardization, scaling, and centering tools \code{\link{center}()}, +\code{\link{center_mod}()}, \code{\link{gscale}()}, \code{\link{scale_mod}()} } diff --git a/tests/testthat/_snaps/effect-plot/brm-multiv-default-int.svg b/tests/testthat/_snaps/effect-plot/brm-multiv-default-int.svg index cd5c7f44..371cf1ba 100644 --- a/tests/testthat/_snaps/effect-plot/brm-multiv-default-int.svg +++ b/tests/testthat/_snaps/effect-plot/brm-multiv-default-int.svg @@ -51,6 +51,6 @@ 8 cyl mpg -mv default dv mpg +mv default dv mpg diff --git a/tests/testthat/_snaps/effect-plot/brm-multiv-default-sigma-int.svg b/tests/testthat/_snaps/effect-plot/brm-multiv-default-sigma-int.svg index 5762bf69..47bf9291 100644 --- a/tests/testthat/_snaps/effect-plot/brm-multiv-default-sigma-int.svg +++ b/tests/testthat/_snaps/effect-plot/brm-multiv-default-sigma-int.svg @@ -51,6 +51,6 @@ 8 cyl sigma -mv default dv mpg sigma +mv default dv mpg sigma diff --git a/tests/testthat/_snaps/effect-plot/brm-multiv-selected-int.svg b/tests/testthat/_snaps/effect-plot/brm-multiv-selected-int.svg index b26c32ca..ef48f015 100644 --- a/tests/testthat/_snaps/effect-plot/brm-multiv-selected-int.svg +++ b/tests/testthat/_snaps/effect-plot/brm-multiv-selected-int.svg @@ -53,6 +53,6 @@ 8 cyl wt -mv selected dv wt +mv selected dv wt diff --git a/tests/testthat/_snaps/effect-plot/brm-multiv-selected-sigma-int.svg b/tests/testthat/_snaps/effect-plot/brm-multiv-selected-sigma-int.svg index 3f2f16d9..1525c2af 100644 --- a/tests/testthat/_snaps/effect-plot/brm-multiv-selected-sigma-int.svg +++ b/tests/testthat/_snaps/effect-plot/brm-multiv-selected-sigma-int.svg @@ -49,6 +49,6 @@ 8 cyl sigma -mv selected dv wt sigma +mv selected dv wt sigma diff --git a/tests/testthat/_snaps/effect-plot/brm.svg b/tests/testthat/_snaps/effect-plot/brm.svg index 3a51095c..36d67ea3 100644 --- a/tests/testthat/_snaps/effect-plot/brm.svg +++ b/tests/testthat/_snaps/effect-plot/brm.svg @@ -55,6 +55,6 @@ 4 zBase count -brms +brms diff --git a/tests/testthat/_snaps/effect-plot/glm-bin-2col.svg b/tests/testthat/_snaps/effect-plot/glm-bin-2col.svg index 3f98caaa..605edf5d 100644 --- a/tests/testthat/_snaps/effect-plot/glm-bin-2col.svg +++ b/tests/testthat/_snaps/effect-plot/glm-bin-2col.svg @@ -53,6 +53,6 @@ 0.2 x cbind(y, t - y) -glm-bin-2col +glm-bin-2col diff --git a/tests/testthat/_snaps/effect-plot/glm-cat-bar-offset-no-int.svg b/tests/testthat/_snaps/effect-plot/glm-cat-bar-offset-no-int.svg index 78c1b20d..1019882a 100644 --- a/tests/testthat/_snaps/effect-plot/glm-cat-bar-offset-no-int.svg +++ b/tests/testthat/_snaps/effect-plot/glm-cat-bar-offset-no-int.svg @@ -47,6 +47,6 @@ 1 talent_f counts -categorical bar plot no intervals +categorical bar plot no intervals diff --git a/tests/testthat/_snaps/effect-plot/glm-cat-bar-offset.svg b/tests/testthat/_snaps/effect-plot/glm-cat-bar-offset.svg index ccbc665e..d1c6062c 100644 --- a/tests/testthat/_snaps/effect-plot/glm-cat-bar-offset.svg +++ b/tests/testthat/_snaps/effect-plot/glm-cat-bar-offset.svg @@ -47,6 +47,6 @@ 1 talent_f counts -categorical bar plot +categorical bar plot diff --git a/tests/testthat/_snaps/effect-plot/glm-cat-line-offset-no-int.svg b/tests/testthat/_snaps/effect-plot/glm-cat-line-offset-no-int.svg index 2c10e70e..f12b13ea 100644 --- a/tests/testthat/_snaps/effect-plot/glm-cat-line-offset-no-int.svg +++ b/tests/testthat/_snaps/effect-plot/glm-cat-line-offset-no-int.svg @@ -44,6 +44,6 @@ 1 talent_f counts -categorical line plot no intervals +categorical line plot no intervals diff --git a/tests/testthat/_snaps/effect-plot/glm-cat-line-offset.svg b/tests/testthat/_snaps/effect-plot/glm-cat-line-offset.svg index 05ae4aed..93a73237 100644 --- a/tests/testthat/_snaps/effect-plot/glm-cat-line-offset.svg +++ b/tests/testthat/_snaps/effect-plot/glm-cat-line-offset.svg @@ -52,6 +52,6 @@ 1 talent_f counts -categorical line plot +categorical line plot diff --git a/tests/testthat/_snaps/effect-plot/glm-cat-offset-partials.svg b/tests/testthat/_snaps/effect-plot/glm-cat-offset-partials.svg index 1544b7c5..1f1ee2ad 100644 --- a/tests/testthat/_snaps/effect-plot/glm-cat-offset-partials.svg +++ b/tests/testthat/_snaps/effect-plot/glm-cat-offset-partials.svg @@ -101,6 +101,6 @@ 1 talent_f counts -categorical, offset, partial residuals +categorical, offset, partial residuals diff --git a/tests/testthat/_snaps/effect-plot/glm-cat-offset-points.svg b/tests/testthat/_snaps/effect-plot/glm-cat-offset-points.svg index 09410faf..b24439ef 100644 --- a/tests/testthat/_snaps/effect-plot/glm-cat-offset-points.svg +++ b/tests/testthat/_snaps/effect-plot/glm-cat-offset-points.svg @@ -101,6 +101,6 @@ 1 talent_f counts -categorical, offset, plot points +categorical, offset, plot points diff --git a/tests/testthat/_snaps/effect-plot/glm-cat-offset.svg b/tests/testthat/_snaps/effect-plot/glm-cat-offset.svg index d225d31d..271b6293 100644 --- a/tests/testthat/_snaps/effect-plot/glm-cat-offset.svg +++ b/tests/testthat/_snaps/effect-plot/glm-cat-offset.svg @@ -51,6 +51,6 @@ 1 talent_f counts -categorical (plus offset) +categorical (plus offset) diff --git a/tests/testthat/_snaps/effect-plot/glm-offset-partials.svg b/tests/testthat/_snaps/effect-plot/glm-offset-partials.svg index 69196f89..3fa903fe 100644 --- a/tests/testthat/_snaps/effect-plot/glm-offset-partials.svg +++ b/tests/testthat/_snaps/effect-plot/glm-offset-partials.svg @@ -102,6 +102,6 @@ 3 money counts -offset plus partials +offset plus partials diff --git a/tests/testthat/_snaps/effect-plot/glm-offset-points.svg b/tests/testthat/_snaps/effect-plot/glm-offset-points.svg index b3a02df9..fc462aaa 100644 --- a/tests/testthat/_snaps/effect-plot/glm-offset-points.svg +++ b/tests/testthat/_snaps/effect-plot/glm-offset-points.svg @@ -102,6 +102,6 @@ 3 money counts -offset plus plot points +offset plus plot points diff --git a/tests/testthat/_snaps/effect-plot/glm-offset.svg b/tests/testthat/_snaps/effect-plot/glm-offset.svg index b1ef64c4..447388f5 100644 --- a/tests/testthat/_snaps/effect-plot/glm-offset.svg +++ b/tests/testthat/_snaps/effect-plot/glm-offset.svg @@ -48,6 +48,6 @@ 3 money counts -offset +offset diff --git a/tests/testthat/_snaps/effect-plot/glmer-offset.svg b/tests/testthat/_snaps/effect-plot/glmer-offset.svg index 6a25dbb9..d8f0a231 100644 --- a/tests/testthat/_snaps/effect-plot/glmer-offset.svg +++ b/tests/testthat/_snaps/effect-plot/glmer-offset.svg @@ -55,6 +55,6 @@ 4 period incidence -glmer + offset test +glmer + offset test diff --git a/tests/testthat/_snaps/effect-plot/glmer.svg b/tests/testthat/_snaps/effect-plot/glmer.svg index 1f9ec6a0..2ec9235e 100644 --- a/tests/testthat/_snaps/effect-plot/glmer.svg +++ b/tests/testthat/_snaps/effect-plot/glmer.svg @@ -50,6 +50,6 @@ 40 Anger r2 -glmer test +glmer test diff --git a/tests/testthat/_snaps/effect-plot/lm-all-centered.svg b/tests/testthat/_snaps/effect-plot/lm-all-centered.svg index 1c60e54b..c5590fc2 100644 --- a/tests/testthat/_snaps/effect-plot/lm-all-centered.svg +++ b/tests/testthat/_snaps/effect-plot/lm-all-centered.svg @@ -46,6 +46,6 @@ 12 Murder Income -All centered +All centered diff --git a/tests/testthat/_snaps/effect-plot/lm-one-centered.svg b/tests/testthat/_snaps/effect-plot/lm-one-centered.svg index da4ccb00..17516bd9 100644 --- a/tests/testthat/_snaps/effect-plot/lm-one-centered.svg +++ b/tests/testthat/_snaps/effect-plot/lm-one-centered.svg @@ -46,6 +46,6 @@ 12 Murder Income -HSGrad centered +HSGrad centered diff --git a/tests/testthat/_snaps/effect-plot/lm-partials-all-centered.svg b/tests/testthat/_snaps/effect-plot/lm-partials-all-centered.svg index 11843a38..27de4b37 100644 --- a/tests/testthat/_snaps/effect-plot/lm-partials-all-centered.svg +++ b/tests/testthat/_snaps/effect-plot/lm-partials-all-centered.svg @@ -96,6 +96,6 @@ 12 Murder Income -Partial residuals all centered +Partial residuals all centered diff --git a/tests/testthat/_snaps/effect-plot/lm-partials-one-centered.svg b/tests/testthat/_snaps/effect-plot/lm-partials-one-centered.svg index 2077597e..a9d0dcca 100644 --- a/tests/testthat/_snaps/effect-plot/lm-partials-one-centered.svg +++ b/tests/testthat/_snaps/effect-plot/lm-partials-one-centered.svg @@ -98,6 +98,6 @@ 12 Murder Income -Partial residuals HSGrad centered +Partial residuals HSGrad centered diff --git a/tests/testthat/_snaps/effect-plot/lm-points-all-centered.svg b/tests/testthat/_snaps/effect-plot/lm-points-all-centered.svg index 874482b7..52e141d7 100644 --- a/tests/testthat/_snaps/effect-plot/lm-points-all-centered.svg +++ b/tests/testthat/_snaps/effect-plot/lm-points-all-centered.svg @@ -96,6 +96,6 @@ 12 Murder Income -Plot points all centered +Plot points all centered diff --git a/tests/testthat/_snaps/effect-plot/lm-points-one-centered.svg b/tests/testthat/_snaps/effect-plot/lm-points-one-centered.svg index 0ed4f84a..8730112e 100644 --- a/tests/testthat/_snaps/effect-plot/lm-points-one-centered.svg +++ b/tests/testthat/_snaps/effect-plot/lm-points-one-centered.svg @@ -96,6 +96,6 @@ 12 Murder Income -Plot points HSGrad centered +Plot points HSGrad centered diff --git a/tests/testthat/_snaps/effect-plot/lm-robust.svg b/tests/testthat/_snaps/effect-plot/lm-robust.svg index d74c0d9f..f67b1ea5 100644 --- a/tests/testthat/_snaps/effect-plot/lm-robust.svg +++ b/tests/testthat/_snaps/effect-plot/lm-robust.svg @@ -46,6 +46,6 @@ 12 Murder Income -Robust intervals +Robust intervals diff --git a/tests/testthat/_snaps/effect-plot/lm-rug-sides-lb.svg b/tests/testthat/_snaps/effect-plot/lm-rug-sides-lb.svg index b6f9a9ef..e9c19355 100644 --- a/tests/testthat/_snaps/effect-plot/lm-rug-sides-lb.svg +++ b/tests/testthat/_snaps/effect-plot/lm-rug-sides-lb.svg @@ -146,6 +146,6 @@ 12 Murder Income -Rug sides 'lb' +Rug sides 'lb' diff --git a/tests/testthat/_snaps/effect-plot/lm-rug.svg b/tests/testthat/_snaps/effect-plot/lm-rug.svg index 9a379de0..5c5cc115 100644 --- a/tests/testthat/_snaps/effect-plot/lm-rug.svg +++ b/tests/testthat/_snaps/effect-plot/lm-rug.svg @@ -146,6 +146,6 @@ 12 Murder Income -Rug default +Rug default diff --git a/tests/testthat/_snaps/effect-plot/lmer-partials.svg b/tests/testthat/_snaps/effect-plot/lmer-partials.svg index 4c676fcd..99483887 100644 --- a/tests/testthat/_snaps/effect-plot/lmer-partials.svg +++ b/tests/testthat/_snaps/effect-plot/lmer-partials.svg @@ -535,7 +535,7 @@ - + 0.0 @@ -548,6 +548,6 @@ 40 Anger as.numeric(r2 == "Y") -lmer test + partial residuals +lmer test + partial residuals diff --git a/tests/testthat/_snaps/effect-plot/lmer-points.svg b/tests/testthat/_snaps/effect-plot/lmer-points.svg index 1ad82bab..81c4ece4 100644 --- a/tests/testthat/_snaps/effect-plot/lmer-points.svg +++ b/tests/testthat/_snaps/effect-plot/lmer-points.svg @@ -550,6 +550,6 @@ 40 Anger as.numeric(r2 == "Y") -lmer test + plot points +lmer test + plot points diff --git a/tests/testthat/_snaps/effect-plot/lmer.svg b/tests/testthat/_snaps/effect-plot/lmer.svg index b4d0cadf..b243eda7 100644 --- a/tests/testthat/_snaps/effect-plot/lmer.svg +++ b/tests/testthat/_snaps/effect-plot/lmer.svg @@ -52,6 +52,6 @@ 40 Anger as.numeric(r2 == "Y") -lmer test +lmer test diff --git a/tests/testthat/_snaps/effect-plot/rstanarm-facet.svg b/tests/testthat/_snaps/effect-plot/rstanarm-facet.svg new file mode 100644 index 00000000..f50f3a70 --- /dev/null +++ b/tests/testthat/_snaps/effect-plot/rstanarm-facet.svg @@ -0,0 +1,556 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +13 + + + + + + + + + +14 + + + + + + + + + +15 + + + + + + + + + + + + + + + + + + +9 + + + + + + + + + +10 + + + + + + + + + +11 + + + + + + + + + +12 + + + + + + + + + +5 + + + + + + + + + +6 + + + + + + + + + +7 + + + + + + + + + +8 + + + + + + + + + +1 + + + + + + + + + +2 + + + + + + + + + +3 + + + + + + + + + +4 + + +10 +20 +30 +10 +20 +30 +10 +20 +30 +10 +20 +30 +0 +5 +10 +15 +20 +0 +5 +10 +15 +20 +0 +5 +10 +15 +20 +0 +5 +10 +15 +20 +size +incidence +stanreg facet.by + + diff --git a/tests/testthat/_snaps/effect-plot/rstanarm.svg b/tests/testthat/_snaps/effect-plot/rstanarm.svg index 0407055b..dee4682a 100644 --- a/tests/testthat/_snaps/effect-plot/rstanarm.svg +++ b/tests/testthat/_snaps/effect-plot/rstanarm.svg @@ -51,6 +51,6 @@ 30 size incidence -stanreg +stanreg diff --git a/tests/testthat/_snaps/effect-plot/svyglm-all-centered-partials.svg b/tests/testthat/_snaps/effect-plot/svyglm-all-centered-partials.svg index 731127ce..a9da076a 100644 --- a/tests/testthat/_snaps/effect-plot/svyglm-all-centered-partials.svg +++ b/tests/testthat/_snaps/effect-plot/svyglm-all-centered-partials.svg @@ -252,6 +252,6 @@ 100 meals api00 -svyglm partial residuals +svyglm partial residuals diff --git a/tests/testthat/_snaps/effect-plot/svyglm-all-centered-points.svg b/tests/testthat/_snaps/effect-plot/svyglm-all-centered-points.svg index 293dde66..5aea4731 100644 --- a/tests/testthat/_snaps/effect-plot/svyglm-all-centered-points.svg +++ b/tests/testthat/_snaps/effect-plot/svyglm-all-centered-points.svg @@ -254,6 +254,6 @@ 100 meals api00 -svyglm plot points +svyglm plot points diff --git a/tests/testthat/_snaps/effect-plot/svyglm-binomial.svg b/tests/testthat/_snaps/effect-plot/svyglm-binomial.svg index b8e585e9..747c6977 100644 --- a/tests/testthat/_snaps/effect-plot/svyglm-binomial.svg +++ b/tests/testthat/_snaps/effect-plot/svyglm-binomial.svg @@ -50,6 +50,6 @@ 100 mobility sch.wide -svyglm binomial +svyglm binomial diff --git a/tests/testthat/_snaps/effect-plot/svyglm-one-centered.svg b/tests/testthat/_snaps/effect-plot/svyglm-one-centered.svg index 86f655c1..5c6f280e 100644 --- a/tests/testthat/_snaps/effect-plot/svyglm-one-centered.svg +++ b/tests/testthat/_snaps/effect-plot/svyglm-one-centered.svg @@ -48,6 +48,6 @@ 100 meals api00 -svyglm ell centered +svyglm ell centered diff --git a/tests/testthat/_snaps/effect-plot/svyglm.svg b/tests/testthat/_snaps/effect-plot/svyglm.svg index ce62323a..d0aec5e6 100644 --- a/tests/testthat/_snaps/effect-plot/svyglm.svg +++ b/tests/testthat/_snaps/effect-plot/svyglm.svg @@ -48,6 +48,6 @@ 100 meals api00 -svyglm +svyglm diff --git a/tests/testthat/_snaps/effect-plot/wlm-all-centered.svg b/tests/testthat/_snaps/effect-plot/wlm-all-centered.svg index f52d5286..2f4f184c 100644 --- a/tests/testthat/_snaps/effect-plot/wlm-all-centered.svg +++ b/tests/testthat/_snaps/effect-plot/wlm-all-centered.svg @@ -46,6 +46,6 @@ 12 Murder Income -Weighted lm +Weighted lm diff --git a/tests/testthat/_snaps/effect-plot/wlm-one-centered-robust-partials.svg b/tests/testthat/_snaps/effect-plot/wlm-one-centered-robust-partials.svg index 9163625a..ab107630 100644 --- a/tests/testthat/_snaps/effect-plot/wlm-one-centered-robust-partials.svg +++ b/tests/testthat/_snaps/effect-plot/wlm-one-centered-robust-partials.svg @@ -101,6 +101,6 @@ 12 Murder Income -Weighted lm HSGrad centered, robust, partial residuals +Weighted lm HSGrad centered, robust, partial residuals diff --git a/tests/testthat/_snaps/effect-plot/wlm-one-centered-robust-points.svg b/tests/testthat/_snaps/effect-plot/wlm-one-centered-robust-points.svg index d7a5a5a1..7e17b2e0 100644 --- a/tests/testthat/_snaps/effect-plot/wlm-one-centered-robust-points.svg +++ b/tests/testthat/_snaps/effect-plot/wlm-one-centered-robust-points.svg @@ -101,6 +101,6 @@ 12 Murder Income -Weighted lm HSGrad centered, robust, plot points +Weighted lm HSGrad centered, robust, plot points diff --git a/tests/testthat/_snaps/effect-plot/wlm-one-centered-robust.svg b/tests/testthat/_snaps/effect-plot/wlm-one-centered-robust.svg index 0623f7f3..1239ff0f 100644 --- a/tests/testthat/_snaps/effect-plot/wlm-one-centered-robust.svg +++ b/tests/testthat/_snaps/effect-plot/wlm-one-centered-robust.svg @@ -51,6 +51,6 @@ 12 Murder Income -Weighted lm HSGrad centered and robust intervals +Weighted lm HSGrad centered and robust intervals diff --git a/tests/testthat/_snaps/effect-plot/wlm-one-centered.svg b/tests/testthat/_snaps/effect-plot/wlm-one-centered.svg index 604a0ac6..053220cb 100644 --- a/tests/testthat/_snaps/effect-plot/wlm-one-centered.svg +++ b/tests/testthat/_snaps/effect-plot/wlm-one-centered.svg @@ -46,6 +46,6 @@ 12 Murder Income -Weighted lm HSGrad centered +Weighted lm HSGrad centered diff --git a/tests/testthat/_snaps/export-summs/glm2-odds-modnames.svg b/tests/testthat/_snaps/export-summs/glm2-odds-modnames.svg index e509f7cc..74ec5047 100644 --- a/tests/testthat/_snaps/export-summs/glm2-odds-modnames.svg +++ b/tests/testthat/_snaps/export-summs/glm2-odds-modnames.svg @@ -54,15 +54,15 @@ 1.2 1.3 exp(Estimate) -Model - +Model + - + Mod1 Mod2 -glm2-odds-modnames +glm2-odds-modnames diff --git a/tests/testthat/_snaps/export-summs/glm2-summ-args.svg b/tests/testthat/_snaps/export-summs/glm2-summ-args.svg index 6e5500e5..5cdbbcd1 100644 --- a/tests/testthat/_snaps/export-summs/glm2-summ-args.svg +++ b/tests/testthat/_snaps/export-summs/glm2-summ-args.svg @@ -52,15 +52,15 @@ 0.1 0.2 Estimate -Model - +Model + - + Model 1 Model 2 -glm2-summ-args +glm2-summ-args diff --git a/tests/testthat/_snaps/export-summs/glm2.svg b/tests/testthat/_snaps/export-summs/glm2.svg index 8ce23572..057582ac 100644 --- a/tests/testthat/_snaps/export-summs/glm2.svg +++ b/tests/testthat/_snaps/export-summs/glm2.svg @@ -54,15 +54,15 @@ 0.1 0.2 Estimate -Model - +Model + - + Model 1 Model 2 -glm2 +glm2 diff --git a/tests/testthat/_snaps/export-summs/lm3-coef-names.svg b/tests/testthat/_snaps/export-summs/lm3-coef-names.svg index 1b2567ed..9078ae37 100644 --- a/tests/testthat/_snaps/export-summs/lm3-coef-names.svg +++ b/tests/testthat/_snaps/export-summs/lm3-coef-names.svg @@ -49,19 +49,19 @@ -500 0 Estimate -Model - +Model + - + - + Model 1 Model 2 Model 3 -lm3-coef-names +lm3-coef-names diff --git a/tests/testthat/_snaps/export-summs/lm3-coef-omit-facet.svg b/tests/testthat/_snaps/export-summs/lm3-coef-omit-facet.svg index 023b0121..bf28f781 100644 --- a/tests/testthat/_snaps/export-summs/lm3-coef-omit-facet.svg +++ b/tests/testthat/_snaps/export-summs/lm3-coef-omit-facet.svg @@ -18,7 +18,7 @@ - + @@ -83,19 +83,19 @@ HSGrad Murder Estimate -Model - +Model + - + - + Model 1 Model 2 Model 3 -lm3-coef-omit-facet +lm3-coef-omit-facet diff --git a/tests/testthat/_snaps/export-summs/lm3-coef-omit.svg b/tests/testthat/_snaps/export-summs/lm3-coef-omit.svg index c0aa5c3d..75fd9287 100644 --- a/tests/testthat/_snaps/export-summs/lm3-coef-omit.svg +++ b/tests/testthat/_snaps/export-summs/lm3-coef-omit.svg @@ -18,7 +18,7 @@ - + @@ -49,19 +49,19 @@ -500 0 Estimate -Model - +Model + - + - + Model 1 Model 2 Model 3 -lm3-coef-omit +lm3-coef-omit diff --git a/tests/testthat/_snaps/export-summs/lm3-linesize2-inner-ci-msg.svg b/tests/testthat/_snaps/export-summs/lm3-linesize2-inner-ci-msg.svg index e6f3c0b4..86fa2dd5 100644 --- a/tests/testthat/_snaps/export-summs/lm3-linesize2-inner-ci-msg.svg +++ b/tests/testthat/_snaps/export-summs/lm3-linesize2-inner-ci-msg.svg @@ -99,22 +99,22 @@ 0 5000 Estimate -Model - +Model + - + - + Model 1 Model 2 Model 3 -lm3-linesize2-inner-ci-msg +lm3-linesize2-inner-ci-msg diff --git a/tests/testthat/_snaps/export-summs/lm3-linesize2-inner-ci.svg b/tests/testthat/_snaps/export-summs/lm3-linesize2-inner-ci.svg index 4426e9ce..c5570b7c 100644 --- a/tests/testthat/_snaps/export-summs/lm3-linesize2-inner-ci.svg +++ b/tests/testthat/_snaps/export-summs/lm3-linesize2-inner-ci.svg @@ -99,22 +99,22 @@ 0 5000 Estimate -Model - +Model + - + - + Model 1 Model 2 Model 3 -lm3-linesize2-inner-ci +lm3-linesize2-inner-ci diff --git a/tests/testthat/_snaps/export-summs/lm3-linesize2.svg b/tests/testthat/_snaps/export-summs/lm3-linesize2.svg index 5c591896..03a96ab2 100644 --- a/tests/testthat/_snaps/export-summs/lm3-linesize2.svg +++ b/tests/testthat/_snaps/export-summs/lm3-linesize2.svg @@ -82,19 +82,19 @@ 0 5000 Estimate -Model - +Model + - + - + Model 1 Model 2 Model 3 -lm3-linesize2 +lm3-linesize2 diff --git a/tests/testthat/_snaps/export-summs/lm3-summ-args.svg b/tests/testthat/_snaps/export-summs/lm3-summ-args.svg index bd7f6933..4b78a2a5 100644 --- a/tests/testthat/_snaps/export-summs/lm3-summ-args.svg +++ b/tests/testthat/_snaps/export-summs/lm3-summ-args.svg @@ -80,19 +80,19 @@ 0 2000 Estimate -Model - +Model + - + - + Model 1 Model 2 Model 3 -lm3-summ-args +lm3-summ-args diff --git a/tests/testthat/_snaps/export-summs/lm3.svg b/tests/testthat/_snaps/export-summs/lm3.svg index f913a853..649546e1 100644 --- a/tests/testthat/_snaps/export-summs/lm3.svg +++ b/tests/testthat/_snaps/export-summs/lm3.svg @@ -82,19 +82,19 @@ 0 5000 Estimate -Model - +Model + - + - + Model 1 Model 2 Model 3 -lm3 +lm3 diff --git a/tests/testthat/_snaps/export-summs/lmer-summ-arg.svg b/tests/testthat/_snaps/export-summs/lmer-summ-arg.svg index 394009f5..7e86772d 100644 --- a/tests/testthat/_snaps/export-summs/lmer-summ-arg.svg +++ b/tests/testthat/_snaps/export-summs/lmer-summ-arg.svg @@ -44,6 +44,6 @@ 30 40 Estimate -lmer-summ-arg +lmer-summ-arg diff --git a/tests/testthat/_snaps/export-summs/lmer.svg b/tests/testthat/_snaps/export-summs/lmer.svg index 726551c1..7abfaa41 100644 --- a/tests/testthat/_snaps/export-summs/lmer.svg +++ b/tests/testthat/_snaps/export-summs/lmer.svg @@ -40,6 +40,6 @@ 5 10 Estimate -lmer +lmer diff --git a/tests/testthat/_snaps/export-summs/pc-brm1.svg b/tests/testthat/_snaps/export-summs/pc-brm1.svg index 7e5d8d45..4dc5c839 100644 --- a/tests/testthat/_snaps/export-summs/pc-brm1.svg +++ b/tests/testthat/_snaps/export-summs/pc-brm1.svg @@ -49,6 +49,6 @@ 0.0 0.5 Estimate -basic brms fit +basic brms fit diff --git a/tests/testthat/_snaps/export-summs/pc-brmmv-sigma-select-dv.svg b/tests/testthat/_snaps/export-summs/pc-brmmv-sigma-select-dv.svg index 8e6ba6fc..184fd48b 100644 --- a/tests/testthat/_snaps/export-summs/pc-brmmv-sigma-select-dv.svg +++ b/tests/testthat/_snaps/export-summs/pc-brmmv-sigma-select-dv.svg @@ -45,6 +45,6 @@ 0.0 0.2 Estimate -select wt dv, dpar sigma mv brms fit +select wt dv, dpar sigma mv brms fit diff --git a/tests/testthat/_snaps/export-summs/pc-brmmv-sigma.svg b/tests/testthat/_snaps/export-summs/pc-brmmv-sigma.svg index 1423ac23..2c582154 100644 --- a/tests/testthat/_snaps/export-summs/pc-brmmv-sigma.svg +++ b/tests/testthat/_snaps/export-summs/pc-brmmv-sigma.svg @@ -18,7 +18,7 @@ - + @@ -47,6 +47,6 @@ 0.25 0.50 Estimate -default dv, dpar sigma mv brms fit +default dv, dpar sigma mv brms fit diff --git a/tests/testthat/_snaps/export-summs/pc-brmmv.svg b/tests/testthat/_snaps/export-summs/pc-brmmv.svg index 286db935..084bc0c3 100644 --- a/tests/testthat/_snaps/export-summs/pc-brmmv.svg +++ b/tests/testthat/_snaps/export-summs/pc-brmmv.svg @@ -18,7 +18,7 @@ - + @@ -47,6 +47,6 @@ -1 0 Estimate -default mv brms fit +default mv brms fit diff --git a/tests/testthat/_snaps/export-summs/pc-brmmv2-multidist-select-dv.svg b/tests/testthat/_snaps/export-summs/pc-brmmv2-multidist-select-dv.svg index 7d99996d..937fc275 100644 --- a/tests/testthat/_snaps/export-summs/pc-brmmv2-multidist-select-dv.svg +++ b/tests/testthat/_snaps/export-summs/pc-brmmv2-multidist-select-dv.svg @@ -51,15 +51,15 @@ -1 0 Estimate -Model - +Model + - + MPG DV MPG Sigma -select mpg dv, dpar sigma separate models mv brms fit +select mpg dv, dpar sigma separate models mv brms fit diff --git a/tests/testthat/_snaps/export-summs/pc-glm1-dists-exp.svg b/tests/testthat/_snaps/export-summs/pc-glm1-dists-exp.svg index 0d029136..6102071c 100644 --- a/tests/testthat/_snaps/export-summs/pc-glm1-dists-exp.svg +++ b/tests/testthat/_snaps/export-summs/pc-glm1-dists-exp.svg @@ -48,6 +48,6 @@ 1.1 1.2 exp(Estimate) -pc-glm1-dists-exp +pc-glm1-dists-exp diff --git a/tests/testthat/_snaps/export-summs/pc-glm1-dists.svg b/tests/testthat/_snaps/export-summs/pc-glm1-dists.svg index 0ac883d9..a5ea97a5 100644 --- a/tests/testthat/_snaps/export-summs/pc-glm1-dists.svg +++ b/tests/testthat/_snaps/export-summs/pc-glm1-dists.svg @@ -51,6 +51,6 @@ 0.1 0.2 Estimate -pc-glm1-dists +pc-glm1-dists diff --git a/tests/testthat/_snaps/export-summs/pc-lm-modnames.svg b/tests/testthat/_snaps/export-summs/pc-lm-modnames.svg index 1590e4fd..76dfa4b8 100644 --- a/tests/testthat/_snaps/export-summs/pc-lm-modnames.svg +++ b/tests/testthat/_snaps/export-summs/pc-lm-modnames.svg @@ -69,15 +69,15 @@ -4000 0 Estimate -Model - +Model + - + Mod1 Mod2 -pc-lm-modnames +pc-lm-modnames diff --git a/tests/testthat/_snaps/export-summs/pc-lm1-dists-scale.svg b/tests/testthat/_snaps/export-summs/pc-lm1-dists-scale.svg index b171341d..8e331301 100644 --- a/tests/testthat/_snaps/export-summs/pc-lm1-dists-scale.svg +++ b/tests/testthat/_snaps/export-summs/pc-lm1-dists-scale.svg @@ -67,6 +67,6 @@ 200 400 Estimate -pc-lm1-dists-scale +pc-lm1-dists-scale diff --git a/tests/testthat/_snaps/export-summs/pc-lm1-dists.svg b/tests/testthat/_snaps/export-summs/pc-lm1-dists.svg index 73f3544b..a79fb89f 100644 --- a/tests/testthat/_snaps/export-summs/pc-lm1-dists.svg +++ b/tests/testthat/_snaps/export-summs/pc-lm1-dists.svg @@ -67,6 +67,6 @@ -4000 0 Estimate -pc-lm1-dists +pc-lm1-dists diff --git a/tests/testthat/_snaps/export-summs/pc-lm2-dists-inner-ci-scale.svg b/tests/testthat/_snaps/export-summs/pc-lm2-dists-inner-ci-scale.svg index 52089245..fd5ae0eb 100644 --- a/tests/testthat/_snaps/export-summs/pc-lm2-dists-inner-ci-scale.svg +++ b/tests/testthat/_snaps/export-summs/pc-lm2-dists-inner-ci-scale.svg @@ -74,6 +74,6 @@ 200 400 Estimate -pc-lm2-dists-inner-ci-scale +pc-lm2-dists-inner-ci-scale diff --git a/tests/testthat/_snaps/export-summs/pc-lm2-dists-inner-ci.svg b/tests/testthat/_snaps/export-summs/pc-lm2-dists-inner-ci.svg index 783dee1b..27cd339b 100644 --- a/tests/testthat/_snaps/export-summs/pc-lm2-dists-inner-ci.svg +++ b/tests/testthat/_snaps/export-summs/pc-lm2-dists-inner-ci.svg @@ -74,13 +74,13 @@ -4000 0 Estimate -Model - +Model + - + Model 1 Model 2 -pc-lm2-dists-inner-ci +pc-lm2-dists-inner-ci diff --git a/tests/testthat/_snaps/export-summs/pc-lm2-dists.svg b/tests/testthat/_snaps/export-summs/pc-lm2-dists.svg index a50a2700..cb993b4c 100644 --- a/tests/testthat/_snaps/export-summs/pc-lm2-dists.svg +++ b/tests/testthat/_snaps/export-summs/pc-lm2-dists.svg @@ -74,13 +74,13 @@ -4000 0 Estimate -Model - +Model + - + Model 1 Model 2 -pc-lm2-dists +pc-lm2-dists diff --git a/tests/testthat/_snaps/export-summs/pc-lm2-inner-ci.svg b/tests/testthat/_snaps/export-summs/pc-lm2-inner-ci.svg index a1668c7c..3c75a02f 100644 --- a/tests/testthat/_snaps/export-summs/pc-lm2-inner-ci.svg +++ b/tests/testthat/_snaps/export-summs/pc-lm2-inner-ci.svg @@ -88,17 +88,17 @@ -4000 0 Estimate -Model - +Model + - + Model 1 Model 2 -pc-lm2-inner-ci +pc-lm2-inner-ci diff --git a/tests/testthat/_snaps/export-summs/pc-lm3-coef-omit.svg b/tests/testthat/_snaps/export-summs/pc-lm3-coef-omit.svg index 5a154fa3..bff19802 100644 --- a/tests/testthat/_snaps/export-summs/pc-lm3-coef-omit.svg +++ b/tests/testthat/_snaps/export-summs/pc-lm3-coef-omit.svg @@ -18,7 +18,7 @@ - + @@ -49,19 +49,19 @@ -500 0 Estimate -Model - +Model + - + - + Model 1 Model 2 Model 3 -pc-lm3-coef-omit +pc-lm3-coef-omit diff --git a/tests/testthat/_snaps/export-summs/pc-lm3-coefnames.svg b/tests/testthat/_snaps/export-summs/pc-lm3-coefnames.svg index 944d2732..a4f35a3f 100644 --- a/tests/testthat/_snaps/export-summs/pc-lm3-coefnames.svg +++ b/tests/testthat/_snaps/export-summs/pc-lm3-coefnames.svg @@ -49,19 +49,19 @@ -500 0 Estimate -Model - +Model + - + - + Model 1 Model 2 Model 3 -pc-lm3-coefnames +pc-lm3-coefnames diff --git a/tests/testthat/_snaps/export-summs/svyglm-summ-arg.svg b/tests/testthat/_snaps/export-summs/svyglm-summ-arg.svg index 7e89bea0..8f4d06ab 100644 --- a/tests/testthat/_snaps/export-summs/svyglm-summ-arg.svg +++ b/tests/testthat/_snaps/export-summs/svyglm-summ-arg.svg @@ -18,7 +18,7 @@ - + @@ -62,6 +62,6 @@ 0 40 Estimate -svyglm-summ-arg +svyglm-summ-arg diff --git a/tests/testthat/_snaps/export-summs/svyglm.svg b/tests/testthat/_snaps/export-summs/svyglm.svg index 322903c3..c4d93049 100644 --- a/tests/testthat/_snaps/export-summs/svyglm.svg +++ b/tests/testthat/_snaps/export-summs/svyglm.svg @@ -18,7 +18,7 @@ - + @@ -58,6 +58,6 @@ 50 100 Estimate -svyglm +svyglm diff --git a/tests/testthat/test-effect-plot.R b/tests/testthat/test-effect-plot.R index 7a392df0..9c409f02 100644 --- a/tests/testthat/test-effect-plot.R +++ b/tests/testthat/test-effect-plot.R @@ -313,5 +313,11 @@ if (requireNamespace("rstanarm") & requireNamespace("lme4")) { expect_s3_class(make_predictions(rsfit, pred = "size", interval = TRUE, estimate = "median", data = cbpp), "data.frame") }) + test_that("facet.by works with rstanarm", { + p <- effect_plot(rsfit, pred = "size", interval = TRUE, data = lme4::cbpp, + facet.by = "herd") + + ggtitle("stanreg facet.by") + expect_doppelganger("rstanarm-facet", p) + }) } diff --git a/tests/testthat/test-export-summs.R b/tests/testthat/test-export-summs.R index 3ee95877..48af1407 100644 --- a/tests/testthat/test-export-summs.R +++ b/tests/testthat/test-export-summs.R @@ -37,7 +37,7 @@ if (requireNamespace("lme4")) { mv <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy) } -if (requireNamespace("huxtable") & requireNamespace("broom")) { +if (requireNamespace("huxtable")) { test_that("Export doesn't fail with lm", { expect_is(export_summs(fit, fit2, fitw), "huxtable") @@ -170,8 +170,6 @@ test_that("Export can take manual coefficient names", { context("plot_summs") -if (requireNamespace("broom")) { - test_that("plot_summs doesn't fail with lm", { p <- plot_summs(fit, fit2, fitw) expect_doppelganger("lm3", p) @@ -291,7 +289,7 @@ test_that("plot.distributions works", { expect_doppelganger("pc-lm2-dists-inner-ci-scale", p) }) -if (requireNamespace("brms") & requireNamespace("broom.mixed")) { +if (requireNamespace("brms")) { bfit1 <- readRDS("brmfit.rds") mvfit <- readRDS("mvfit.rds") test_that("plot_coefs works with brms", { @@ -320,4 +318,3 @@ if (requireNamespace("brms") & requireNamespace("broom.mixed")) { expect_doppelganger("pc-brmmv2-multidist-select-dv", p) }) } -}