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.

MNL model using allocation data

Ask questions about model specifications. Ideally include a mathematical explanation of your proposed model.
Post Reply
TCEagle
Posts: 3
Joined: 15 Jan 2021, 01:02

MNL model using allocation data

Post by TCEagle »

Does Apollo allow one to use proportions data from stated preference tasks in the MNL model?

I often have projects where I ask doctors to allocate a proportion of their patients across alternatives in the task. The log likelihood function becomes a simple weighted sum of the predicted probabilities across all alternatives in the task weighted by a proportion that sums to 1.0 across all alternatives in a task. E.G., LogLikelihood = sum[across all Alts](proportion * probability)[for each alt]. The likelihood is the product across all alts of the predicted probability raised to the proportion assign to the alt. It can be considered a proportion-form of the weighted MNL model where the weights are the frequency of observations choosing the alternative in the choice task -- only the frequency of observations is replaced by the proportions assigned to the alternative by the respondent.

Does anyone have an example likelihood function routine I can use to write my own? Or does someone already have such a routine. I would like to use in the HB routines of Apollo...

Thanks,

Tom
dpalma
Posts: 190
Joined: 24 Apr 2020, 17:54

Re: MNL model using allocation data

Post by dpalma »

Hi Tom,

Currently, Apollo does not have any pre-coded function to estimate choice models where the choices are not at the individual task level. If you want to estimate a choice model with aggregate data, you could use one of two approaches.
  • One way to do it is to expand your data so that it represents individual choices. For example, if your data has two alternatives with 40% choosing alternative A, you could create 10 choices, all of them with the same two alternatives, and make four of them choose option A, and 6 option B.
  • The other way is using weight, and is more like the approach you mention. Considering the same example, you would create a new database with two observations, both with the same alternatives. The first observation chooses A, and the second B. The you assign a weight of 40% to the first observation, and 60% to the second.
To use weights, you need to include them in the database, and use the setting

Code: Select all

apollo_control$weights = "nameOfWeightColumn"
Where you need to change “nameOfWeightColumn” to whatever is appropriate in your database.

Cheers
David
TCEagle
Posts: 3
Joined: 15 Jan 2021, 01:02

Re: MNL model using allocation data

Post by TCEagle »

No, I think you misunderstood the issue. The allocation is at the individual respondent level. Think of a respondent allocating patients across a choice set of different treatments. The loglikelihood is the sum(allocation(j) * log(predicted Prob j)) where we sum across alternatives in the task.

Thanks,

Tom
dpalma
Posts: 190
Joined: 24 Apr 2020, 17:54

Re: MNL model using allocation data

Post by dpalma »

Hi Tom,

Using the second approach would lead to the loglikelihood you want. Here are more detailed instructions.

Imagine you have one choice exercise with two alternatives (A and B), and two doctors answered your survey. The first doctor assigned 40% to alternative A, and 60% to alternative B. The second doctor assigned 50% to each alternative.

You would have to create a database as follows:

Code: Select all

doc obs xA1 xA2 xB1 xB2 choice weight
  1   1  a1  a2  b1  b2      A    0.6
  1   2  a1  a2  b1  b2      B    0.4
  2   1  a1  a2  b1  b2      A    0.5
  2   2  a1  a2  b1  b2      B    0.5
Where a1, a2, b1, and b2 are the numeric values of the attributes of each alternative (I’m assuming two attributes per alternative).

If you set apollo_control$weights="weight", then the loglikelihood of each row would become:
log( Prob(choice)^weight ) = weight*log(Prob(choice))
Then apollo would add the loglike across rows, leading to the “sum” in your formula.

You could implement this without the need to expand the database, but it would require some fiddling around.

Cheers
David
TCEagle
Posts: 3
Joined: 15 Jan 2021, 01:02

Re: MNL model using allocation data

Post by TCEagle »

Awesome! Thank you David! That is a huge help. I had not thought to replicate the tasks and changing the choice.

Tom
Post Reply