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.

conditionals for random parameters when an individual has lots of observations

Ask questions about post-estimation functions (e.g. prediction, conditionals, etc) or other processing of results.
Post Reply
wj5tu
Posts: 7
Joined: 15 May 2020, 00:58

conditionals for random parameters when an individual has lots of observations

Post by wj5tu »

Dear Prof. Hess,

In my dataset, each individual has many observations (ranges from 50 to 3000). When estimating a random parameter model, I had to set "workInLogs = TRUE" to avoid numerical issues, and it works.

Then, I want to look at posterior conditionals for those random parameters using "conditionals = apollo_conditionals(model, apollo_probabilities, apollo_inputs)", but I got the following error:

"Error in apollo_avgInterDraws(P, apollo_inputs, functionality) : No draws present to average over! "

Then, I update the apollo_inputs by removing the statement "workInLogs = TRUE". Now I can get posterior conditionals for most individuals. But for those individuals with very high number of observations (more than 2000), I got ""NaN"" post.mean and post.sd.

I was wondering is there a way that the function of apollo_conditionals() can handle this situation?

Best,
Wenjian
stephanehess
Site Admin
Posts: 1050
Joined: 24 Apr 2020, 16:29

Re: conditionals for random parameters when an individual has lots of observations

Post by stephanehess »

Hi Wenjian

the error message you received was not very intuitive, apologies fort that. We have improved this error message in version 0.1.1.

However, the computation of conditionals is not possible when using workInLogs. To compute conditionals, we need the probability of an individual's entire sequence of choices, and with a very large number of choices, this will become really close to zero, or zero, which is the reason for using workInLogs. This then prevents the use of the code for conditionals.

A possible solution in your case is to still use the entire sample for estimation, but reduce the number of choices when you come to computing the conditionals, and then drop workInLogs. Of course, this only makes sense if your choices are quite similar in terms of attributes/outcomes.

But if you have such large numbers of choices per person, then you need to also ask yourself what the additional information is you're getting per choice for these individuals, and also think about the very uneven distribution of the number of choices per person in your data

Best wishes

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
wj5tu
Posts: 7
Joined: 15 May 2020, 00:58

Re: conditionals for random parameters when an individual has lots of observations

Post by wj5tu »

Hi Prof. Hess,

Thank you very much for your time and insights!

My data is not a typical choice dataset. Below is a brief context of this case:

Data: national sample, some states have more than 2000 samples, while those less populated states may have only about 300 samples.
Dependent variable: each sample’s ride-haling use frequency (ordered nature)
Independent variable: age, gender, education, income, etc.
Model: ordered probit with random parameters, allowing the coefficients for age, gender, education, and income to vary across states but to be constant within states.

Code and model output are attached. For those states with less than 2000 samples, the Apollo_conditionals function works well. The problem is that I can not get conditionals for four states which have more than 2000 samples. Per your suggestion, should I randomly drop a fraction of samples from those four states to be able to get their conditionals?

Best,
Wenjian
Attachments
conditionals.rar
(61.04 KiB) Downloaded 515 times
stephanehess
Site Admin
Posts: 1050
Joined: 24 Apr 2020, 16:29

Re: conditionals for random parameters when an individual has lots of observations

Post by stephanehess »

Hi Wenjian

so in effect you're treating each state as an "individual" in the model, with random heterogeneity across states. This is of course final methodologically, but you should be aware that with only 51 states, you only have a low number of "individuals" to which to fit a continuous distribution. You might in fact do better by allowing for some deterministic differences across the states in the impact of the covariates. Have you tried that? If you can estimate meaningful differences in that way, it will be much more insightful than trying to fit a continuous distribution

Best wishes

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
wj5tu
Posts: 7
Joined: 15 May 2020, 00:58

Re: conditionals for random parameters when an individual has lots of observations

Post by wj5tu »

Hi Prof. Hess,

Thanks for your suggestions! I believe it is a good idea to first examine observed heterogeneity.

Besides, I can think of another route to address the numerical issue. Instead of using state as an "individual", maybe use a smaller geographic unit (e.g., county, blocks, etc.). In this way, the number of "individual" should be large enough to support a continuous distribution specification, and the number of observations per individual won't be so large that multiplication of probability becomes zero.

Best,
Wenjian
stephanehess
Site Admin
Posts: 1050
Joined: 24 Apr 2020, 16:29

Re: conditionals for random parameters when an individual has lots of observations

Post by stephanehess »

Yes. that would make more sense
--------------------------------
Stephane Hess
www.stephanehess.me.uk
Post Reply