Page 1 of 1

Error in MNL model

Posted: 04 Apr 2023, 10:32
by Waldo
Dear Apollo team,

I'm encountering the following error when estimating a MNL model:

Error in if (!test) { : missing value where TRUE/FALSE needed

From what I read on R programming related websites this error is quite common and should be easy to solve, however I am not an experienced R-user and unable to incorporate the suggested solutions in the Apollo code.

The code I am using for the MNL model is almost identical to that of example 1 (model MNL_RP) on the example and code page. Do you know why I am getting this error, and is there any way how I can fix this?

apollo_initialise()
apollo_control <- list(
modelName = "CL_apollo",
modelDescr = "Patient preferences for treatment",
indivID = "ID")
database<-DCM_Domburg_adapt2
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)

Re: Error in MNL model

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

apologies for the slow response, the forum was offline due to a technical issue.

To help you with this issue, we would need to try the model on your data ourselves, can you share the material with us via e-mail?

Stephane