Skip to content

Commit

Permalink
warn/check for underscores (bbolker#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbolker committed Mar 8, 2020
1 parent 0339744 commit c2587ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/brms_tidiers.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ NULL
#' included? See \code{\link[rstanarm]{loo.stanreg}} for details. Note: for
#' models fit to very large datasets this can be a slow computation.
#' @param ... Extra arguments, not used
#'
#' @return
#' When \code{parameters = NA}, the \code{effects} argument is used
#' to determine which parameters to summarize.
Expand Down Expand Up @@ -97,6 +96,7 @@ NULL
#' in previous versions of the package), while technically inappropriate in
#' a Bayesian setting where "fixed" and "random" effects are not well-defined,
#' are used for compatibility with other (frequentist) mixed model types.
#' @note At present, the components of parameter estimates are separated by parsing the column names of \code{posterior_samples} (e.g. \code{r_patient[1,Intercept]} for the random effect on the intercept for patient 1, or \code{b_Trt1} for the fixed effect \code{Trt1}. We try to detect underscores in parameter names and warn, but detection may be imperfect.
#' @export
tidy.brmsfit <- function(x, parameters = NA,
effects = c("fixed", "ran_pars"),
Expand All @@ -105,6 +105,10 @@ tidy.brmsfit <- function(x, parameters = NA,
conf.method = c("quantile", "HPDinterval"),
fix.intercept = TRUE,
...) {
if (any(grepl("_", rownames(fixef(x)))) ||
any(grepl("_", names(ranef(x))))) {
warning("some parameter names contain underscores: term naming may be unreliable!")
}
use_effects <- anyNA(parameters)
conf.method <- match.arg(conf.method)
is.multiresp <- length(x$formula$forms)>1
Expand Down
2 changes: 2 additions & 0 deletions man/brms_tidiers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c2587ef

Please sign in to comment.