I am wondering if one can apply colors directly to parameters from rstanarm models with bayesplot
For example from https://mc-stan.org/bayesplot/articles/plotting-mcmc-draws.html:
library("bayesplot")
library("ggplot2")
library("rstanarm")
fit <- stan_glm(mpg ~ ., data = mtcars, seed = 1111)
posterior <- as.array(fit)
color_scheme_set("red")
mcmc_intervals(posterior, pars = c("cyl", "drat", "am", "sigma"))
returns:
The documentation describes custom schemes, or mixing, but they still apply to every parameter in the plot:
color_scheme_set("mix-blue-red")
plot(fit, pars = c("cyl", "drat", "am", "sigma"))
The plot function (with rstanarm model) no longer accepts a col
argument to be able to specify each point. Is there anyway to specify a string of colors (or schemes) for each parameter in the plot?
Edit: Based on comments from @Limey, you can modify plots as ggobjects, but I don't see a straightforward way to access the original plot aesthetics.
For example, scale_colour_manual
(or any other scale_colour_...
for that matter) does not alter the plotted values:
plot(fit, pars = c("cyl", "drat", "am", "sigma"))+
scale_colour_manual(values=c("blue", "purple", "orange","red"))
(see plot above, it looks the same). Another example, I can plot points, on top of the original:
plot(fit, pars = c(names(mtcars)[-1]))+
geom_point(aes(x=fit$coefficients[-1],y=names(fit$coefficients)[-1]),color="black")
and make them bigger to match (note I have also made them pink here):
plot(fit, pars = c(names(mtcars)[-1]))+
geom_point(aes(x=fit$coefficients[-1],y=names(fit$coefficients)[-1]),color="pink",size=3)
I could do this for each of the errorbar objects as well, but at this point I am not really modifying the original plot, but rather plotting right over the top of it. In this case it makes sense to ditch the rstanarm plot function all together and simply do it manually, or create my own function, which is fine. However, if anyone knows how to do modify the plot(rstanarm_object)
colors directly, I would still be interested to hear it.