'MDCEV model estimation - all observations have zero probaility at starting value for model component

I am running an MDCEV model on location choice dataset and at first I ran into an error as "Log-likelihood calculation fails at values close to the starting values!" so I changed some starting values and now I am getting this eror:

Error in if (all(testL == 0)) stop("All observations have zero probability at starting value for model component "", : missing value where TRUE/FALSE needed

Could anyone give me some suggestions? Much appreciated!

And here is my code:

rm(list = ls())

library(apollo)

apollo_initialise()

apollo_control = list(
  modelName       = "MDCEV_no_outside_good",
  modelDescr      = "MDCEV model on housing supply data, alpha-gamma profile, no outside good and constants only in utilities",
  indivID         = "indivID", 
  outputDirectory = "output"
)

database = read.csv("Project_MDCEV.csv",header=TRUE)
alt = read.csv("alternatives.csv",header=TRUE)
attach(database)
View(database)

apollo_beta = c(alpha_base         = 10,
                gamma_gen          = -1,
                delta_acar         = 100,
                sig                = 1)

apollo_fixed = c("sig")


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()
  
 
  alternatives = as.character(alt$DAUID)

  
  avail = list()
  for(i in alt$DAUID){
    avail[paste0(i)] = 1
  }
  
  
  continuousChoice = list()
  for (i in alt$DAUID){
    continuousChoice[[paste0(i)]] = get(paste0("X",i))
  }
  
 
  V = list()
  for (i in alt$DAUID){
    V[[paste0(i)]] = delta_acar *alt$ACAR[which(alt$DAUID==paste0(i))]
  }
 
  
 
  alpha = list()
  for (i in alt$DAUID){
    alpha[paste0(i)]=1/(1+exp(-alpha_base))
  }
 
  

  gamma =list()
  for (i in alt$DAUID){
    gamma[paste0(i)]=gamma_gen
  }
  
 
  cost = list()
  for(i in alt$DAUID){
    cost[paste0(i)] = 1
  }
  
  budget <- budget_cal
  
  mdcev_settings <- list(alternatives      = alternatives,
                         avail             = avail,
                         continuousChoice  = continuousChoice,
                         utilities         = V,
                         alpha             = alpha,
                         gamma             = gamma, 
                         sigma             = sig, 
                         cost              = cost,
                         budget            = budget)
  
  
  P[["model"]] = apollo_mdcev(mdcev_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)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source