Description Usage Arguments Details Value Examples
Calculate Bayesian marginal means for conjoint experiments
1 |
baemces |
An AMCE object of class 'brmsfit'. |
formula |
A standard formula of the form outcome ~ feature 1 + feature 2 ... + feature n |
id |
Respondent ID variable |
mm_bae()
is a Bayesian estimation function for a key quantity of interest in conjoint analysis (marginal means), and is essentially a wrapper for [‘emmeans'](https://github.com/rvlenth/emmeans), and borrows extensively from ['cregg'](https://github.com/leeper/cregg), R’s foremost conjoint analysis package. The calculation in this function is computationally expensive. Attempting to calculate MMs naively for an entire AMCE brmsfit object will often crash R, so this function uses a loop to calculate each feature one-by-one. The results of this process are equivalent. Obviously this takes time, but exactly how long is highly contingent on the number of predictors in the model.
A dataframe of marginal means. 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 | #' #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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.