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.

Estimating the average marginal effects of a mixed logit within Apollo's post-estimation functions?

Ask questions about post-estimation functions (e.g. prediction, conditionals, etc) or other processing of results.
Post Reply
BrennaLynn
Posts: 3
Joined: 21 May 2020, 22:23

Estimating the average marginal effects of a mixed logit within Apollo's post-estimation functions?

Post by BrennaLynn »

Hello,

I was hoping for some guidance in estimating average marginal effects for the coefficients of a mixed logit. I was able to follow the instructions in the manual and a few of the posted examples to estimate average marginal effects for a multinomial logit, but am unable to determine how to apply Apollo's post-estimation functions to estimate the AMEs of a mixed logit.

The Procedure:
For each parameter, I will need to define the distribution of the respective betas according to the regression outputs (i.e., using the estimated mean and standard deviation) then draw N betas from said distribution. For each beta, I would use the apollo_predict function to find base predictions. Then, I would marginally increase the data and use apollo_predict again to find new predictions. I would use those two predictions (base and new) to calculate the AME, then take the arithmetic mean of those estimates across all N draws. Rinse and repeat for each mixed coefficient.

My questions are as follows:

(1) apollo_predict reads in the model in order to generate predictions, but I need to draw from the distributions of the betas. Is it possible to define a distribution for each beta and replace the betas in the original model for each draw or iteration? If so, how? If not, is there a better way to accomplish this?

(2) This procedure will only generate point estimates for the AMEs, but I want to be able to say something about the simulation error. Is there a good way to estimate the confidence intervals around AME estimates within Apollo?

Thank you for your time,

Brenna
stephanehess
Site Admin
Posts: 989
Joined: 24 Apr 2020, 16:29

Re: Estimating the average marginal effects of a mixed logit within Apollo's post-estimation functions?

Post by stephanehess »

Hi Brenna

apollo_prediction makes use of the full distribution of the random coefficients. So it will take the estimated parameters and create draws for the coefficients at the person level, using the number of draws you specified in the settings for draws. It will then calculate the probabilities with each draw and average over the draws. That's how to make predictions using Mixed Logit. The output that Apollo produces is averaged across the draws.

To answer your second question, you need to be quite careful here in terms of interpretation. I don't believe simulation error is the right thought here. That would relate to how good or bad the simulation based approximation to the MMNL integral is. What I believe you are meaning is the heterogeneity in the predictions resulting from the random heterogeneity that your MMNL model has estimated.

What you can do in Apollo is to, after estimation, make the following call:

predictions_1=apollo_probabilities(model$estimate,apollo_inputs, functionality="raw")

this will given you the probabilities for each observation at the level of each draw.

If you then want to make a second set of predictions after changing the attributes, please make sure to follow the below procedure. Imagine you're looking at a 1% increase in the cost of the first alternative, called cost_1. Then you would do:

database$cost_1=1.0.1*database$cost_1

You then need to revalidate your inputs, by calling:

apollo_inputs = apollo_validateInputs()

before

predictions_2=apollo_probabilities(model$estimate,apollo_inputs, functionality="raw")

Best wishes

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
BrennaLynn
Posts: 3
Joined: 21 May 2020, 22:23

Re: Estimating the average marginal effects of a mixed logit within Apollo's post-estimation functions?

Post by BrennaLynn »

Hi Stephane,

Thank you so much for your thorough, clear response. This is a great help!

All the best,
Brenna
Post Reply