Heterogeneous effects analysis of conjoint experiments

  collapse = TRUE,
  comment = "#>",
  fig.width = 7, fig.height = 5


This vignette provides a brief example of how to estimate heterogeneous effects in conjoint experiments, using \code{cjbart}.

Suppose we conducted a conjoint experiment on 250 individuals, where each individual makes 5 discrete choices between two profiles. The resultant data would include 2500 observations. Within this conjoint, suppose there are five attributes A-E, each with 3 levels. We also record two covariates of each subject. Let's mock up this data:

subjects <- 250
rounds <- 5
profiles <- 2
obs <- subjects*rounds*profiles

fake_data <- data.frame(A = sample(c("a1","a2","a3"), obs, replace = TRUE),
                        B = sample(c("b1","b2","b3"), obs, replace = TRUE),
                        C = sample(c("c1","c2","c3"), obs, replace = TRUE),
                        D = sample(c("d1","d2","d3"), obs, replace = TRUE),
                        E = sample(c("e1","e2","e3"), obs, replace = TRUE),

                        covar1 = rep(runif(subjects, 0 ,1),
                                     each = rounds),
                        covar2 = rep(sample(c(1,0),
                                            replace = TRUE),
                                     each = rounds),

                        id1 = rep(1:subjects, each=rounds),
                        stringsAsFactors = TRUE)

fake_data$Y <- ifelse(fake_data$E == "e2",
                      rbinom(obs, 1, fake_data$covar1),
                      sample(c(0,1), obs, replace = TRUE))

Train a probit BART model on conjoint data

To estimate a conjoint model on this data we will use the cjbart() function, which uses Bayesian Additive Regression Trees (BART) to approximate the relationships between the outcome (a binary choice), the randomized attribute-levels, and the included covariates. The result is a modified pbart model, which we will use to estimate heterogeneity in the treatment effects:

cj_model <- cjbart::cjbart(data = fake_data,
                   Y = "Y", 
                   id = "id1")

To generate heterogeneity estimates at the observation- and individual-level, we use the IMCE() function. We pass in both the original experimental data, and the conjoint model generated in the last step. At this point, we also declare the names of the conjoint attribute variables (attribs) and the reference category we want to use for each attribute when calculating the marginal component effects (ref_levels). The vector of reference levels must be of the same length as attribs, with the level at position i corresponding to the attrib[i]:

het_effects <- cjbart::IMCE(data = fake_data, 
                            model = cj_model, 
                            attribs = c("A","B","C","D","E"),
                            ref_levels = c("a1","b1","c1","d1","e1"),
                            cores = 1)

IMCE() returns an object of class "cjbart", which contains the individual-level marginal component effects (IMCEs), matrices reflecting the upper and lower values of each estimate's confidence interval RESPECTIVELY, and optionally the underlying observation-level marginal component effects (OMCEs) when keep_omces = TRUE.

It is likely that users will want to compare the conjoint estimation strategy to other estimation strategies, such as logistic regression models. We can recover the average marginal component effect (AMCE) for the BART model using the summary() command:


We can plot the IMCEs, color coding the points by some covariate value, using the in-built plot() function:

plot(het_effects, covar = "covar1")

To aid presentation, the plot function can restrict which attribute-levels are displayed by using the plot_levels argument:

plot(het_effects, covar = "covar1", plot_levels = c("a2","a3","b2","b3"))

Finally, it is also to compare the derived AMCES against a parametric calculation of the AMCEs, using a conjoint estimation package like \code{cregg}:

cregg_amce <- cregg::cj(fake_data, Y ~ A + B + C + D + E, id = ~ id1)
cjbart_amce <- summary(het_effects)

colnames(cjbart_amce)[1] <- "level"

merge(cregg_amce[,c("level","estimate")], cjbart_amce[,c("level","AMCE")])

Try the cjbart package in your browser

Any scripts or data that you put into this service are public.

cjbart documentation built on Nov. 4, 2021, 1:07 a.m.