Hello Prof. Hess,
I specified a model in MNL form with socio demographics data. I would like to develop that in MMNL to compare the results. Just wondering if there is any sample on that to have a look? In my MMNL not sure where I'm doing wrong that I get NAs. Which is not the case in MNL.
BTW, I'm working with dummy values for now until I receive the data, so Rho-square may not make sense.
Regards,
Maisie
RESULTS:
Estimation method : bfgs
Model diagnosis : iteration limit exceeded
Number of individuals : 12
Number of rows in database : 108
Number of modelled outcomes : 108
Number of cores used : 4
Number of inter-individual draws : 100 (halton)
Number of intra-individual draws : 100 (mlhs)
LL(start) : -141.8176
LL(0) : -74.8599
LL(final) : -69.67577
Rho-square (0) : 0.0693
Adj.Rho-square (0) : -0.1979
AIC : 179.35
BIC : 232.99
Estimated parameters : 20
Time taken (hh:mm:ss) : 00:26:44.84
pre-estimation : 00:00:20.36
estimation : 00:26:23.15
post-estimation : 00:00:1.33
Iterations : 202 (iteration limit exceeded )
Estimates:
Estimate s.e. t.rat.(0) Rob.s.e. Rob.t.rat.(0)
mu_log_b_pc -15.060869 NA NA NA NA
sigma_log_b_pc -1.327230 NA NA NA NA
mu_log_b_pt 4.628390 NA NA NA NA
sigma_log_b_pt -0.003218 NA NA NA NA
sigma_log_b_pt_inter 0.001371 NA NA NA NA
sigma_log_b_pt_intera -0.039830 NA NA NA NA
mu_log_b_es 4.702541 NA NA NA NA
sigma_log_b_es 0.004531 NA NA NA NA
mu_log_b_eb -7.692006 NA NA NA NA
sigma_log_b_eb -0.005519 NA NA NA NA
mu_log_b_rs -7.939968 NA NA NA NA
sigma_log_b_rs 0.072400 NA NA NA NA
mu_log_b_cs 4.414534 NA NA NA NA
sigma_log_b_cs 0.010955 NA NA NA NA
b_cost_shift_female -8.9257e-04 NA NA NA NA
b_cost_shift_age 0.004253 NA NA NA NA
b_pt_shift_car_availability -113.129184 NA NA NA NA
b_pt_shift_child -20.178565 NA NA NA NA
b_cost_shift_disability -0.009708 NA NA NA NA
b_cost_shift_income -1.6089e-04 NA NA NA NA
MODEL:
### Vector of parameters, including any that are kept fixed in estimation
apollo_beta=c(
mu_log_b_pc =-2,
sigma_log_b_pc = 0,
mu_log_b_pt =2,
sigma_log_b_pt = 0,
sigma_log_b_pt_inter = 0,
sigma_log_b_pt_intera = 0,
mu_log_b_es =2,
sigma_log_b_es = 0,
mu_log_b_eb =2,
sigma_log_b_eb = 0,
mu_log_b_rs =2,
sigma_log_b_rs = 0,
mu_log_b_cs =2,
sigma_log_b_cs = 0,
b_cost_shift_female = 0,
b_cost_shift_age = 0,
b_pt_shift_car_availability = 0,
b_pt_shift_child = 0,
b_cost_shift_disability = 0,
b_cost_shift_income = 0)
### Set parameters for generating draws
apollo_draws = list(
interDrawsType = "halton",
interNDraws = 100,
interUnifDraws = c("draws_pc"),
interNormDraws = c("draws_pt","draws_es","draws_eb","draws_rs","draws_cs"),
intraDrawsType = "mlhs",
intraNDraws = 100,
intraUnifDraws = c(),
intraNormDraws = c("draws_pt_intra")
)
### Create random parameters
apollo_randCoeff = function(apollo_beta, apollo_inputs){
randcoeff = list()
randcoeff[["b_pc"]] = -exp( mu_log_b_pc + sigma_log_b_pc * draws_pc )
randcoeff[["b_pt"]] = exp( mu_log_b_pt + sigma_log_b_pt * draws_pt
+ sigma_log_b_pt_inter * draws_pt ^2
+ sigma_log_b_pt_intera * draws_pt_intra)
randcoeff[["b_es"]] = exp( mu_log_b_es + sigma_log_b_es * draws_es )
randcoeff[["b_eb"]] = exp( mu_log_b_eb + sigma_log_b_eb * draws_eb )
randcoeff[["b_rs"]] = exp( mu_log_b_rs + sigma_log_b_rs * draws_rs )
randcoeff[["b_cs"]] = exp( mu_log_b_cs + sigma_log_b_cs * draws_cs )
return(randcoeff)
}
.....
### Create alternative specific constants and coefficients using interactions with socio-demographics
b_pc_value= b_pc + b_cost_shift_female*female + b_cost_shift_age*age_cate + b_cost_shift_disability*disability + b_cost_shift_income *income_adj
b_pt_value= b_pt + b_pt_shift_car_availability*car_availability + b_pt_shift_child*child
### List of utilities: these must use the same names as in mnl_settings, order is irrelevant
V = list()
V[['alt1']] = b_pc_value *( pc1 + b_pt_value * pt1 + b_es * es1 + b_eb * eb1 + b_rs * rs1 + b_cs * cs1)
V[['alt2']] = b_pc_value *( pc2 + b_pt_value * pt2 + b_es * es2 + b_eb * eb2 + b_rs * rs2 + b_cs * cs2)
### Define settings for MNL model component
mnl_settings = list(
alternatives = c(alt1=1, alt2=2),
avail = list(alt1=1, alt2=1),
choiceVar = choice,
V = V
)
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.
Mixed logit model with socio demographics data
-
- Site Admin
- Posts: 1042
- Joined: 24 Apr 2020, 16:29
Re: Mixed logit model with socio demographics data
Is it possible that in your data, nobody chooses PT when they have a car available? That's what the parameter value for the pt shift term seems to imply:
b_pt_shift_car_availability -113.129184
b_pt_shift_car_availability -113.129184
Re: Mixed logit model with socio demographics data
Hi Stephen,
Could you please advise why I am getting NA?
Could you please advise why I am getting NA?
-
- Site Admin
- Posts: 1042
- Joined: 24 Apr 2020, 16:29
Re: Mixed logit model with socio demographics data
Can you check whether my hypothesis is correct, i.e. that nobody with a car ever chooses PT? If so, the parameter would not be identified and that's why you get NA
Re: Mixed logit model with socio demographics data
Hi Stephen,
That's not the case, since I have some records that people with a car are choosing PT (also I didn't get any NA with MNL model)
That's not the case, since I have some records that people with a car are choosing PT (also I didn't get any NA with MNL model)
-
- Site Admin
- Posts: 1042
- Joined: 24 Apr 2020, 16:29
Re: Mixed logit model with socio demographics data
It looks like your model hasn't actually converged (look at the iterations), but either way, these very large negative parameters point towards some issues. Could you also show us the output of the MNL model, and the output of a model without the intra-individual heterogeneity?
Re: Mixed logit model with socio demographics data
Sorry for the late reply.
The issue was data-related. When I received my data and loaded it into the model the problem got fixed. It seems the model needed much more data to do the estimates.
Thank you very much for your time.
Maisie
The issue was data-related. When I received my data and loaded it into the model the problem got fixed. It seems the model needed much more data to do the estimates.
Thank you very much for your time.
Maisie