Page 1 of 1

Error in MNL model

Posted: 04 Apr 2023, 18:54
by Waldo
Dear Apollo team,

I'm estimating a MNL model, largely following example 1 (model MNL_RP) on the example and code page. The model is made-up of 2 choice sets, each of which contains 1 attribute with 4 levels, 2 attributes with 3 levels and 1 attribute with 2 levels, resulting in a total of 8 dummy variables per choice set. I have two specific questions about the model specification.

1) When estimating the model I run into the following warning message:

In sqrt(diag(robvarcov)) : NaNs produced

In the next step it turns out to be impossible to print the P-values (they are NaN or the R-software freezes altogether). Do you have any idea what is happening and is there any way to resolve this issue? I noticed that there is a high degree of collinearity (Cramer’s V of 0.79) among some of the dummy variables, could this be the problem? And if so, is there a model available in the Apollo package which would be better suited to estimating a model with multicollinearity issues? I have explored the Apollo manual and forum but so far I have not been able to tackle the problem.

2) Instead of a dummy coded model I would like to fit the model using effects coding. I found the example script on the example and code page (MNL_SP_effects) but I am not a very experienced R-user and it proves very difficult to incorporate the suggested scripts in the Apollo code that I am using to estimate my model. I found a previous forum thread about this topic (here) but without a conclusive solution. Would you have any suggestion as to what changes to the current code I would have to make to make the code suitable for effect-coded data?
I am using the following code to estimate the model:

apollo_initialise()
apollo_control <- list(
modelName = "CL_apollo",
modelDescr = "Patient preferences for treatment",
indivID = "ID")
database<-DCM
apollo_beta <- c(
b_infection_min100 = 0,
b_infection_plus100 = 0,
b_infection_plus500 = 0,
b_bleeding_high = 0,
b_transfusion_5jaar = 0,
b_transfusion_25jaar = 0,
b_fatigue_5 = 0,
b_fatigue_10 = 0
)
apollo_fixed <- c()
apollo_inputs <- apollo_validateInputs()

apollo_probabilities <- function(apollo_beta, apollo_inputs, functionality = "estimate"){
apollo_attach(apollo_beta, apollo_inputs)
on.exit(apollo_detach(apollo_beta, apollo_inputs))

P <- list()

V <- list()
V[['alt1']] = b_infection_min100* infection_min100.1 + b_infection_plus100 * infection_plus100.1 + b_infection_plus500 * infection_plus500.1 + b_bleeding_high * bleeding_high.1 +
b_transfusion_5jaar * transfusion_5jaar.1 + b_transfusion_25jaar * transfusion_25jaar.1 + b_fatigue_5* fatigue_5.1 + b_fatigue_10 * fatigue_10.1
V[['alt2']] = b_infection_min100* infection_min100.2 + b_infection_plus100 * infection_plus100.2 + b_infection_plus500 * infection_plus500.2 + b_bleeding_high * bleeding_high.2 +
b_transfusion_5jaar * transfusion_5jaar.2 + b_transfusion_25jaar * transfusion_25jaar.2 + b_fatigue_5* fatigue_5.2 + b_fatigue_10 * fatigue_10.2

mnl_settings <- list(
alternatives = c(alt1 = 1, alt2 = 2),
avail = list(alt1 = 1, alt2 = 1),
choiceVar = choice,
V = V
)

P[['model']] <- apollo_mnl(mnl_settings, functionality)
P <- apollo_panelProd(P, apollo_inputs, functionality)
P <- apollo_prepareProb(P, apollo_inputs, functionality)

return(P)
}
model <- apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, apollo_inputs)
Calculating log-likelihood at equal shares (LL(0)) for
applicable models...
Calculating log-likelihood at observed shares from
estimation data (LL(c)) for applicable models...
Calculating LL of each model component...
Calculating other model fit measures
Computing covariance matrix using analytical gradient.
0%....25%....50%....75%.100%
WARNING: Some eigenvalues of the Hessian are complex,
indicating that the Hessian is not symmetrical.
Computing score matrix...

Warning message:
In sqrt(diag(robvarcov)) : NaNs produced

Best regards, Waldo

Re: Error in MNL model

Posted: 24 Apr 2023, 17:16
by stephanehess
Hi

apologies for the slow reply, the forum was offline

1) can you share your outputs so we can help understand? It looks like an overspecification - are you sure you are normalising appropriately
2) regarding effects coding, the example is how to do it in Apollo, but of course note that effects coding is not giving you any advantages over dummy coding, and you can just use the dummy coding results and rescale them afterwards if you want

Stephane