Closed Erin-Fedewa-NOAA closed 1 year ago
Yes, in general you need all predictors to be in the input - for some examples with more than one predictor see: https://mjskay.github.io/tidybayes/articles/tidy-brms.html#fitprediction-curves
The only exception is that random effects may be omitted if you zero them out using the re_formula
argument.
closing this for now --- let me know if you still have issues
In the simple mtcars example for generating fit curves, the model is fit with one parameter, making your script below straightforward. However, my brms model is fit with several predictors and when trying to use a similar approach to add the posterior distribution, I'm getting a: Error in get(sgroup[1], data) : object 'x' not found....object x being any one of my additional covariates. Is this approach not possible for a more complex model, or am I just misinterpreting the function?
mtcars %>% data_grid(hp = seq_range(hp, n = 101)) %>% add_predicted_draws(m_mpg) %>% ggplot(aes(x = hp, y = mpg)) + stat_lineribbon(aes(y = .prediction), .width = c(.99, .95, .8, .5), color = "#08519C") + geom_point(data = mtcars, size = 2) + scale_fill_brewer()