eMDC Starting Values
Posted: 13 May 2025, 22:59
Hello,
I am estimating a model with 21 alternatives, which correspond to 21 dishes on the menu. I would like to estimate the eMDC model with full substitution and complementarity effects. The code runs well when I set all the interaction terms between the 21 dishes to a fixed value of 0. However, after I remove these interactions from the fixed value list, the model returns the following error:
Error in apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, :
CALCULATION ISSUE - Log-likelihood calculation fails at values close to the starting values!
In addition: Warning messages:
1: In log(Gi) : NaNs produced
2: In log(Gi) : NaNs produced
3: In log(Gi) : NaNs produced
I have tried multiple ways to find the starting values for the interactions, but they all did work. Could you please provide any suggestions on this?
the code is here:
# ################################################################# #
#### LOAD LIBRARY AND DEFINE CORE SETTINGS ####
# ################################################################# #
### Clear memory
rm(list = ls())
### Load Apollo library
library(apollo)
### Set working directory (only works in RStudio)
##apollo_setWorkDir()
### Initialise code
apollo_initialise()
### Set core controls
apollo_control = list(
modelDescr = "Fast",
indivID = "Q_ResponseId",
outputDirectory = "output")
# ################################################################# #
#### LOAD DATA AND APPLY ANY TRANSFORMATIONS ####
# ################################################################# #
### Load data from within the Apollo package
database = Fast
### Create consumption variables for combined activities
# outside good: time spent at home and travelling
### Randomly split dataset into estimation (70%) and validation (30%)
set.seed(1)
database$validation = runif(nrow(database))>0.7
dbVal = database[ database$validation,] # validation sample
database = database[!database$validation,] # estimation sample
# ################################################################# #
#### DEFINE MODEL PARAMETERS ####
# ################################################################# #
### Parameters starting values c(name1=value1, name2=value2, ...)
apollo_beta = c(aincentive=0.066,
sigma = 2.469,
atax=0.219,
# Satiation
g1 = 0.942,
g2 = 1.033,
g3 = 0.995,
g4 = 0.980,
g5 = 1.053,
g6 = 1.016,
g7 = 0.999,
g8 = 1.083,
g9 = 1.163,
g10 = 0.778,
g11 = 0.779,
g12 = 0.732,
g13 = 0.788,
g14 = 0.625,
g15 = 0.412,
g16 = 0.719,
g17 = 0.559,
g18 = 0.574,
g19 = 0.546,
g20 = 0.630,
g21 = 0.683,
# Base utility
b1 = -2.794,
b2 = -3.298,
b3 = -2.772,
b4 = -3.912,
b5 = -3.172,
b6 = -4.422,
b7 = -4.007,
b8 = -4.962,
b9 = -3.398,
b10 = -3.221,
b11 = -2.954,
b12 = -3.666,
b13 = -3.413,
b14 = -2.528,
b15 = -0.773,
b16 = -5.021,
b17 = -2.508,
b18 = -3.479,
b19 = -2.745,
b20 = -3.807,
b21 = -4.485,
btax1 =-0.296,
btax2 =-0.396,
btax3 =-0.388,
btax4 =-0.368,
btax5 =-0.233,
btax6 =-0.075,
btax7 =-0.124,
btax8 =0.099,
btax9 =-0.090,
btax10 =-0.408,
btax11 =0.007,
btax12 =-0.239,
btax13 =-0.122,
btax14 =-0.317,
btax15 =-0.599,
btax16 =0.148,
btax17 =-0.297,
btax18 =-0.348,
btax19 =-0.595,
btax20 =-0.004,
btax21 =-0.172,
# Compl/subst
d1_2=0,
d1_3=0,
d1_4=0,
d1_5=0,
d1_6=0,
d1_7=0,
d1_8=0,
d1_9=0,
d1_10=0,
d1_11=0,
d1_12=0,
d1_13=0,
d1_14=0,
d1_15=0,
d1_16=0,
d1_17=0,
d1_18=0,
d1_19=0,
d1_20=0,
d1_21=0,
d2_3=0,
d2_4=0,
d2_5=0,
d2_6=0,
d2_7=0,
d2_8=0,
d2_9=0,
d2_10=0,
d2_11=0,
d2_12=0,
d2_13=0,
d2_14=0,
d2_15=0,
d2_16=0,
d2_17=0,
d2_18=0,
d2_19=0,
d2_20=0,
d2_21=0,
d3_4=-0,
d3_5=0,
d3_6=-0,
d3_7=-0,
d3_8=-0,
d3_9=0,
d3_10=0,
d3_11=0,
d3_12=0,
d3_13=0,
d3_14=0,
d3_15=0,
d3_16=-0,
d3_17=0,
d3_18=0,
d3_19=0,
d3_20=0,
d3_21=0,
d4_5=-0,
d4_6=0,
d4_7=0,
d4_8=0,
d4_9=-0,
d4_10=0,
d4_11=0,
d4_12=0,
d4_13=0,
d4_14=0,
d4_15=0,
d4_16=0,
d4_17=0,
d4_18=0,
d4_19=0,
d4_20=0,
d4_21=0,
d5_6=-0,
d5_7=-0,
d5_8=-0,
d5_9=-0,
d5_10=0,
d5_11=0,
d5_12=0,
d5_13=0,
d5_14=0,
d5_15=0,
d5_16=0,
d5_17=0,
d5_18=0,
d5_19=0,
d5_20=0,
d5_21=0,
d6_7=0,
d6_8=0,
d6_9=-0,
d6_10=0,
d6_11=0,
d6_12=0,
d6_13=0,
d6_14=0,
d6_15=0,
d6_16=0,
d6_17=0,
d6_18=0,
d6_19=0,
d6_20=0,
d6_21=0,
d7_8=0,
d7_9=-0,
d7_10=0,
d7_11=0,
d7_12=0,
d7_13=0,
d7_14=0,
d7_15=0,
d7_16=-0,
d7_17=0,
d7_18=0,
d7_19=0,
d7_20=0,
d7_21=0,
d8_9=-0,
d8_10=0,
d8_11=0,
d8_12=0,
d8_13=0,
d8_14=0,
d8_15=0,
d8_16=0,
d8_17=-0,
d8_18=0,
d8_19=0,
d8_20=0,
d8_21=0,
d9_10=0,
d9_11=0,
d9_12=0,
d9_13=0,
d9_14=0,
d9_15=-0,
d9_16=0,
d9_17=0,
d9_18=0,
d9_19=0,
d9_20=0,
d9_21=0,
d10_11=-0,
d10_12=-0,
d10_13=-0,
d10_14=0,
d10_15=0,
d10_16=0,
d10_17=0,
d10_18=0,
d10_19=0,
d10_20=0,
d10_21=0,
d11_12=0,
d11_13=0,
d11_14=0,
d11_15=0,
d11_16=0,
d11_17=0,
d11_18=0,
d11_19=0,
d11_20=0,
d11_21=0,
d12_13=0,
d12_14=0,
d12_15=0,
d12_16=0,
d12_17=0,
d12_18=0,
d12_19=0,
d12_20=0,
d12_21=0,
d13_14=0,
d13_15=0,
d13_16=0,
d13_17=0,
d13_18=0,
d13_19=0,
d13_20=0,
d13_21=0,
d14_15=0,
d14_16=0,
d14_17=0,
d14_18=0,
d14_19=0,
d14_20=0,
d14_21=0,
d15_16=0,
d15_17=0,
d15_18=0,
d15_19=0,
d15_20=0,
d15_21=0,
d16_17=0,
d16_18=0,
d16_19=0,
d16_20=0,
d16_21=0,
d17_18=0,
d17_19=0,
d17_20=0,
d17_21=0,
d18_19=0,
d18_20=0,
d18_21=0,
d19_20=0,
d19_21=0,
d20_21=0)
### Names of fixed parameters
apollo_fixed = c()
# ################################################################# #
#### GROUP AND VALIDATE INPUTS ####
# ################################################################# #
apollo_inputs = apollo_validateInputs()
# ################################################################# #
#### DEFINE MODEL AND LIKELIHOOD FUNCTION ####
# ################################################################# #
apollo_probabilities=function(apollo_beta, apollo_inputs,
functionality="estimate"){
### Initialise
apollo_attach(apollo_beta, apollo_inputs)
on.exit(apollo_detach(apollo_beta, apollo_inputs))
P = list()
### Prepare Inputs
alts = c("item1", "item2", "item3", "item4", "item5","item6", "item7", "item8", "item9", "item10", "item11", "item12", "item13", "item14", "item15","item16", "item17", "item18", "item19", "item20","item21" )
nAlt = length(alts)
ones = setNames(as.list(rep(1, nAlt)), alts)
continuousChoice = list(item1=item1/1,
item2=item2/1,
item3=item3/1,
item4=item4/1,
item5=item5/1,
item6=item6/1,
item7=item7/1,
item8=item8/1,
item9=item9/1,
item10=item10/1,
item11=item11/1,
item12=item12/1,
item13=item13/1,
item14=item14/1,
item15=item15/1,
item16=item16/1,
item17=item17/1,
item18=item18/1,
item19=item19/1,
item20=item20/1,
item21=item21/1)
cost = list(item1=p1/1,
item2=p2/1,
item3=p3/1,
item4=p4/1,
item5=p5/1,
item6=p6/1,
item7=p7/1,
item8=p8/1,
item9=p9/1,
item10=p10/1,
item11=p11/1,
item12=p12/1,
item13=p13/1,
item14=p14/1,
item15=p15/1,
item16=p16/1,
item17=p17/1,
item18=p18/1,
item19=p19/1,
item20=p20/1,
item21=p21/1)
utilities = list(
item1 = b1 + btax1*tax,
item2 = b2 + btax2*tax,
item3 = b3 + btax3*tax,
item4 = b4 + btax4*tax,
item5 = b5 + btax5*tax,
item6 = b6 + btax6*tax,
item7 = b7 + btax7*tax,
item8 = b8 + btax8*tax,
item9 = b9 + btax9*tax,
item10 = b10 + btax10*tax,
item11 = b11 + btax11*tax,
item12 = b12 + btax12*tax,
item13 = b13 + btax13*tax,
item14 = b14 + btax14*tax,
item15 = b15 + btax15*tax,
item16 = b16 + btax16*tax,
item17 = b17 + btax17*tax,
item18 = b18 + btax18*tax,
item19 = b19 + btax19*tax,
item20 = b20 + btax20*tax,
item21 = b21 + btax21*tax
)
gamma = list( item1 = g1,
item2 = g2,
item3 = g3,
item4 = g4,
item5 = g5,
item6 = g6,
item7 = g7,
item8 = g8,
item9 = g9,
item10 = g10,
item11 = g11,
item12 = g12,
item13 = g13,
item14 = g14,
item15 = g15,
item16 = g16,
item17 = g17,
item18 = g18,
item19 = g19,
item20 = g20,
item21 = g21
)
delta = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_3, d2_3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_4, d2_4, d3_4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_5, d2_5, d3_5, d4_5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_6, d2_6, d3_6, d4_6, d5_6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_7, d2_7, d3_7, d4_7, d5_7, d6_7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_8, d2_8, d3_8, d4_8, d5_8, d6_8, d7_8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_9, d2_9, d3_9, d4_9, d5_9, d6_9, d7_9, d8_9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_10, d2_10, d3_10, d4_10, d5_10, d6_10, d7_10, d8_10, d9_10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_11, d2_11, d3_11, d4_11, d5_11, d6_11, d7_11, d8_11, d9_11, d10_11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_12, d2_12, d3_12, d4_12, d5_12, d6_12, d7_12, d8_12, d9_12, d10_12, d11_12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_13, d2_13, d3_13, d4_13, d5_13, d6_13, d7_13, d8_13, d9_13, d10_13, d11_13, d12_13, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_14, d2_14, d3_14, d4_14, d5_14, d6_14, d7_14, d8_14, d9_14, d10_14, d11_14, d12_14, d13_14, 0, 0, 0, 0, 0, 0, 0, 0,
d1_15, d2_15, d3_15, d4_15, d5_15, d6_15, d7_15, d8_15, d9_15, d10_15, d11_15, d12_15, d13_15, d14_15, 0, 0, 0, 0, 0, 0, 0,
d1_16, d2_16, d3_16, d4_16, d5_16, d6_16, d7_16, d8_16, d9_16, d10_16, d11_16, d12_16, d13_16, d14_16, d15_16, 0, 0, 0, 0, 0, 0,
d1_17, d2_17, d3_17, d4_17, d5_17, d6_17, d7_17, d8_17, d9_17, d10_17, d11_17, d12_17, d13_17, d14_17, d15_17, d16_17, 0, 0, 0, 0, 0,
d1_18, d2_18, d3_18, d4_18, d5_18, d6_18, d7_18, d8_18, d9_18, d10_18, d11_18, d12_18, d13_18, d14_18, d15_18, d16_18, d17_18, 0, 0, 0, 0,
d1_19, d2_19, d3_19, d4_19, d5_19, d6_19, d7_19, d8_19, d9_19, d10_19, d11_19, d12_19, d13_19, d14_19, d15_19, d16_19, d17_19, d18_19, 0, 0, 0,
d1_20, d2_20, d3_20, d4_20, d5_20, d6_20, d7_20, d8_20, d9_20, d10_20, d11_20, d12_20, d13_20, d14_20, d15_20, d16_20, d17_20, d18_20, d19_20, 0, 0,
d1_21, d2_21, d3_21, d4_21, d5_21, d6_21, d7_21, d8_21, d9_21, d10_21, d11_21, d12_21, d13_21, d14_21, d15_21, d16_21, d17_21, d18_21, d19_21, d20_21, 0)
delta = matrix(delta, nrow=nAlt, ncol=nAlt, byrow=TRUE)
emdc_settings = list(continuousChoice = continuousChoice,
avail = ones,
utilityOutside = aincentive*tenper+atax*tax,
utilities = utilities,
budget = real_budget,
sigma = sigma,
gamma = gamma,
delta = delta,
cost = cost,
maxIterations=20)
P[["model"]] = apollo_emdc(emdc_settings, functionality)
### Comment out as necessary
P = apollo_panelProd(P, apollo_inputs, functionality)
P = apollo_prepareProb(P, apollo_inputs, functionality)
return(P)
}
# ################################################################# #
#### MODEL ESTIMATION ####
# ################################################################# #
model = apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, apollo_inputs)
I am estimating a model with 21 alternatives, which correspond to 21 dishes on the menu. I would like to estimate the eMDC model with full substitution and complementarity effects. The code runs well when I set all the interaction terms between the 21 dishes to a fixed value of 0. However, after I remove these interactions from the fixed value list, the model returns the following error:
Error in apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, :
CALCULATION ISSUE - Log-likelihood calculation fails at values close to the starting values!
In addition: Warning messages:
1: In log(Gi) : NaNs produced
2: In log(Gi) : NaNs produced
3: In log(Gi) : NaNs produced
I have tried multiple ways to find the starting values for the interactions, but they all did work. Could you please provide any suggestions on this?
the code is here:
# ################################################################# #
#### LOAD LIBRARY AND DEFINE CORE SETTINGS ####
# ################################################################# #
### Clear memory
rm(list = ls())
### Load Apollo library
library(apollo)
### Set working directory (only works in RStudio)
##apollo_setWorkDir()
### Initialise code
apollo_initialise()
### Set core controls
apollo_control = list(
modelDescr = "Fast",
indivID = "Q_ResponseId",
outputDirectory = "output")
# ################################################################# #
#### LOAD DATA AND APPLY ANY TRANSFORMATIONS ####
# ################################################################# #
### Load data from within the Apollo package
database = Fast
### Create consumption variables for combined activities
# outside good: time spent at home and travelling
### Randomly split dataset into estimation (70%) and validation (30%)
set.seed(1)
database$validation = runif(nrow(database))>0.7
dbVal = database[ database$validation,] # validation sample
database = database[!database$validation,] # estimation sample
# ################################################################# #
#### DEFINE MODEL PARAMETERS ####
# ################################################################# #
### Parameters starting values c(name1=value1, name2=value2, ...)
apollo_beta = c(aincentive=0.066,
sigma = 2.469,
atax=0.219,
# Satiation
g1 = 0.942,
g2 = 1.033,
g3 = 0.995,
g4 = 0.980,
g5 = 1.053,
g6 = 1.016,
g7 = 0.999,
g8 = 1.083,
g9 = 1.163,
g10 = 0.778,
g11 = 0.779,
g12 = 0.732,
g13 = 0.788,
g14 = 0.625,
g15 = 0.412,
g16 = 0.719,
g17 = 0.559,
g18 = 0.574,
g19 = 0.546,
g20 = 0.630,
g21 = 0.683,
# Base utility
b1 = -2.794,
b2 = -3.298,
b3 = -2.772,
b4 = -3.912,
b5 = -3.172,
b6 = -4.422,
b7 = -4.007,
b8 = -4.962,
b9 = -3.398,
b10 = -3.221,
b11 = -2.954,
b12 = -3.666,
b13 = -3.413,
b14 = -2.528,
b15 = -0.773,
b16 = -5.021,
b17 = -2.508,
b18 = -3.479,
b19 = -2.745,
b20 = -3.807,
b21 = -4.485,
btax1 =-0.296,
btax2 =-0.396,
btax3 =-0.388,
btax4 =-0.368,
btax5 =-0.233,
btax6 =-0.075,
btax7 =-0.124,
btax8 =0.099,
btax9 =-0.090,
btax10 =-0.408,
btax11 =0.007,
btax12 =-0.239,
btax13 =-0.122,
btax14 =-0.317,
btax15 =-0.599,
btax16 =0.148,
btax17 =-0.297,
btax18 =-0.348,
btax19 =-0.595,
btax20 =-0.004,
btax21 =-0.172,
# Compl/subst
d1_2=0,
d1_3=0,
d1_4=0,
d1_5=0,
d1_6=0,
d1_7=0,
d1_8=0,
d1_9=0,
d1_10=0,
d1_11=0,
d1_12=0,
d1_13=0,
d1_14=0,
d1_15=0,
d1_16=0,
d1_17=0,
d1_18=0,
d1_19=0,
d1_20=0,
d1_21=0,
d2_3=0,
d2_4=0,
d2_5=0,
d2_6=0,
d2_7=0,
d2_8=0,
d2_9=0,
d2_10=0,
d2_11=0,
d2_12=0,
d2_13=0,
d2_14=0,
d2_15=0,
d2_16=0,
d2_17=0,
d2_18=0,
d2_19=0,
d2_20=0,
d2_21=0,
d3_4=-0,
d3_5=0,
d3_6=-0,
d3_7=-0,
d3_8=-0,
d3_9=0,
d3_10=0,
d3_11=0,
d3_12=0,
d3_13=0,
d3_14=0,
d3_15=0,
d3_16=-0,
d3_17=0,
d3_18=0,
d3_19=0,
d3_20=0,
d3_21=0,
d4_5=-0,
d4_6=0,
d4_7=0,
d4_8=0,
d4_9=-0,
d4_10=0,
d4_11=0,
d4_12=0,
d4_13=0,
d4_14=0,
d4_15=0,
d4_16=0,
d4_17=0,
d4_18=0,
d4_19=0,
d4_20=0,
d4_21=0,
d5_6=-0,
d5_7=-0,
d5_8=-0,
d5_9=-0,
d5_10=0,
d5_11=0,
d5_12=0,
d5_13=0,
d5_14=0,
d5_15=0,
d5_16=0,
d5_17=0,
d5_18=0,
d5_19=0,
d5_20=0,
d5_21=0,
d6_7=0,
d6_8=0,
d6_9=-0,
d6_10=0,
d6_11=0,
d6_12=0,
d6_13=0,
d6_14=0,
d6_15=0,
d6_16=0,
d6_17=0,
d6_18=0,
d6_19=0,
d6_20=0,
d6_21=0,
d7_8=0,
d7_9=-0,
d7_10=0,
d7_11=0,
d7_12=0,
d7_13=0,
d7_14=0,
d7_15=0,
d7_16=-0,
d7_17=0,
d7_18=0,
d7_19=0,
d7_20=0,
d7_21=0,
d8_9=-0,
d8_10=0,
d8_11=0,
d8_12=0,
d8_13=0,
d8_14=0,
d8_15=0,
d8_16=0,
d8_17=-0,
d8_18=0,
d8_19=0,
d8_20=0,
d8_21=0,
d9_10=0,
d9_11=0,
d9_12=0,
d9_13=0,
d9_14=0,
d9_15=-0,
d9_16=0,
d9_17=0,
d9_18=0,
d9_19=0,
d9_20=0,
d9_21=0,
d10_11=-0,
d10_12=-0,
d10_13=-0,
d10_14=0,
d10_15=0,
d10_16=0,
d10_17=0,
d10_18=0,
d10_19=0,
d10_20=0,
d10_21=0,
d11_12=0,
d11_13=0,
d11_14=0,
d11_15=0,
d11_16=0,
d11_17=0,
d11_18=0,
d11_19=0,
d11_20=0,
d11_21=0,
d12_13=0,
d12_14=0,
d12_15=0,
d12_16=0,
d12_17=0,
d12_18=0,
d12_19=0,
d12_20=0,
d12_21=0,
d13_14=0,
d13_15=0,
d13_16=0,
d13_17=0,
d13_18=0,
d13_19=0,
d13_20=0,
d13_21=0,
d14_15=0,
d14_16=0,
d14_17=0,
d14_18=0,
d14_19=0,
d14_20=0,
d14_21=0,
d15_16=0,
d15_17=0,
d15_18=0,
d15_19=0,
d15_20=0,
d15_21=0,
d16_17=0,
d16_18=0,
d16_19=0,
d16_20=0,
d16_21=0,
d17_18=0,
d17_19=0,
d17_20=0,
d17_21=0,
d18_19=0,
d18_20=0,
d18_21=0,
d19_20=0,
d19_21=0,
d20_21=0)
### Names of fixed parameters
apollo_fixed = c()
# ################################################################# #
#### GROUP AND VALIDATE INPUTS ####
# ################################################################# #
apollo_inputs = apollo_validateInputs()
# ################################################################# #
#### DEFINE MODEL AND LIKELIHOOD FUNCTION ####
# ################################################################# #
apollo_probabilities=function(apollo_beta, apollo_inputs,
functionality="estimate"){
### Initialise
apollo_attach(apollo_beta, apollo_inputs)
on.exit(apollo_detach(apollo_beta, apollo_inputs))
P = list()
### Prepare Inputs
alts = c("item1", "item2", "item3", "item4", "item5","item6", "item7", "item8", "item9", "item10", "item11", "item12", "item13", "item14", "item15","item16", "item17", "item18", "item19", "item20","item21" )
nAlt = length(alts)
ones = setNames(as.list(rep(1, nAlt)), alts)
continuousChoice = list(item1=item1/1,
item2=item2/1,
item3=item3/1,
item4=item4/1,
item5=item5/1,
item6=item6/1,
item7=item7/1,
item8=item8/1,
item9=item9/1,
item10=item10/1,
item11=item11/1,
item12=item12/1,
item13=item13/1,
item14=item14/1,
item15=item15/1,
item16=item16/1,
item17=item17/1,
item18=item18/1,
item19=item19/1,
item20=item20/1,
item21=item21/1)
cost = list(item1=p1/1,
item2=p2/1,
item3=p3/1,
item4=p4/1,
item5=p5/1,
item6=p6/1,
item7=p7/1,
item8=p8/1,
item9=p9/1,
item10=p10/1,
item11=p11/1,
item12=p12/1,
item13=p13/1,
item14=p14/1,
item15=p15/1,
item16=p16/1,
item17=p17/1,
item18=p18/1,
item19=p19/1,
item20=p20/1,
item21=p21/1)
utilities = list(
item1 = b1 + btax1*tax,
item2 = b2 + btax2*tax,
item3 = b3 + btax3*tax,
item4 = b4 + btax4*tax,
item5 = b5 + btax5*tax,
item6 = b6 + btax6*tax,
item7 = b7 + btax7*tax,
item8 = b8 + btax8*tax,
item9 = b9 + btax9*tax,
item10 = b10 + btax10*tax,
item11 = b11 + btax11*tax,
item12 = b12 + btax12*tax,
item13 = b13 + btax13*tax,
item14 = b14 + btax14*tax,
item15 = b15 + btax15*tax,
item16 = b16 + btax16*tax,
item17 = b17 + btax17*tax,
item18 = b18 + btax18*tax,
item19 = b19 + btax19*tax,
item20 = b20 + btax20*tax,
item21 = b21 + btax21*tax
)
gamma = list( item1 = g1,
item2 = g2,
item3 = g3,
item4 = g4,
item5 = g5,
item6 = g6,
item7 = g7,
item8 = g8,
item9 = g9,
item10 = g10,
item11 = g11,
item12 = g12,
item13 = g13,
item14 = g14,
item15 = g15,
item16 = g16,
item17 = g17,
item18 = g18,
item19 = g19,
item20 = g20,
item21 = g21
)
delta = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_3, d2_3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_4, d2_4, d3_4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_5, d2_5, d3_5, d4_5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_6, d2_6, d3_6, d4_6, d5_6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_7, d2_7, d3_7, d4_7, d5_7, d6_7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_8, d2_8, d3_8, d4_8, d5_8, d6_8, d7_8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_9, d2_9, d3_9, d4_9, d5_9, d6_9, d7_9, d8_9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_10, d2_10, d3_10, d4_10, d5_10, d6_10, d7_10, d8_10, d9_10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_11, d2_11, d3_11, d4_11, d5_11, d6_11, d7_11, d8_11, d9_11, d10_11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_12, d2_12, d3_12, d4_12, d5_12, d6_12, d7_12, d8_12, d9_12, d10_12, d11_12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_13, d2_13, d3_13, d4_13, d5_13, d6_13, d7_13, d8_13, d9_13, d10_13, d11_13, d12_13, 0, 0, 0, 0, 0, 0, 0, 0, 0,
d1_14, d2_14, d3_14, d4_14, d5_14, d6_14, d7_14, d8_14, d9_14, d10_14, d11_14, d12_14, d13_14, 0, 0, 0, 0, 0, 0, 0, 0,
d1_15, d2_15, d3_15, d4_15, d5_15, d6_15, d7_15, d8_15, d9_15, d10_15, d11_15, d12_15, d13_15, d14_15, 0, 0, 0, 0, 0, 0, 0,
d1_16, d2_16, d3_16, d4_16, d5_16, d6_16, d7_16, d8_16, d9_16, d10_16, d11_16, d12_16, d13_16, d14_16, d15_16, 0, 0, 0, 0, 0, 0,
d1_17, d2_17, d3_17, d4_17, d5_17, d6_17, d7_17, d8_17, d9_17, d10_17, d11_17, d12_17, d13_17, d14_17, d15_17, d16_17, 0, 0, 0, 0, 0,
d1_18, d2_18, d3_18, d4_18, d5_18, d6_18, d7_18, d8_18, d9_18, d10_18, d11_18, d12_18, d13_18, d14_18, d15_18, d16_18, d17_18, 0, 0, 0, 0,
d1_19, d2_19, d3_19, d4_19, d5_19, d6_19, d7_19, d8_19, d9_19, d10_19, d11_19, d12_19, d13_19, d14_19, d15_19, d16_19, d17_19, d18_19, 0, 0, 0,
d1_20, d2_20, d3_20, d4_20, d5_20, d6_20, d7_20, d8_20, d9_20, d10_20, d11_20, d12_20, d13_20, d14_20, d15_20, d16_20, d17_20, d18_20, d19_20, 0, 0,
d1_21, d2_21, d3_21, d4_21, d5_21, d6_21, d7_21, d8_21, d9_21, d10_21, d11_21, d12_21, d13_21, d14_21, d15_21, d16_21, d17_21, d18_21, d19_21, d20_21, 0)
delta = matrix(delta, nrow=nAlt, ncol=nAlt, byrow=TRUE)
emdc_settings = list(continuousChoice = continuousChoice,
avail = ones,
utilityOutside = aincentive*tenper+atax*tax,
utilities = utilities,
budget = real_budget,
sigma = sigma,
gamma = gamma,
delta = delta,
cost = cost,
maxIterations=20)
P[["model"]] = apollo_emdc(emdc_settings, functionality)
### Comment out as necessary
P = apollo_panelProd(P, apollo_inputs, functionality)
P = apollo_prepareProb(P, apollo_inputs, functionality)
return(P)
}
# ################################################################# #
#### MODEL ESTIMATION ####
# ################################################################# #
model = apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, apollo_inputs)