Skip to contents

Overlays the prior density that rstanarm used (after any autoscaling) on the posterior density of each parameter. A posterior that looks like its prior indicates the data carry little information about that parameter; a posterior in the tail of its prior suggests prior-data conflict. Unlike rstanarm::posterior_vs_prior(), no refitting is needed.

Usage

plot_prior_posterior(fit, pars = NULL, n_grid = 300L)

Arguments

fit

A stanreg object from rstanarm::stan_glm() or rstanarm::stan_glmer() (population-level parameters only).

pars

Parameters to show (default: all).

n_grid

Number of grid points for the prior density.

Value

A ggplot object.

Details

The intercept is shown at the predictor means, which is the parameter rstanarm places its prior on.

Examples

# \donttest{
data(kidiq, package = "rstanarm")
fit <- rstanarm::stan_glm(kid_score ~ mom_iq, data = kidiq,
                          chains = 2, iter = 1000, refresh = 0)
plot_prior_posterior(fit)

# }