Dear team,
I am confused a bit on how to set up the apollo_probabilities function to fit a 2 level nested logit model using Bayesian estimation (through Apollo's call to RSGHB routines). In RSGHB we have to write out the logsum formulas and the nest probabilities and the within nest probabilities expressions. In Apollo do I simply use the same expressions used in the NL_two_levels.r code? Using a highly simplified version of the utility functions...
V=list()
V[["car"]] = asc_car + b_tt_car * time_car + b_cost * cost_car
V[["bus"]] = asc_bus + b_tt_bus * time_bus + b_access * access_bus + b_cost * cost_bus
V[["air"]] = asc_air + b_tt_air * time_air + b_access * access_air + b_cost * cost_air
V[["rail"]] = asc_rail + b_tt_rail * time_rail + b_access * access_rail + b_cost * cost_rail
### Specify nests for NL model
nlNests = list(root=1,
PT=lambda_PT)
### Specify tree structure for NL model
nlStructure= list()
nlStructure[["root"]] = c("car","PT")
nlStructure[["PT"]] = c("bus","air","rail")
### Define settings for NL model
nl_settings <- list(
alternatives = c(car=1, bus=2, air=3, rail=4),
avail = list(car=av_car, bus=av_bus, air=av_air, rail=av_rail),
choiceVar = choice,
utilities = V,
nlNests = nlNests,
nlStructure = nlStructure
)
### Compute probabilities using MNL model
P[["model"]] = apollo_nl(nl_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)
This seems to run, but I am not sure it is right. Is this correct, or do I need to write out my own logum expressions, etc. as I would if using RSGHB? If I have to write out all the losum etc., expression as I do in RSGHB, do I still have to call a P[["model"]] ? if so should that be P[["model"]] = apollo_mnl(mnl_settings, functionality) or something else..
Thank you in advance for your help!
Tom Eagle
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. In addition, help files are available for all functions, using e.g. ?apollo_mnl
- 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.
Bayesian estimation of a 2 level nested logit estimated using bayesian estimation
-
- Site Admin
- Posts: 1232
- Joined: 24 Apr 2020, 16:29
Re: Bayesian estimation of a 2 level nested logit estimated using bayesian estimation
Hi Tom
what you do is correct. Apollo uses exactly the same code for classical and Bayesian estimation (except dropping the panel prod for the latter, as you have already done). It then prepares everything internally for using RSGHB
Best wishes
Stephane
what you do is correct. Apollo uses exactly the same code for classical and Bayesian estimation (except dropping the panel prod for the latter, as you have already done). It then prepares everything internally for using RSGHB
Best wishes
Stephane
Re: Bayesian estimation of a 2 level nested logit estimated using bayesian estimation
Thank you Stephane. I really appreciate your help.
Tom
Tom