-
-
Notifications
You must be signed in to change notification settings - Fork 196
prior_summary() |> dplyr::select() alters the content in the prior column #1761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
not the content changes. just what is printed. when changing the class to a
regular data.frame the special printing is no longer applied. that is what
you are seeing
A. Solomon Kurz ***@***.***> schrieb am Mi., 2. Apr. 2025,
17:33:
… It looks like their's a bug when you try to subset the columns from
prior_summary() with dplyr::select(). Some of the information in the prior
column changes. To give a sense, here's a simplified version of fit2 from
the inhaler documentation.
# Load
library(tidyverse)
library(brms)
# Fit
fit2.1 <- brm(rating ~ treat + (1 | subject),
data = inhaler,
family = cumulative(),
prior = set_prior("normal(0, 5)"),
cores = 4, seed = 1)
# Before `select()`
prior_summary(fit2.1)
prior class coef group resp dpar nlpar lb ub source
normal(0,5) b user
normal(0,5) b treat (vectorized)
student_t(3, 0, 2.5) Intercept default
student_t(3, 0, 2.5) Intercept 1 (vectorized)
student_t(3, 0, 2.5) Intercept 2 (vectorized)
student_t(3, 0, 2.5) Intercept 3 (vectorized)
student_t(3, 0, 2.5) sd 0 default
student_t(3, 0, 2.5) sd subject 0 (vectorized)
student_t(3, 0, 2.5) sd Intercept subject 0 (vectorized)
To my eye, this all looks correct. Now see what happens when we use
select().
prior_summary(fit2.1) |>
select(prior, class, coef, group)
prior class coef group source
normal(0,5) b (unknown)
(flat) b treat (unknown)
student_t(3, 0, 2.5) Intercept (unknown)
(flat) Intercept 1 (unknown)
(flat) Intercept 2 (unknown)
(flat) Intercept 3 (unknown)
student_t(3, 0, 2.5) sd (unknown)
(flat) sd subject (unknown)
(flat) sd Intercept subject (unknown)
Several rows have now changed to (flat) in the prior column. The issue
appears the same if you instead use the get_prior(fit2.1) or fit2.1$prior
methods, instead.
—
Reply to this email directly, view it on GitHub
<#1761>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADCW2AG562LHTYYRDLBANCD2XPYKDAVCNFSM6AAAAAB2JX24HKVHI2DSMVQWIX3LMV43ASLTON2WKOZSHE3DMNJYGE4TSOI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
[image: ASKurz]*ASKurz* created an issue (paul-buerkner/brms#1761)
<#1761>
It looks like their's a bug when you try to subset the columns from
prior_summary() with dplyr::select(). Some of the information in the prior
column changes. To give a sense, here's a simplified version of fit2 from
the inhaler documentation.
# Load
library(tidyverse)
library(brms)
# Fit
fit2.1 <- brm(rating ~ treat + (1 | subject),
data = inhaler,
family = cumulative(),
prior = set_prior("normal(0, 5)"),
cores = 4, seed = 1)
# Before `select()`
prior_summary(fit2.1)
prior class coef group resp dpar nlpar lb ub source
normal(0,5) b user
normal(0,5) b treat (vectorized)
student_t(3, 0, 2.5) Intercept default
student_t(3, 0, 2.5) Intercept 1 (vectorized)
student_t(3, 0, 2.5) Intercept 2 (vectorized)
student_t(3, 0, 2.5) Intercept 3 (vectorized)
student_t(3, 0, 2.5) sd 0 default
student_t(3, 0, 2.5) sd subject 0 (vectorized)
student_t(3, 0, 2.5) sd Intercept subject 0 (vectorized)
To my eye, this all looks correct. Now see what happens when we use
select().
prior_summary(fit2.1) |>
select(prior, class, coef, group)
prior class coef group source
normal(0,5) b (unknown)
(flat) b treat (unknown)
student_t(3, 0, 2.5) Intercept (unknown)
(flat) Intercept 1 (unknown)
(flat) Intercept 2 (unknown)
(flat) Intercept 3 (unknown)
student_t(3, 0, 2.5) sd (unknown)
(flat) sd subject (unknown)
(flat) sd Intercept subject (unknown)
Several rows have now changed to (flat) in the prior column. The issue
appears the same if you instead use the get_prior(fit2.1) or fit2.1$prior
methods, instead.
—
Reply to this email directly, view it on GitHub
<#1761>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADCW2AG562LHTYYRDLBANCD2XPYKDAVCNFSM6AAAAAB2JX24HKVHI2DSMVQWIX3LMV43ASLTON2WKOZSHE3DMNJYGE4TSOI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
That's not exactly true. There are a few other weird things that can happen when manipulating the |
Yeah that is a good point. Unclassing |
@paul-buerkner, I'm not sure if this is implied by your last comment, but from my standpoint it would be really great if code like this
carried the filled-in cells in the
Same request about what happens with the |
I see. Could make sense. I will have to think about what the best behavior is in that regard. |
Uh oh!
There was an error while loading. Please reload this page.
It looks like there's a bug when you try to subset the columns from
prior_summary()
withdplyr::select()
. Some of the information in theprior
column changes. To give a sense, here's a simplified version offit2
from theinhaler
documentation.To my eye, this all looks correct. Now see what happens when we use
select()
.Several rows have now changed to
(flat)
in theprior
column. The issue appears the same if you instead use theget_prior(fit2.1)
orfit2.1$prior
methods. It also persists if you use the base bracket notation in place ofselect()
(prior_summary(fit2.1)[, 1:4]
).Though my primary interest is with the
prior
column, I find the behavior of thesource
column surprising, too. When I tried to drop that column withselect()
, it still appeared in the print output, but now with all(unknown)
.The text was updated successfully, but these errors were encountered: