Description Usage Arguments Details Value Examples
Generate a tidy dataframe of Bayesian AMCEs from brmsfit
1 |
data |
A tidy conjoint dataframe - the original dataset you used in the AMCE model. |
formula |
A standard formula of the form outcome ~ feature 1 + feature 2 ... + feature n - the same as the one plugged into the AMCE model. |
brmsfit |
The brmsfit object to convert. |
iter |
The number of iterations in the brms model. Defaults to 2000, the same as the default in amce_bae and cjbae. |
cjbae_df()
takes an AMCE brmsfit object and creates a dataframe of AMCE parameter estimates. The other arguments are needed in addition to the brmsfit argument in order to create the feature variable in the output. Also used as a utility function in other functions.
A dataframe of AMCEs. These take the form of samples from the posterior probability distribution and can be plotted as distributions, rather than point estimates.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #' #' #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 generic function with MM and save specified, gives MMs as output and saves brmsfit to
# working directory - this will take a while
bae <- cjbae(data = taxes, formula = f, id = ID, estimate = "mm", prior = prior, save_amce = TRUE)
# AMCE brmsfit object can be loaded from working directory using readRDS()
# then converted into proper cjbae output
cjbae_df(taxes, f, baerms)
# if the iter argument in cjbae() is altered from the default, the same is required in cjbae_df()
bae <- cjbae(data = taxes, formula = f, id = ID, estimate = "mm", prior = prior, save_amce = TRUE, iter = 1e3)
cjbae_df(taxes, f, baerms, iter = 1e3)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.