Skip to content

Commit

Permalink
clean up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bbolker committed Apr 9, 2024
1 parent 7c1618c commit 7a7da7b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion R/glmm_tidiers.R
@@ -1,7 +1,9 @@
##' @importFrom dplyr bind_rows tibble
##' @importFrom stats vcov
##' @export
tidy.glmm <- function(x, effects = "fixed") {
tidy.glmm <- function(x, effects = "fixed", ...) {

check_dots(...)

estimate <- std.error <- statistic <- p.value <- NULL ## avoid check warnings for NSE
fix_nm <- names(coef(x))
Expand Down
6 changes: 4 additions & 2 deletions R/ordinal_tidiers.R
Expand Up @@ -27,12 +27,14 @@ predict_all_clmm <- function(object, newdata, ...) {
#' the \code{tidy} method for \code{clmm} objects (from the
#' \code{ordinal} package) lives in the \code{broom} package.
#'
#' @inheritParams lme4_tidiers
#' @importFrom tibble tibble
#' @importFrom stats model.frame
#' @export
augment.clmm <- function( x,
data = model.frame(x),
...) {
data = model.frame(x),
newdata,
...) {

if (!missing(newdata)) data <- newdata

Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test-rstanarm.R
Expand Up @@ -12,7 +12,7 @@ if (suppressPackageStartupMessages(require(rstanarm, quietly = TRUE))) {
td2 <- tidy(fit, effects = "ran_vals")
td3 <- tidy(fit, effects = "ran_pars")
td4 <- tidy(fit, effects = "auxiliary")
expect_equal(colnames(td1), c("term", "estimate", "std.error"))
expect_equal(colnames(td1), c("term", "estimate", "std.error", "group"))
})

test_that("tidy with multiple 'effects' selections works on rstanarm fits", {
Expand All @@ -27,8 +27,8 @@ if (suppressPackageStartupMessages(require(rstanarm, quietly = TRUE))) {
td3 <- tidy(fit, conf.int = TRUE, conf.level = 0.95)
nms <- c("level", "group", "term", "estimate", "std.error", "conf.low", "conf.high")
expect_equal(colnames(td2), nms)
expect_true(all(td3$conf.low < td1$conf.low))
expect_true(all(td3$conf.high > td1$conf.high))
expect_true(all(is.na(td3$conf.low) | td3$conf.low < td1$conf.low))
expect_true(all(is.na(td3$conf.high) | td3$conf.high > td1$conf.high))
})

test_that("glance works on rstanarm fits", {
Expand All @@ -40,8 +40,8 @@ if (suppressPackageStartupMessages(require(rstanarm, quietly = TRUE))) {
})

test_that("exponentiation", {
td1 <- tidy(fit2, conf.int = TRUE)
td1e <- tidy(fit2, conf.int = TRUE, exponentiate = TRUE)
td1 <- tidy(fit2, conf.int = TRUE, effects = "fixed")
td1e <- tidy(fit2, conf.int = TRUE, exponentiate = TRUE, effects = "fixed")
expect_equal(td1e$estimate, exp(td1$estimate))
expect_equal(td1e$conf.low, exp(td1$conf.low))
expect_equal(td1e$conf.high, exp(td1$conf.high))
Expand Down

0 comments on commit 7a7da7b

Please sign in to comment.