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.

Probabilities with standard errors

Ask questions about post-estimation functions (e.g. prediction, conditionals, etc) or other processing of results.
Post Reply
tomas.rossetti
Posts: 18
Joined: 16 Jul 2020, 14:51

Probabilities with standard errors

Post by tomas.rossetti »

I am estimating a binary choice model where some variables that affect choice probabilities are continuous. I would like to plot how probabilities change with respect to some of these continuous variables, along with a confidence interval that reflects the parameters' uncertainty.

I know that I would have to construct a dataset with a baseline alternative, and another alternative where all attributes are fixed except for the continuous one I would like to plot. Using apollo_mnl will give me the point estimates but not the standard deviations I'm also looking for. That function could give me a confidence interval if I'm estimating a mixed logit model, but that would be introduced through the random heterogeneity and not through the parameters' standard errors.

Is there any way other than sampling from the betas' asymptotic distribution and running apollo_mnl?

Thanks for your help!

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

Re: Probabilities with standard errors

Post by dpalma »

Hi Tomás,

You can do this in two stages. Let's assume your model has two alternatives, with the following utility functions:

Code: Select all

V[['yes']] = b0 + b1*x1 + b2*x
V[['no']]  = 0
You want to calculate the effect of x1 on the probability, including confidence intervals. You would then:

1) Create a new dataset where only x1 changes, so for example:

Code: Select all

id   x1   x2 choice
 1  0.1  3.0      1
 2  0.2  3.0      1
 3  0.3  3.0      1
 4  0.4  3.0      1
 5  0.5  3.0      1
 6  0.6  3.0      1
...
2) Use apollo_prediction with the option for confidence intervals. This will take multiple sets of draws for b0, b1 and b2 from their asymptotic distribution and calculate predictions for each set. Based on these values, it will calculate a confidence interval. You would do this as follows:

Code: Select all

apolo_inputs <- apollo_validateInputs() # this is to update the database to the new one created in the previous point
pred <- apollo_prediction(model, apollo_probabilities, apollo_inputs, prediction_settings = list(runs=100)) # use 100 draws for C.I.
You can read apollo_prediction documentation for the specifics on how results are returned by apollo_prediction, but the aggregated results will be printed to screen.

Let us know if you run into any issues with this approach.

Cheers
David
tomas.rossetti
Posts: 18
Joined: 16 Jul 2020, 14:51

Re: Probabilities with standard errors

Post by tomas.rossetti »

Wonderful, thank you so much David.

All the best,

Tomás
Post Reply