I am trying to develop a nested logit model with 15 nests, each with 2 alternatives (labeled and unlabeled SKU). My data is structured in an aggregate form, so I use the quantities that were sold to calculate the log likelihood.
I am having problems with the estimation of this model. The Hessian norm always converges to infinitive, even when I try to estimate a simple MNL. I have tried different optimizers and different scales for my variables and the problem remains the same. Is there something wrong with the modeling?
Also, I need to calculate the average WTP for the labeled and unlabeled alternatives. Is it sufficient to do the division of the derivative of the remaining shelf life by the price of each of the alternatives and then average all the simulated labeled and unlabeled WTP's? Should the MU parameters not be considered for the calculation?
ASC_unlabeled = {}
ASC_labeled = {}
B_rsl_unlabeled = {}
B_rsl_labeled = {}
B_Price_unlabeled = {}
B_Price_labeled = {}
Mu = {}
nest = {}
for i in range(15):
ASC_unlabeled[i] = Beta('ASC_unlabeled' + str(array_skus[i]), 0, None, None, 0)
ASC_labeled[i] = Beta('ASC_labeled' + str(array_skus[i]), -0.184, None, None, 0)
B_rsl_unlabeled[i] = Beta('B_rsl_unlabeled' + str(array_skus[i]),2,None, None,0)
B_rsl_labeled[i] = Beta('B_rsl_etiqueta' + str(array_skus[i]),1,None, None,0)
B_Price_unlabeled[i] = Beta('B_Price_unlabeled' + str(array_skus[i]),-0.323,None, None,0)
B_Price_labeled[i] = Beta('B_Price_labeled' + str(array_skus[i]),-0.734,None, None,0)
Mu[i] = Beta('MU'+ str(array_skus[i]), 1, 1, 10, 0)
nest[i] = Mu[i], [2*i, 2*i+1]
ASC_unlabeled[0] = Beta('ASC_unlabeled6119649' , 0, None, None, 1)
nests = nest[0], nest[1], nest[2], nest[3], nest[4], nest[5], nest[6], nest[7], nest[8], nest[9], nest[10], nest[11], nest[12], nest[13], nest[14]
# Utilities
V = {}
av = {}
n = 0
for i in range(15):
V[i+n] = (ASC_unlabeled[i] + B_Price_unlabeled[i] * Variable(str(array_skus[i])+'_price_unlabeled') + B_rsl_unlabeled[i] * log((Variable(str(array_skus[i])+'_remaining_shelf_life_unlabeled'))+1))
av[i+n] = Variable(str(array_skus[i])+'_av')
n +=1
V[i+n] = (ASC_labeled[i] + B_Price_labeled[i] * Variable(str(array_skus[i])+'_price_labeled') + B_rsl_labeled[i] * Variable(str(array_skus[i])+'_remaining_shelf_life_labeled'))
av[i+n] = Variable(str(array_skus[i])+'_av_et')
logprob = (Variable(str(array_skus[0])+'_sold_unlabeled')) * (models.lognested(V, av, nests, 0)) + (Variable(str(array_skus[0])+'_sold_labeled')) * (models.lognested(V, av, nests, 1))
for i in range(1,15):
logprob += (Variable(str(array_skus[i])+'_sold_unlabeled') )* (models.lognested(V, av, nests, i*2))
logprob += (Variable(str(array_skus[i])+'_sold_labeled')) *( models.lognested(V, av, nests, (i*2+1)) )
results = biogeme.estimate(algorithm=opt.bioNewton, algoParameters={'maxiter':100})
Thank you in advance.
Kindest regards.