Plotting smooth splines using conditional_smooths in brms

With the following model fit using smooth splines in brms

 library(brms)
 dat <- mgcv::gamSim(1, n = 200, scale = 2)
 fit <- brm(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = dat)

we can show the fit of s(x2) through

 plot(conditional_smooths(fit, smooths = "s(x2)"), ask = FALSE)

The fitted curve is centered around 0 along the y-axis. Is there a way to add the Intercept of the model to the plot? Also, how to show s(x1)+s(x2)?

1 Like

To add the intercept, just use conditional_effects() rather than conditional_smooths(). Note that this method makes predictions with the other predictors held at their mean.

I am not sure what you mean by this…

4 Likes

Thanks a lot for the pointer @jd_c! The function conditional_smooths() does seem to collect various “main” effects and “interactions”.

I also wish to examine various combinations such as s(x1)+s(x2) and s(x1)-s(x2). I guess I may have to resort to predict.brmsfit for those terms?

As far as I know, conditional_smooths() or conditional_effects() only does main effects or interactions.

1 Like