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
Important: Read this before posting to this forum
 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.
 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.
 Before asking a question on the forum, users are kindly requested to follow these steps:
 Check that the same issue has not already been addressed in the forum  there is a search tool.
 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
 Check the frequently asked questions section on the Apollo website, which discusses some common issues/failures. Please see http://www.apollochoicemodelling.com/faq.html
 Make sure that R is using the latest official release of Apollo.
 Users can check which version they are running by entering packageVersion("apollo").
 Then check what is the latest full release (not development version) at http://www.ApolloChoiceModelling.com/code.html.
 To update to the latest official version, just enter install.packages("apollo"). To update to a development version, download the appropriate binary file from http://www.ApolloChoiceModelling.com/code.html, and install the package from file
 If the above steps do not resolve the issue, then users should follow these steps when posting a question:
 provide full details on the issue, including the entire code and output, including any error messages
 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
Re: Probabilities with standard errors
Hi Tomás,
You can do this in two stages. Let's assume your model has two alternatives, with the following utility functions:
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:
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:
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
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
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
...
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.
Let us know if you run into any issues with this approach.
Cheers
David

 Posts: 17
 Joined: 16 Jul 2020, 14:51
Re: Probabilities with standard errors
Wonderful, thank you so much David.
All the best,
Tomás
All the best,
Tomás