effect_plot: Plot predictive draws from baggr model

View source: R/effect_draw.R

effect_plotR Documentation

Plot predictive draws from baggr model

Description

This function plots values from effect_draw, the predictive distribution (under default settings, posterior predictive), for one or more baggr objects.

Usage

effect_plot(..., transform = NULL)

Arguments

...

Object(s) of class baggr. If there is more than one, a comparison will be plotted and names of objects will be used as a plot legend (see examples).

transform

a transformation to apply to the result, should be an R function; (this is commonly used when calling group_effects from other plotting or printing functions)

Details

Under default settings in baggr posterior predictive is obtained. But effect_plot can also be used for prior predictive distributions when setting ppd=T in baggr. The two outputs work exactly the same, but labels will change to indicate this difference.

Value

A ggplot object.

See Also

effect_draw documents the process of drawing values; baggr_compare can be used as a shortcut for effect_plot with argument compare = "effects"

Examples



# A single effects plot
bg1 <- baggr(schools, prior_hypersd = uniform(0, 20))
effect_plot(bg1)

# Compare how posterior depends on the prior choice
bg2 <- baggr(schools, prior_hypersd = normal(0, 5))
effect_plot("Uniform prior on SD"=bg1,
            "Normal prior on SD"=bg2)

# Compare the priors themselves (ppd=T)
bg1_ppd <- baggr(schools, prior_hypersd = uniform(0, 20), ppd=TRUE)
bg2_ppd <- baggr(schools, prior_hypersd = normal(0, 5), ppd=TRUE)
effect_plot("Uniform prior on SD"=bg1_ppd,
            "Normal prior on SD"=bg2_ppd)


baggr documentation built on March 31, 2023, 10:02 p.m.