knitr::opts_chunk$set(echo = TRUE)

VERY MUCH A WORK IN PROGRESS

cjbae provides functions for Bayesian analysis of conjoint experimental data. These functions use brms and emmeans to estimate Bayesian average marginal component effects (AMCEs) and marginal means (MMs). For explanations of these quantities of interest in the standard frequentist approach to conjoint analysis, see Hainmueller, Hopkins and Yamamoto (2014) and Leeper, Hobolt and Tilley (2018).

amce_bae() estimates distributions of AMCE parameters for all levels (excluding baselines/reference categories) of the specified (in a formula) features in a given tidy conjoint dataset (see cregg's cj_tidy). It does this using brms. As such, cjbae depends on brms, and unfortunately installation of the latter can be a bit tricky if you don't have rstan and a C++ compiler functioning on your machine. This page should make your life easier if so.

mm_bae() takes an amce_bae object of class brmsfit and calculates marginal means for all feature-levels, as specified in a formula. Note that this function therefore requires a brmsfit output, so you'll need to have run amce_bae first, with save_amce = TRUE. It is this saved object that will need to be passed to mm_bae. The main output of amce_bae is a tibble, which will not work with mm_bae. The saved object can be loaded into your environment using readRDS().

Alternatively, cjbae() is a one-stop shop for both AMCE and MM calculation. Specifying estimate = "mm" and save_amce = TRUE will generate a saved AMCE brmsfit object and a tidy dataframe of MMs in your R environment. The function cjbae_df() can then be used on the brmsfit object, once it is loaded into your environment, to create a tidy dataframe of AMCEs.

Both MMs and AMCEs can be passed to cjbae_plot() to plot the distributions of parameter estimates in a way that is more-or-less visually consistent with standard approaches to plotting conjoint estimates. This function is currently not particularly flexible, and can be easily replicated in a more flexible way with a standard ggplot approach.

The name cjbae is obviously a sort of 'conjoint bayesian' portmanteau, but it conveniently also reminds us that 'conjoint analysis is bae'.

To install this developmental version of the package:

if (!require("remotes")) {
    install.packages("remotes")
}
remotes::install_github("mbarnfield/cjbae")


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