Skip to content

Commit 15a1fed

Browse files
committed
further adjustments to support binomial models in brmsmargins controlling the trials using at argument
1 parent b2ec91b commit 15a1fed

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

R/prediction.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
#' @importFrom data.table as.data.table
8787
#' @importFrom stats fitted formula
8888
#' @importFrom posterior as_draws_df ndraws
89-
#' @importFrom brms standata
89+
#' @importFrom brms standata brmsterms
9090
#' @export
9191
prediction <- function(object, data, summarize = TRUE, posterior = FALSE,
9292
index, dpar = NULL, resample = 0L, resampleseed = FALSE,
@@ -186,7 +186,8 @@ prediction <- function(object, data, summarize = TRUE, posterior = FALSE,
186186
}
187187

188188
if (identical(family(object)$family, "binomial")) {
189-
trials <- standata(object)$trials
189+
trial.var <- all.vars(brmsterms(formula(object))$adforms$trials)
190+
trials <- data[[trial.var]]
190191
if (length(trials) > 0L) {
191192
if (identical(length(trials), ncol(yhat))) {
192193
yhat <- sweep(yhat, 2, trials, "*")

0 commit comments

Comments
 (0)