CRT_profileordereffect {CRTConjoint}R Documentation

Testing profile order effect in Conjoint Experiments

Description

This function takes a conjoint dataset and returns the p-value when using the CRT to test if the profile order effect holds using HierNet test statistic. The function requires user to specify the outcome, all factors used in the conjoint experiment, and any additional respondent characteristics. The function assumes the forced choice conjoint experiment and consequently assumes the data to contain the left and right profile factors in separate column in the dataset supplied.

Usage

CRT_profileordereffect(
  formula,
  data,
  left,
  right,
  non_factor = NULL,
  B = 200,
  parallel = TRUE,
  num_cores = 2,
  nfolds = 3,
  lambda = c(20, 30, 40),
  tol = 0.001,
  speedup = TRUE,
  seed = sample(c(1:1000), size = 1),
  verbose = TRUE
)

Arguments

formula

A formula object specifying the outcome variable on the left-hand side and factors of (X,Z) and respondent characteristics (V) in the right hand side. RHS variables should be separated by + signs and should only contain either left or right for each (X,Z). For example Y ~ Country_left + Education_left is sufficient as opposed to Y ~ Country_left + Country_right + Education_left + Education_right

data

A dataframe containing outcome variable and all factors (X,Z,V) (including both left and right profile factors). All (X,Z,V) listed in the formula above are expected to be of class factor unless explicitly stated in non_factor input.

left

Vector of column names of data that corresponds to the left profile factors

right

Vector of column names of data that corresponds to the right profile factors. NOTE: left and right are assumed to be the same length and the order should correspond to the same variables. For example left = c("Country_left", "Education_left") and right = c("Country_right", "Education_right")

non_factor

A vector of strings indicating columns of data that are not factors. This should only be used for respondent characteristics (V) that are not factors. For example non_factor = "Respondent_Age".

B

Numeric integer value indicating the number of resamples for the CRT procedure. Default value is B=200.

parallel

Boolean indicating whether parallel computing should be used. Default value is TRUE.

num_cores

Numeric integer indicating number of cores to use when parallel=TRUE. num_cores should not exceed the number of cores the user's machine can handle. Default is 2.

nfolds

Numeric integer indicating number of cross-validation folds. Default is 3.

lambda

Numeric vector indicating lambda used for cross-validation for HierNet fit. Default lambda=c(20,30,40).

tol

Numeric value indicating acceptable tolerance for terminating optimization fit for HierNet. Default is tol=1e-3. WARNING: Do not increase as it greatly increases computation time.

speedup

Boolean indicating whether to employ computational tricks to make function run faster. It is always recommended to use default speedup=TRUE.

seed

Seed used for CRT procedure

verbose

Boolean indicating verbose output. Default verbose=TRUE

Value

A list containing:

p_val

A numeric value for the p-value testing profile order effect.

obs_test_stat

A numeric value for the observed test statistic.

resampled_test_stat

Matrix containing all the B resampled test statistics

tol

Tolerance used for HierNet

lam

Best cross-validated lambda

hiernet_fit

An object of class hiernet that contains the hiernet fit for the observed test statistic

seed

Seed used

elapsed_time

Elapsed time

References

Ham, D., Janson, L., and Imai, K. (2022) Using Machine Learning to Test Causal Hypotheses in Conjoint Analysis

Examples

# Subset of Immigration Choice Conjoint Experiment Data from Hainmueller et. al. (2014).
data("immigrationdata")
form = formula("Y ~ FeatEd + FeatGender + FeatCountry + FeatReason + FeatJob +
FeatExp + FeatPlans + FeatTrips + FeatLang + ppage + ppeducat + ppethm + ppgender")
left = colnames(immigrationdata)[1:9]
right = colnames(immigrationdata)[10:18]

# Testing if profile order effect is present or not in immigration data

profileorder_test = CRT_profileordereffect(formula = form, data = immigrationdata,
 left = left, right = right, B = 50)
profileorder_test$p_val


[Package CRTConjoint version 0.1.0 Index]