Important: Read this before posting to this forum

  1. This forum is for questions related to the use of Apollo. We will answer some general choice modelling questions too, where appropriate, and time permitting. We cannot answer questions about how to estimate choice models with other software packages.
  2. There is a very detailed manual for Apollo available at http://www.ApolloChoiceModelling.com/manual.html. This contains detailed descriptions of the various Apollo functions, and numerous examples are available at http://www.ApolloChoiceModelling.com/examples.html. In addition, help files are available for all functions, using e.g. ?apollo_mnl
  3. Before asking a question on the forum, users are kindly requested to follow these steps:
    1. Check that the same issue has not already been addressed in the forum - there is a search tool.
    2. Ensure that the correct syntax has been used. For any function, detailed instructions are available directly in Apollo, e.g. by using ?apollo_mnl for apollo_mnl
    3. Check the frequently asked questions section on the Apollo website, which discusses some common issues/failures. Please see http://www.apollochoicemodelling.com/faq.html
    4. Make sure that R is using the latest official release of Apollo.
  4. If the above steps do not resolve the issue, then users should follow these steps when posting a question:
    1. provide full details on the issue, including the entire code and output, including any error messages
    2. posts will not immediately appear on the forum, but will be checked by a moderator first. This may take a day or two at busy times. There is no need to submit the post multiple times.

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

Ask questions about data format and processing of data, including the use of pre-estimation functions in Apollo. If your question relates to a specific error you are getting, please provide some of the output.
Post Reply
Zhenyu
Posts: 3
Joined: 07 Mar 2021, 20:48

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

Post 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
dpalma
Posts: 190
Joined: 24 Apr 2020, 17:54

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

Post 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
Post Reply