cjbae_plot: Simple plotting of cjbae outputs.

Description Usage Arguments Details Value Examples

Description

Visualise Bayesian marginal means and AMCEs

Usage

1
2
cjbae_plot(data, visual = c("ridge", "halfeye", "point interval"),
  estimate = c("amce", "mm"))

Arguments

data

A tidy dataframe of either AMCEs or MMs.

visual

Currently either "ridge" or "halfeye" - two different takes on a distribution plot. ADDED "point interval" which uses 'stat_pointintervalh()' from 'tidybayes'.'

estimate

Either "mm" or "amce".

Details

cjbae_plot() plots AMCEs or marginal means of feature-levels as distributions, colour-coded by feature.

Value

A plot of parameter distributions.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#' #load example dataset from {cregg} (Leeper 2019)
library(cregg)
data(taxes)
# formula
f <- chose_plan ~ taxrate1 + taxrate2 + taxrate3 + taxrate4 + taxrate5 + taxrate6 + taxrev
# prior - minimally informative
prior <- c(set_prior("normal(0, .2)", class = "Intercept"),
set_prior("normal(0, .2)", class = "b"),
set_prior("exponential(10)", class = "sd"),
set_prior("exponential(10)", class = "sigma"))
# run amce function with save specified, saves brmsfit to working directory - this will take a while
amce_bae(data = taxes, formula = f, id = ID, prior = prior, save_amce = TRUE)
# run mm function on the saved output
readRDS(baerms)
mm <- mm_bae(baerms, f, ID)
# plot MMs
cjbae_plot(mm, "ridge", "mm")
# generate df of AMCEs
amce <- cjbae_df(baerms)
# plot AMCEs
cjbae_plot(amce, "halfeye", "amce")

mbarnfield/cjbae documentation built on June 23, 2019, 3:32 a.m.