"Error: The following variables are missing in the draws object: " when running emmeans

Hello,

I am having an issue when running emmenas on a brmsfitted object. Currently, I am using a computing cluster to do model fitting for me, so in the brm call, I include the argument ‘file’ to save the model as a .rds file. However, when running this .rds file and attempting to do emmeans on it, it get the error:

Error: The following variables are missing in the draws object: …

Alongside a bunch of variable names. Upon closer inspection, it seems like something is wrong with the coding, as one of the variables that’s missing is b_StimOld when the model outputs as b_Stim1.

library(tidyverse)
library(emmeans)

table <- model_1 %>% emmeans(~ Age * Condition)
table

Here is the program I am trying to run. I was wondering if there was a way to recode or fix this in the posterior without having to refit (as it took me around 14 hours to fit on the cluster).

Thank you so much.

I’m not sure if this is more likely to be a brms issue or an emmeans issue (I haven’t used emmeans and brms together), but you could also try opening an issue at the emmeans GitHub repository to see if they’ve ever encountered this before.