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.

Errors in ordered logit model

Ask questions about errors you encouunter. Please make sure to include full details about your model specifications, and ideally your model file.
Post Reply
Hyewon
Posts: 11
Joined: 28 Dec 2020, 04:30

Errors in ordered logit model

Post by Hyewon »

Dear Stephane,

I am trying to run the ordered logit model in Apollo. However, there are two issues.

1) The result is different from other packages.
2) The result converged and somehow come up, but producing the following errors;

Calculating LL(0)...
Calculating LL of each model component...
There were 22 warnings (use warnings() to see them)
> warnings()
Warning messages:
1: In log(P[[j]]) : NaNs produced
2: In log(P[[j]]) : NaNs produced
3: In log(P[[j]]) : NaNs produced
4: In log(P[[j]]) : NaNs produced
5: In log(P[[j]]) : NaNs produced
6: In log(P[[j]]) : NaNs produced
7: In log(P[[j]]) : NaNs produced
8: In log(P[[j]]) : NaNs produced
9: In log(P[[j]]) : NaNs produced
10: In log(P[[j]]) : NaNs produced
11: In log(P[[j]]) : NaNs produced
12: In log(P[[j]]) : NaNs produced
13: In log(P[[j]]) : NaNs produced
14: In log(P[[j]]) : NaNs produced
15: In log(P[[j]]) : NaNs produced
16: In log(P[[j]]) : NaNs produced
17: In log(P[[j]]) : NaNs produced
18: In log(P[[j]]) : NaNs produced
19: In log(P[[j]]) : NaNs produced
20: In log(P[[j]]) : NaNs produced
21: In log(P[[j]]) : NaNs produced
22: In log(P[[j]]) : NaNs produced

---------------------------------------------------------

Therefore, I think the result why is different from other package is maybe the issue of this.
Ordered logit is a simple model, so I revise it. However, there is no example of it in the manual except LV setting, so can you please kindly check what is the issue of it? I will attach the code.

Code: Select all

# ################################################################# #
#### DEFINE MODEL PARAMETERS                                     ####
# ################################################################# #

### Vector of parameters, including any that are kept fixed in estimation
apollo_beta = c(
  b_auto_tram = 0,
  b_auto_vehi = 0,
  b_bus = 0,
  b_truck_person = 0,
  b_truck_guard = 0,
  b_video = 0,
  b_experi = 0,
  b_none = 0,
  tau_choice_1 = -2,
  tau_choice_2 = -1,
  tau_choice_3 = 1,
  tau_choice_4 = 2
)

### Vector with names (in quotes) of parameters to be kept fixed at their starting value in apollo_beta, use apollo_beta_fixed = c() if none
apollo_fixed = c("b_none")

# ################################################################# #
#### GROUP AND VALIDATE INPUTS                                   ####
# ################################################################# #

apollo_inputs = apollo_validateInputs()

# ################################################################# #
#### DEFINE MODEL AND LIKELIHOOD FUNCTION                        ####
# ################################################################# #

apollo_probabilities=function(apollo_beta, apollo_inputs, functionality="estimate"){
  
  ### Attach inputs and detach after function exit
  apollo_attach(apollo_beta, apollo_inputs)
  on.exit(apollo_detach(apollo_beta, apollo_inputs))
  
  ### Create list of probabilities P
  P = list()
  

  ### Define settings for ordered logit
  
  
  ol_settings = list(outcomeOrdered = choice, 
                      V              =  b_auto_tram*auto_tram + b_auto_vehi*auto_vehi + b_bus*bus + 
                       			b_truck_person*truck_person + b_truck_guard*truck_guard + 
                      			 b_video*video1 + b_none*video2 + b_experi*exp_group,
                       tau            = c(tau_choice_1, tau_choice_2, tau_choice_3, tau_choice_4)
                                       
  )
  
  ### Compute ordered logit probabilities
  P[["model"]]=apollo_ol(ol_settings, functionality)
  
  ### Take product across observation for same individual
  P = apollo_panelProd(P, apollo_inputs, functionality)
  
  ### Prepare and return outputs of function
  P = apollo_prepareProb(P, apollo_inputs, functionality)
  return(P)
}

# ################################################################# #
#### MODEL ESTIMATION                                            ####
# ################################################################# #

model = apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, apollo_inputs)

Did I verify the model in the right way? Can I know the issue in the error?
The outcomeordered is on Likert scale, it will be appreciated if you can have a look and give any comment.

Thank you so much, always!

With best regards,
Hyewon
stephanehess
Site Admin
Posts: 1042
Joined: 24 Apr 2020, 16:29

Re: Errors in ordered logit model

Post by stephanehess »

Hyewon

the reason for the error messages is simply that during estimation, some of the tau parameters overlapped. This is nothing to worry about as the estimation sorted itself out.

However, to help you with your main query, we really need to see the results for your model, with Apollo and the other package you're comparing it to

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
Post Reply