IMCE: Heterogeneous Effects Analysis of Conjoint Results

View source: R/cjbart.R

IMCER Documentation

Heterogeneous Effects Analysis of Conjoint Results

Description

IMCE calculates the individual-level marginal component effects from a BART-estimated conjoint model.

Usage

IMCE(
  data,
  model,
  attribs,
  ref_levels,
  method = "bayes",
  alpha = 0.05,
  keep_omce = FALSE,
  cores = 1,
  skip_checks = FALSE
)

Arguments

data

A data.frame, containing all attributes, covariates, the outcome and id variables to analyze.

model

A model object, the result of running cjbart()

attribs

Vector of attribute names for which IMCEs will be predicted

ref_levels

Vector of reference levels, used to calculate marginal effects

method

Character string, setting the variance estimation method to use. When method is "parametric", a typical combined variance estimate is employed; when method = "bayes", the 95% posterior interval is calculated; and when method = "rubin", combination rules are used to combine the variance analogous to in multiple imputation analysis.

alpha

Number between 0 and 1 – the significance level used to compute confidence/posterior intervals. When method = "bayes", the posterior interval is calculated by taking the alpha/2 and (1-alpha/2) quantiles of the posterior draws. When method = "rubin", the confidence interval equals the IMCE +/- qnorm(alpha/2). By default, alpha is 0.05 i.e. generating a 95% confidence/posterior interval.

keep_omce

Boolean, indicating whether to keep the OMCE-level results (default = FALSE)

cores

Number of CPU cores used during prediction phase

skip_checks

Boolean, indicating whether to check the structure of the data (default = FALSE). Only set this to TRUE if you are confident that the data is structured appropriately

Details

The OMCE estimates are the result of subtracting the predicted value of each observation under the reference-level category from the predicted value of each observation under the given attribute level. If an attribute has k levels, then this will yield k-1 estimates per observation. The IMCE is the average of the OMCEs for each individual within the data.

Value

IMCE returns an object of type "cjbart", a list object.

omce

A data.frame containing the observation-level marginal effects

imce

A data.frame containing the individual-level marginal effects

imce_upper

A data.frame containing the upper bound of the IMCE confidence/credible interval

imce_lower

A data.frame containing the lower bound of the IMCE confidence/credible interval

att_levels

A vector containing the attribute levels

See Also

cjbart()

Examples

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

fake_data <- data.frame(A = sample(c("a1","a2"), obs, replace = TRUE),
                        B = sample(c("b1","b2"), obs, replace = TRUE),
                        id1 = rep(1:subjects, each=rounds),
                        stringsAsFactors = TRUE)

fake_data$Y <- sample(c(0,1), obs, replace = TRUE)

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

## Skip if not Unix due to longer CPU time
if (.Platform$OS.type=='unix') {

  het_effects <- IMCE(data = fake_data,
                      model = cj_model,
                      attribs = c("A","B"),
                      ref_levels = c("a1","b1"),
                      cores = 1)

  summary(het_effects)
}



cjbart documentation built on Sept. 8, 2023, 5:57 p.m.