Skip to content

Commit

Permalink
Fix #153
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Jul 14, 2024
1 parent ad1fc3c commit 0101362
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions R/r2_bayes.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,20 +197,38 @@ r2_posterior.brmsfit <- function(model, verbose = TRUE, ...) {
names(br2) <- res
}
} else if (mi$is_mixed) {
br2 <- list(
R2_Bayes = as.vector(rstantools::bayes_R2(
if (inherits(model, "stanreg")) {
pred_cond <- rstanarm::posterior_epred(
model,
re.form = NULL,
re_formula = NULL,
summary = FALSE
)),
R2_Bayes_marginal = as.vector(rstantools::bayes_R2(
)

Check warning on line 205 in R/r2_bayes.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/r2_bayes.R,line=205,col=11,[missing_argument_linter] Missing argument 4 in function call.
pred_marginal <- rstanarm::posterior_epred(
model,
re.form = NA,
re_formula = NA,
summary = FALSE
))
)
)

Check warning on line 210 in R/r2_bayes.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/r2_bayes.R,line=210,col=11,[missing_argument_linter] Missing argument 4 in function call.
y <- insight::get_response(model)
br2 <- list(
R2_Bayes = as.vector(rstantools::bayes_R2(pred_cond, y = y)),
R2_Bayes_marginal = as.vector(rstantools::bayes_R2(pred_marginal, y = y))
)
} else {
br2 <- list(
R2_Bayes = as.vector(rstantools::bayes_R2(
model,
re.form = NULL,
re_formula = NULL,
summary = FALSE
)),
R2_Bayes_marginal = as.vector(rstantools::bayes_R2(
model,
re.form = NA,
re_formula = NA,
summary = FALSE
))
)
}
names(br2$R2_Bayes) <- rep("Conditional R2", length(br2$R2_Bayes))
names(br2$R2_Bayes_marginal) <- rep("Marginal R2", length(br2$R2_Bayes))
} else {
Expand Down

0 comments on commit 0101362

Please sign in to comment.