CRT_fatigueeffect {CRTConjoint}R Documentation

Testing fatigue effect in Conjoint Experiments

Description

This function takes a conjoint dataset and returns the p-value when using the CRT to test if the fatigue effect holds using HierNet test statistic. The function requires user to specify the outcome, all factors used in the conjoint experiment, and both the evaluation task number and respondent index. 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_fatigueeffect(
  formula,
  data,
  left,
  right,
  task,
  respondent,
  profileorder_constraint = TRUE,
  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")

task

A character string indicating column of data that contains the task evaluation. IMPORTANT: The task variable is assumed to have no missing tasks, i.e., each respondent should have 1:J tasks. Please drop respondents with missing tasks.

respondent

A character string indicating column of data that contains the respondent index. The column should contain integers from 1:N indicating respondent index.

profileorder_constraint

Boolean indicating whether to enforce profile order constraint (default = TRUE)

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 fatigue 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]
# Each respondent evaluated 5 tasks
J = 5
fatigue_df = immigrationdata
fatigue_df$task = rep(1:J, nrow(fatigue_df)/J)
fatigue_df$respondent = rep(1:(nrow(fatigue_df)/J), each = J)

fatigue_test = CRT_fatigueeffect(formula = form, data = fatigue_df, left = left,
right = right, task = "task", respondent = "respondent", B = 50)
fatigue_test$p_val


[Package CRTConjoint version 0.1.0 Index]