Skip to content

Commit

Permalink
fix issue #1652
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-buerkner committed Sep 12, 2024
1 parent 96902a7 commit 407cad8
Show file tree
Hide file tree
Showing 18 changed files with 89 additions and 68 deletions.
4 changes: 4 additions & 0 deletions R/data-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,10 @@ validate_newdata <- function(
new_levels <- get_levels(bterms, data = newdata)
for (g in names(old_levels)) {
unknown_levels <- setdiff(new_levels[[g]], old_levels[[g]])
# NA is not found by get_levels but still behaves like a new level (#1652)
if (anyNA(newdata[[g]])) {
c(unknown_levels) <- NA
}
if (length(unknown_levels)) {
unknown_levels <- collapse_comma(unknown_levels)
stop2(
Expand Down
9 changes: 5 additions & 4 deletions R/prepare_predictions.R
Original file line number Diff line number Diff line change
Expand Up @@ -1173,10 +1173,11 @@ is.bprepnl <- function(x) {
#'
#' @param x An \R object typically of class \code{'brmsfit'}.
#' @param newdata An optional data.frame for which to evaluate predictions. If
#' \code{NULL} (default), the original data of the model is used.
#' \code{NA} values within factors are interpreted as if all dummy
#' variables of this factor are zero. This allows, for instance, to make
#' predictions of the grand mean when using sum coding.
#' \code{NULL} (default), the original data of the model is used. \code{NA}
#' values within factors (excluding grouping variables) are interpreted as if
#' all dummy variables of this factor are zero. This allows, for instance, to
#' make predictions of the grand mean when using sum coding. \code{NA} values
#' within grouping variables are treated as a new level.
#' @param re_formula formula containing group-level effects to be considered in
#' the prediction. If \code{NULL} (default), include all group-level effects;
#' if \code{NA} or \code{~0}, include no group-level effects.
Expand Down
9 changes: 5 additions & 4 deletions man/fitted.brmsfit.Rd

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

9 changes: 5 additions & 4 deletions man/get_refmodel.brmsfit.Rd

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

9 changes: 5 additions & 4 deletions man/log_lik.brmsfit.Rd

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

9 changes: 5 additions & 4 deletions man/loo_moment_match.brmsfit.Rd

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

9 changes: 5 additions & 4 deletions man/posterior_epred.brmsfit.Rd

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

9 changes: 5 additions & 4 deletions man/posterior_linpred.brmsfit.Rd

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

9 changes: 5 additions & 4 deletions man/posterior_predict.brmsfit.Rd

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

9 changes: 5 additions & 4 deletions man/pp_check.brmsfit.Rd

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

9 changes: 5 additions & 4 deletions man/pp_mixture.brmsfit.Rd

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

9 changes: 5 additions & 4 deletions man/predict.brmsfit.Rd

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

9 changes: 5 additions & 4 deletions man/predictive_error.brmsfit.Rd

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

9 changes: 5 additions & 4 deletions man/prepare_predictions.Rd

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

9 changes: 5 additions & 4 deletions man/psis.brmsfit.Rd

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

9 changes: 5 additions & 4 deletions man/reloo.brmsfit.Rd

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

9 changes: 5 additions & 4 deletions man/residuals.brmsfit.Rd

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

9 changes: 5 additions & 4 deletions man/standata.brmsfit.Rd

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

0 comments on commit 407cad8

Please sign in to comment.