- Operating System: Windows 10
- brms Version: 2.9.0
Hi all,
I am trying to obtain marginal effects using emmeans
and tidybayes
from a brms
model with a prior on the real intercept and thus a model of form y ~ 0 + intercept + x
. However, this results in the following error:
Error in vcov(object)[nm, nm, drop = FALSE] : subscript out of bounds
Called from: emm_basis.brmsfit(object, trms, xlev, grid, ...)
Here’s a quick example (with mostly unchanged defaults) using the warpbreaks
data set.
library(emmeans)
library(tidybayes)
library(magrittr)
library(brms)
set.seed(123)
# All seems to works here:
Model1 <- brm(breaks ~ tension,
data = warpbreaks)
Model1 %>%
emmeans(~ tension) %>%
gather_emmeans_draws() %>%
mean_qi()
# A tibble: 3 x 7
# tension .value .lower .upper .width .point .interval
# <fct> <dbl> <dbl> <dbl> <dbl> <chr> <chr>
# L 36.4 30.9 42.0 0.95 mean qi
# M 26.2 20.6 31.7 0.95 mean qi
# H 21.6 16.1 27.2 0.95 mean qi
# Error occurs here:
Model2 <- brm(breaks ~ 0 + intercept + tension,
data = warpbreaks)
Model2 %>%
emmeans(~ tension) %>%
gather_emmeans_draws() %>%
mean_qi()
#Error in vcov(object)[nm, nm, drop = FALSE] : subscript out of bounds
#Called from: emm_basis.brmsfit(object, trms, xlev, grid, ...)
It seems the error has to do with how the internally generated variable intercept
is handled or else there might be a misunderstanding on my part wrt how things should work. Your help is very much appreciated.