Skip to content

Commit

Permalink
make stanarm tidiers safe without REs (still need tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbolker committed Oct 14, 2024
1 parent a7396c4 commit 8402765
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions R/rstanarm_tidiers.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ tidy.stanreg <- function(x,
check_dots(...)
conf.method <- match.arg(conf.method)
std.error <- estimate <- NULL ## fool code checker/NSE
miss_effects <- missing(effects)
effects <-
match.arg(effects,
several.ok = TRUE,
Expand All @@ -105,10 +106,10 @@ tidy.stanreg <- function(x,
"ran_pars", "auxiliary"
)
)
if (any(effects %in% c("ran_vals", "ran_pars"))) {
if (!inherits(x, "lmerMod")) {
stop("Model does not have varying ('ran_vals') or hierarchical ('ran_pars') effects.")
}
no_ranef <- !inherits(x, "lmerMod")
if (miss_effects && no_ranef) effects <- setdiff(effects, c("ran_vals", "ran_pars"))
if (!miss_effects && no_ranef && any(effects %in% c("ran_vals", "ran_pars"))) {
stop("Model does not have varying ('ran_vals') or hierarchical ('ran_pars') effects.")
}

nn <- c("estimate", "std.error")
Expand Down

0 comments on commit 8402765

Please sign in to comment.