Dear Professor,
I am working through your MDCEV examples to prepare for my latest research as well as your advanced modeling course.
However, the second example fails: the one with the outside good and sociodemographic variables?
I can get it working when assuming alpha_k = 0, so maybe it is an identification issue related to the outside good?
This is the code: https://www.apollochoicemodelling.com/f ... ide_good.r.
I ran it without modification in Apollo 0.3.5.
See the relevant output below.
Best regards,
Chris ten Dam
xxxxxxxxxxxxxxxxxxxxxx
WARNING: Singular Hessian, cannot calculate s.e.
Hessian written to
output/MDCEV_withOutsideGoodandSDs_example_originalFile_hessian.csv
WARNING: Some eigenvalues of the Hessian are positive, indicating convergence to
a saddle point!
Computing score matrix...
Your model was estimated using the BGW algorithm. Please acknowledge
this by citing Bunch et al. (1993) - doi.org/10.1145/151271.151279
Please acknowledge the use of Apollo by citing Hess & Palma (2019) -
doi.org/10.1016/j.jocm.2019.100170
Warning messages:
1: In log((inputs$continuousChoice[[j]]/inputs$gamma[[j]]) + 1) :
NaNs produced
2: In log(inputs$continuousChoice[[j]] + inputs$gamma[[j]]) :
NaNs produced
3: In log((inputs$continuousChoice[[j]]/inputs$gamma[[j]]) + 1) :
NaNs produced
4: In log(inputs$continuousChoice[[j]] + inputs$gamma[[j]]) :
NaNs produced
5: In log((inputs$continuousChoice[[j]]/inputs$gamma[[j]]) + 1) :
NaNs produced
6: In log(inputs$continuousChoice[[j]] + inputs$gamma[[j]]) :
NaNs produced
7: In log((inputs$continuousChoice[[j]]/inputs$gamma[[j]]) + 1) :
NaNs produced
8: In log(inputs$continuousChoice[[j]] + inputs$gamma[[j]]) :
NaNs produced
...
Unconstrained optimisation.
Estimates:
Estimate s.e. t.rat.(0) Rob.s.e.
alpha_base -911.5129 NA NA NA
gamma_work 4.8990 NA NA NA
gamma_school 3.0985 NA NA NA
gamma_shopping 0.4264 NA NA NA
gamma_private 0.6200 NA NA NA
gamma_leisure 2.0958 NA NA NA
delta_work -3.7172 NA NA NA
delta_school -7.4183 NA NA NA
delta_shopping -3.8044 NA NA NA
delta_private -4.2786 NA NA NA
delta_leisure -3.4001 NA NA NA
delta_work_FT 1.3248 NA NA NA
delta_work_wknd -2.8609 NA NA NA
delta_school_young 2.3442 NA NA NA
delta_leisure_wknd 0.2949 NA NA NA
sig 1.0000 NA NA NA
Rob.t.rat.(0)
alpha_base NA
gamma_work NA
gamma_school NA
gamma_shopping NA
gamma_private NA
gamma_leisure NA
delta_work NA
delta_school NA
delta_shopping NA
delta_private NA
delta_leisure NA
delta_work_FT NA
delta_work_wknd NA
delta_school_young NA
delta_leisure_wknd NA
sig NA
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. We check the forum at least twice a week. It may thus take a couple of days for your post to appear and before we reply. There is no need to submit the post multiple times.
MDCEV_with_outside_good example fails
Re: MDCEV_with_outside_good example fails
Hi,
We have come to realise that model in particular fails to converge on Windows, but it does converge on macOS. Beyond the OS differences, the issue is a very common one among MDCEV models with outside good using the alpha-gamma parametrisation, i.e. models where you have a common alpha among all alternatives (including teh outside good), and different gammas for each inside good. This is the most common parametrisation as it allows for Pinjari & Bhat's efficient forecasting algorithm.
The problem is that alpha tends towards zero. Conceptually, this means that the utility function for inside goods transform from a power function into a logarithm, which is not a problem. However, in the code alpha is parametrised as alpha = 1 / ( 1 + exp(-alpha_base) ), so alpha_base tends towards negative infinity, preventing the model from converging properly.
Just as you mention, the solution for this is to either fix alpha = 0, or alpha_base to a large negative value (e.g. -23). But you should not do this from the start in every MDCEV model, instead, you should first check that alpha effectively tends towards zero, and if it does, only then fix the parameter, as in this case.
I hope this helps,
David
We have come to realise that model in particular fails to converge on Windows, but it does converge on macOS. Beyond the OS differences, the issue is a very common one among MDCEV models with outside good using the alpha-gamma parametrisation, i.e. models where you have a common alpha among all alternatives (including teh outside good), and different gammas for each inside good. This is the most common parametrisation as it allows for Pinjari & Bhat's efficient forecasting algorithm.
The problem is that alpha tends towards zero. Conceptually, this means that the utility function for inside goods transform from a power function into a logarithm, which is not a problem. However, in the code alpha is parametrised as alpha = 1 / ( 1 + exp(-alpha_base) ), so alpha_base tends towards negative infinity, preventing the model from converging properly.
Just as you mention, the solution for this is to either fix alpha = 0, or alpha_base to a large negative value (e.g. -23). But you should not do this from the start in every MDCEV model, instead, you should first check that alpha effectively tends towards zero, and if it does, only then fix the parameter, as in this case.
I hope this helps,
David