Plotting priors for conditional effects

I am getting started with bayesian analysis, so let me know if my question does not make sense. I’m using brms, and I want to plot the priors for my conditional effects.

This much is okay:

# Fit the model
my.brms.model.fit <- brm(eff ~ fct1 * fct2 + (1 | subject_id),
                         data = my.data)

# Display the final estimates for the regression coefficients
summary(my.brms.model.fit)

# Plot the final estimates for conditional effects, example:
plot(conditional_effects(my.brms.model.fit,
                         effects = "fct1",
                         conditions = data.frame(fct2 = c("fc2.level1"))))

# Display the priors for the regression coefficients
prior_summary(my.brms.model.fit)

However, how do I plot the priors for my conditional effects?

# This fails with no applicable method for 'conditional_effects' 
# applied to an object of class "c('brmsprior', 'data.frame')"
plot(conditional_effects(prior_summary(my.brms.model.fit)))

How do I achieve this?

Another way I guessed could be to supply empty data:

my.brms.model.fit <- brm(eff ~ fct1 * fct2 + (1 | subject_id),
                         data = my.data %>% filter(fct1 == ''))

But that gives me the error Argument 'data' does not contain observations.


  • Operating System: Linux / Ubuntu 24.04 VM
  • brms Version: 2.23.0

brm has the argument sample_prior. After fitting a model with sample_prior = “only”, you can use conditional_effects like you wanted:

conditional_effects(my.prior.only.fit)

see also ?brm for more details on the sample_prior argument.

3 Likes

This is the way

Great, I can play around with that!

The default improper priors do pose a problem:

Sampling from priors is not possible as some parameters have no proper priors.

But I think I can fix that.

Thanks!