Page 1 of 1

Structure a dataset with four choice sets and three options for each choice set

Posted: 17 Mar 2021, 20:10
by Zhenyu
Dear all,

I would like to analyze a dataset using the mixed logit model (based on Apollo_example_14). The dataset is a survey dataset and each respondent was presented with four choice sets (1,2,3, and 4). For each choice set, there are three options (option A, option B, and status quo). And there are four variables (coverage, accurancy1, accurancy2, and bid) for each option.

After transforming the dataset to the wide-format based on choice set and option, we have many variables. For example, coverage will be converted into cov_1_1, cov_1_2, cov_1_3, cov_2_1, cov_2_2, cov_2_3, cov_3_1, cov_3_2, cov_3_3, cov_4_1, cov_4_2, cov_4_3, and so on so forth. The first number indicates the choice set and the second number indicates the option.

Based on Apollo_example_14, I define the following model and likelihood function:

V1= (b_cov_1*cov_1_1 + b_cov_1*cov_1_2 + b_cov_1*cov_1_3) + (b_acc1_1*acc1_1_1 + b_acc1_1*acc1_1_2 + b_acc1_1*acc1_1_3)
+ (b_acc2_1*acc2_1_1 + b_acc2_1*acc2_1_2 + b_acc2_1*acc2_1_3) + (b_bid_1 * bid_1_1 * b_bid_1 * bid_1_2 + b_bid_1 * bid_1_3)

Similarly,

V4= (b_cov_4*cov_4_1 + b_cov_4*cov_4_2 + b_cov_4*cov_4_3) + (b_acc1_4*acc1_4_1 + b_acc1_4*acc1_4_2 + b_acc1_4*acc1_4_3)
+ (b_acc2_4*acc2_4_1 + b_acc2_4*acc2_4_2 + b_acc2_4*acc2_4_3) + (b_bid_4 * bid_4_1 * b_bid_4 * bid_4_2 + b_bid_4 * bid_4_3)

I am not sure if I set up my model and functions correctly. Any comments, thoughts or ideas are warmly welcomed.

Best,

Zhenyu

Re: Structure a dataset with four choice sets and three options for each choice set

Posted: 22 Mar 2021, 12:23
by dpalma
Hi Zhenyu,

Apollo requires a wide format similar to what you did, but not quite the same. You need to format the data with only one choice (i.e. one choice scenario) per row, and multiple rows per individual.

When you write the likelihood function, you write it at the level of the row, i.e. at the choice scenario level. So you must write the utility functions considering only one choice scenario:

Code: Select all

VA= b_cov*cov_A + b_acc1*acc1_A + b_acc2*acc2_A + b_bid * bid_A
VB= b_cov*cov_B + b_acc1*acc1_B + b_acc2*acc2_B + b_bid * bid_B
VC= b_cov*cov_C + b_acc1*acc1_C + b_acc2*acc2_C + b_bid * bid_C
In the example, I changed your indices to A, B, C for the alternatives. You do not need an index for choice scenario, as each row contains only one choice scenario. Also, you only need one coefficient for each attribute, as this coefficient is the same across choice scenarios.

You can look at apollo_modeChoiceData.csv for an example on how to format the choices.

Best
David