90% credibility interval in brms

I want to change prob setting to be middle 90% interval

n<-175
sim_d_and_fit <-
function
(seed, n , probs =c(0.05, 0.95) {
mu_n <-0
mu_c <-0.3
set.seed(seed)
d <-
tibble(group = rep(c("normal","covid"), each = n)) %>%
mutate(treatment = ifelse(group =="normal",0,1),
y = ifelse(group =="normal",rnorm(n, mean = mu_n, sd =1),
rnorm(n, mean = mu_c, sd =1)))

update(fit,
newdata = d,
seed = seed) %>%
fixef() %>%
data.frame() %>%
rownames_to_column("parameter") %>%
filter(parameter =="treatment")
}
n_sim <-100
s10 <-
tibble(seed =1:n_sim) %>%
mutate(b1 = map(seed, sim_d_and_fit, n =175)) %>%
unnest(b1)
mutate(width = Q95 - Q5)

I got that error

Error in mutate(width = Q95 - Q5) : object 'Q95' not found

In this case you can specify the interval you want in the probs argument to the fixef() function. Like:

update(fit, newdata = d, seed = seed) %>% 
fixef(probs = c(.5, .95)) %>% 
data.frame() %>% 
rownames_to_column("parameter") %>%
filter(parameter =="treatment")

The summary function to brmsfit also has a prob argument, taking the desired width of the interval.

Is the issue here just that you missed the pipe %>% after unnest? If you do mutate without telling it what object to use, it won’t be able to find anything, hence ‘object Q95 not found’.

Either put the pipe in after unnest. Or do:

s10 <- mutate(s10, width = Q95 - Q5)

Thank you very much