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.

Mixed Multinomial Logit with heterogeneity in means and variances

Ask questions about model specifications. Ideally include a mathematical explanation of your proposed model.
Post Reply
LPowell
Posts: 2
Joined: 01 Jun 2020, 13:46

Mixed Multinomial Logit with heterogeneity in means and variances

Post by LPowell »

I am rather new to choice modeling and Apollo. Trying to run a mixed multinomial logit model with heterogeneity in means and variances on a large sample of vehicle crash data. I can estimate the model with NLogit, but it runs very slowly (I gave up after it ran for 48 hours on a fast AWS cluster). Apollo's multi-threading capability could make this task more practical, given that we need to compare results from dozens of specifications. However, I cannot find reference to mean/variance heterogeneity in the random parameters model in the Apollo documentation.

Is it possible to run such a model in Apollo? If so, can someone please boost me up the learning curve?

For those familiar with NLogit, the following code is a reduced form of what we want to achieve in Apollo:

RPLOGIT;
LHS=DAMAGE;
CHOICES = C1, C2, C3;
MODEL:
U(C1)= C1*ONE + C1*X1 + C1*X2 /
U(C2) = C2*X3 + C2*X4 + C2*X5 +C2*X6 /
U(C3)= C3*ONE + C3*X7 + C3*X8 + C3*X9 + C3*X10 + C3*X11 ;
PTS=1000; HALTON;
RPL = X2, X5;
HFR = X2, X5, X6;
FCN = X12(N|#11!111), X13(N|#11!010), X14(N|#11!010) $

The LHS "choices" (C1, C2, C3) are levels of damage to vehicles and the independent variables (X1-X14) are mostly 0/1 dummies describing the crash and contributing factors (e.g. head on collision, driver age, type of vehicle, speeding). Hence, the independent variables are not choice-specific.

A paper that estimates a similar model is Seraneeprakarn, P., Huang, S., Shankar, V., Mannering, F., Venkataraman, N., Milton, J., 2017. Occupant injury severities in hybrid-vehicle involved crashes: A random parameters approach with heterogeneity in means and variances. Analytic Methods in Accident Research 15, 41-55. Available from
https://www.dropbox.com/s/am3v78i8q4tpy ... e.pdf?dl=0

Thank you.
stephanehess
Site Admin
Posts: 1042
Joined: 24 Apr 2020, 16:29

Re: Mixed Multinomial Logit with heterogeneity in means and variances

Post by stephanehess »

Hi

yes, this is very straightforward to do.

Let's use a simple example where you have that beta_cost follows a negative lognormal distribution, where we then estimate the parameters (mean and sd) of the Normal distribution of log(-beta_cost). Let's call these mu and sig and assume that mu is different for men and women, while sig is interacted continuously with income.

We could specify this as follows. Where I put ... is to add other things for your model. Here, I assume that you have variables in your data called male, female and income, and that the cost for the first alternative is cost_1:

Code: Select all

apollo_beta = c(mu_male    = 0,
                        mu_female = 0,
                        sig              = 0.1,
                        lambda_inc_sig = 0,
                        ...)

apollo_draws = list(
...
  interNormDraws = c("draws_beta_cost"...),
...
)

apollo_randCoeff = function(apollo_beta, apollo_inputs){
  randcoeff = list()

  randcoeff[["beta_cost"]] = -exp( mu_male * male + mu_female * female + sig * income ^ lambda_inc_sig * draws_beta_cost)
...

  return(randcoeff)
}

apollo_probabilities=function(apollo_beta, apollo_inputs, functionality="estimate"){

...
  V[['alt1']] = b_cost * cost_1 
...
--------------------------------
Stephane Hess
www.stephanehess.me.uk
LPowell
Posts: 2
Joined: 01 Jun 2020, 13:46

Re: Mixed Multinomial Logit with heterogeneity in means and variances

Post by LPowell »

This is very helpful. Thank you for the fast reply.
Post Reply