Skip to content

Fix predictions_as_draws() for multivariate brms models - #151

Merged
n-kall merged 2 commits into
stan-dev:developmentfrom
Sandhu-SS:fix-multivariate-predictions-as-draws
Oct 19, 2026
Merged

n-kall merged 2 commits into
stan-dev:developmentfrom
Sandhu-SS:fix-multivariate-predictions-as-draws

Conversation

@Sandhu-SS

Copy link
Copy Markdown

Fixes issue #150

Comment thread R/brms-functions.R Outdated
dim_pred <- dim(predictions)
if (!(mv)) {
dim_pred <- dim(predictions)
# dim_pred <- dim(predictions) # Moved up before if (!(mv)) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it would be best to delete this rather than comment. And as the new placement is correct and logical there is no need for the comment


suppressWarnings({
bform1 <- brms::bf(mvbind(tarsus, back) ~ sex + hatchdate + (1|p|fosternest) + (1|q|dam)) + brms::set_rescor(TRUE)
fit1 <- brms::brm(bform1, data = BTdata, chains = 2, cores = 2, iter = 10)

@n-kall n-kall Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is probably best to change this to leave out the cores argument, as there is no need to necessarily use multiple cores in the test

{
testthat::skip_if_not_installed("brms")

data("BTdata", package = "MCMCglmm")

@n-kall n-kall Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would you be able to find another dataset that is available in base R or brms? currently MCMCglmm is not listed in imports or suggests

@n-kall n-kall left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Sandhu-SS. Overall this looks good, but I left a couple or comments. I think it would be best to find another dataset that is available in base R rather than another package, to avoid additional dependencies even for tests

@Sandhu-SS

Copy link
Copy Markdown
Author

Thank you for the suggestion. I replaced the MCMCglmm::BTdata example with the base R mtcars dataset, so the test no longer introduces an additional dependency.

I also cleaned up R/brms-functions.R by removing the commented-out deleted line and have pushed these changes to this PR.

@n-kall
n-kall changed the base branch from main to development October 19, 2026 07:04
@n-kall

n-kall commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

Thanks! Merging to the development branch

@n-kall
n-kall merged commit 2aff9c1 into stan-dev:development Oct 19, 2026
4 checks passed
@Sandhu-SS
Sandhu-SS deleted the fix-multivariate-predictions-as-draws branch October 19, 2026 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants