[bambi] understanding plot_cap

If I understand the code correctly, the plot_cap (Conditional Adjusted Predictions) function does posterior prediction on out of sample data with the goal of visualising how the outcome variable varies as a function of (some) interpolated predictor variables.

Assuming that’s right, my question is: how does this relate to the concept of marginal effects which I hear a lot about in the R/stats community? Examples of what I mean are Plotting Marginal Effects of Regression Models and Plotting Interaction Effects of Regression Models

Are the conditional adjusted predictions the same or different to the concept of marginal effects?

Thanks!

Hi Ben! Let me add some comments.

the goal of visualising how the outcome variable varies as a function of (some) interpolated predictor variables.

Instead of “outcome variable” I would say “model parameter”. The visualization shows, by default, how the mean varies as a function of a predictor. You can choose to show another parameter instead of the mean when you have a distributional model.

For the “marginal” vs “conditional” I really like this resource https://vincentarelbundock.github.io/marginaleffects/articles/marginaleffects.html. It’s from the R library where I took the idea of plot_cap.

As far as I understand conditional adjusted predictions are different from marginal effects because they’re conditional on specific values for all the predictors. To get the marginal effect you would need “marginalize” over the conditional adjusted predictions. Perhaps this could be added to Bambi in the future.

Finally, see this

You won’t find plot_cap in the marginaleffects package because it was renamed a few months ago and it’s called plot_predictions now (perhaps it’s a better name? what do you think?)

EDIT These are great as well (but long)

Thanks! Lots to work through to get a full understanding. This topic seems non-trivial.

1 Like

Hi, this is a great thread. I’m also really trying to get my head round plot_cap and conditional adjusted predictions vs. marginal effects.

Had a couple of practical questions:

  1. If you are using the default settings with a model, idata and single covariate/predictor, would I be correct in saying the plot shows predictions on the y-axis against values of that predictor, while other covariates are held at their mean values?

  2. The target is a bit unclear to me - I only can see the ‘mean’ as an option as compared to plot_predictions in R which has a few eg. ‘median’, ‘tukey’. I am probably misinterpreting this - could you please explain a bit more what you meant by target and what can be varied?