Dear Apollo team,
I am trying to estimate a LC model for my choice data. Respondents had to choose from 2 options (Robot A and Robot B), attributes were: size (small, medium*, large), appearance(human, robot*, animal), function (func1*, func2, func3, func4), surveillance (yes/no), emergency call (yes/no), cost (0,50,100,150). I have data for two countries: Hungary and Poland, 400-400 responses.
The MNL model works really well for both countries - reliable WTP estimates, robust coefficients. However, when I try to estimate a simple LC model with two classes, no covariates for class membership, for Hungary for Class 1, I get positive (close to 0 though) coefficient for cost. For Poland both cost coeffs are negative, but for Class 1 it is again is very close to zero. (Also, majority 70%+ of respondents are in Class 1 - in the close to 0 coeff group). When I am trying to estimate WTP values with unconditionals, these are higher in volume than the MNL estimates for both countries. Do you think sg wrong with my model? Or is it possible, that one group is not cost sensitive (potentially due to low price levels defined in the task)? The MNL model worked well on the data, and I also tried to clean the data and get rid of a few consistent left-or right responses, and also tried with different initial parameter values, but results were similar.
I would really appreciate your thoughts on what could be an explanation for the positive cost coeff in Hungary, and the higher WTP estimates from the LC model. My code and outputs are below for both Hungary (I can send Poland separately due to character limits).
Many thanks,
Petra
************************************Code MNL Hungary *******************************************************************
# ################################################################# #
#### LOAD LIBRARY AND DEFINE CORE SETTINGS ####
# ################################################################# #
### Clear memory
rm(list = ls())
setwd("C:/Users/cf21091/OneDrive - University of Bristol/TKP/data/analysis")
### Load Apollo library
library(apollo)
### Initialise code
apollo_initialise()
### Set core controls
apollo_control = list(
modelName = "mnl_robot_hu_asc",
modelDescr = "MNL on robot informal care - Hungary",
indivID = "id",
outputDirectory = "output_base_hu"
)
# ################################################################# #
#### LOAD DATA AND APPLY ANY TRANSFORMATIONS ####
# ################################################################# #
### Loading data from package
### if data is to be loaded from a file (e.g. called data.csv),
### the code would be: database =
database=read.csv("robot_choices_data_hu.csv",header=TRUE)
### for data dictionary, use ?apollo_drugChoiceData
# ################################################################# #
#### DEFINE MODEL PARAMETERS ####
# ################################################################# #
### Vector of parameters, including any that are kept fixed in estimation
apollo_beta = c(asc1=0,
asc2=0,
coeff_robot = 0,
coeff_human = 0,
coeff_animal = 0,
coeff_small = 0,
coeff_medium = 0,
coeff_large = 0,
coeff_func1 = 0,
coeff_func2 = 0,
coeff_func3 = 0,
coeff_func4 = 0,
coeff_surv = 0,
coeff_help = 0,
coeff_cost = 0
)
### Vector with names (in quotes) of parameters to be kept fixed at their starting value in apollo_beta, use apollo_beta_fixed = c() if none
apollo_fixed = c("coeff_medium", "coeff_robot", "coeff_func1", "asc2")
# ################################################################# #
#### GROUP AND VALIDATE INPUTS ####
# ################################################################# #
apollo_inputs = apollo_validateInputs()
# ################################################################# #
#### DEFINE MODEL AND LIKELIHOOD FUNCTION ####
# ################################################################# #
apollo_probabilities=function(apollo_beta, apollo_inputs, functionality="estimate"){
### Attach inputs and detach after function exit
apollo_attach(apollo_beta, apollo_inputs)
on.exit(apollo_detach(apollo_beta, apollo_inputs))
### Create list of probabilities P
P = list()
### Likelihood of choices
### List of utilities: these must use the same names as in mnl_settings, order is irrelevant
V = list()
V[["alt1"]] = asc1+(coeff_robot*(a_type==0) + coeff_human*(a_type==1)+ coeff_animal*(a_type==2)
+ coeff_small*(a_size==0) + coeff_medium*(a_size==1) + coeff_large*(a_size==2)
+ coeff_func1*(a_function==0) + coeff_func2*(a_function==1) + coeff_func3*(a_function==2) + coeff_func4*(a_function==3)
+ coeff_help*a_help
+ coeff_surv*a_surv
+ coeff_cost*a_cost)
V[["alt2"]] = asc2+ ( coeff_robot*(b_type==0) + coeff_human*(b_type==1)+ coeff_animal*(b_type==2)
+ coeff_small*(b_size==0) + coeff_medium*(b_size==1) + coeff_large*(b_size==2)
+ coeff_func1*(b_function==0) + coeff_func2*(b_function==1) + coeff_func3*(b_function==2) + coeff_func4*(b_function==3)
+ coeff_help*b_help
+ coeff_surv*b_surv
+ coeff_cost*b_cost )
### Define settings for MNL model component
mnl_settings = list(
alternatives = c(alt1=1, alt2=2),
choiceVar = choice_,
utilities = V,
componentName = "choice"
)
### Compute probabilities for MNL model component
P[["model"]] = apollo_mnl(mnl_settings, functionality)
### Take product across observation for same individual
P = apollo_panelProd(P, apollo_inputs, functionality)
### Prepare and return outputs of function
P = apollo_prepareProb(P, apollo_inputs, functionality)
return(P)
}
# ################################################################# #
#### MODEL ESTIMATION ####
# ################################################################# #
### Estimate model
model = apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, apollo_inputs)
# ################################################################# #
#### MODEL OUTPUTS ####
# ################################################################# #
# ----------------------------------------------------------------- #
#---- FORMATTED OUTPUT (TO SCREEN) ----
# ----------------------------------------------------------------- #
modelOutput_settings=list(printPVal=TRUE)
apollo_modelOutput(model, modelOutput_settings)
# ----------------------------------------------------------------- #
#---- FORMATTED OUTPUT (TO FILE, using model name) ----
# ----------------------------------------------------------------- #
apollo_saveOutput(model, modelOutput_settings)
********************************Results MNL HU********************************************************
> # ################################################################# #
> #### MODEL ESTIMATION ####
> # ################################################################# #
>
> ### Estimate model
> model = apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, apollo_inputs)
Preparing user-defined functions.
Testing likelihood function...
Setting "avail" is missing, so full availability is assumed.
Overview of choices for MNL model component choice:
alt1 alt2
Times available 4000.00 4000.00
Times chosen 2117.00 1883.00
Percentage chosen overall 52.92 47.08
Percentage chosen when available 52.92 47.08
Pre-processing likelihood function...
Testing influence of parameters
Starting main estimation
BGW using analytic model derivatives supplied by caller...
Iterates will be written to:
output_base_hu/mnl_robot_hu_asc_iterations.csv
it nf F RELDF PRELDF RELDX MODEL stppar
0 1 2.772588722e+03
1 3 2.749526747e+03 8.318e-03 8.318e-03 1.00e+00 G 9.57e+00
2 5 2.628225305e+03 4.412e-02 4.431e-02 8.20e-01 G 3.56e-01
3 6 2.611311991e+03 6.435e-03 6.713e-03 2.16e-01 G 0.00e+00
4 7 2.611283212e+03 1.102e-05 1.106e-05 7.85e-03 S 0.00e+00
5 8 2.611283173e+03 1.491e-08 1.486e-08 2.76e-04 S 0.00e+00
6 9 2.611283173e+03 3.424e-11 3.383e-11 1.36e-05 S 0.00e+00
***** Relative function convergence *****
Estimated parameters with approximate standard errors from BHHH matrix:
Estimate BHHH se BHH t-ratio (0)
asc1 0.135263 0.03303 4.0947
asc2 0.000000 NA NA
coeff_robot 0.000000 NA NA
coeff_human -0.160443 0.04555 -3.5220
coeff_animal -0.463064 0.04707 -9.8377
coeff_small -0.127603 0.04586 -2.7827
coeff_medium 0.000000 NA NA
coeff_large -0.148183 0.04840 -3.0616
coeff_func1 0.000000 NA NA
coeff_func2 0.433066 0.05674 7.6327
coeff_func3 0.239602 0.05570 4.3020
coeff_func4 0.044368 0.05838 0.7600
coeff_surv 0.138042 0.03299 4.1838
coeff_help 0.144731 0.03303 4.3822
coeff_cost -0.002957 2.9503e-04 -10.0230
Final LL: -2611.2832
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 numerical jacobian of analytical gradient.
0%....25%....50%....75%..100%
Negative definite Hessian with maximum eigenvalue: -153.509396
Computing score matrix...
Your model was estimated using the BGW algorithm. Please acknowledge this by citing Bunch et al. (1993) - DOI 10.1145/151271.151279
>
> # ################################################################# #
> #### MODEL OUTPUTS ####
> # ################################################################# #
>
> # ----------------------------------------------------------------- #
> #---- FORMATTED OUTPUT (TO SCREEN) ----
> # ----------------------------------------------------------------- #
>
>
> modelOutput_settings=list(printPVal=TRUE)
> apollo_modelOutput(model, modelOutput_settings)
Model run by cf21091 using Apollo 0.3.4 on R 4.3.0 for Windows.
Please acknowledge the use of Apollo by citing Hess & Palma (2019)
DOI 10.1016/j.jocm.2019.100170
www.ApolloChoiceModelling.com
Model name : mnl_robot_hu_asc
Model description : MNL on robot informal care - Hungary
Model run at : 2025-09-05 11:02:24.336505
Estimation method : bgw
Model diagnosis : Relative function convergence
Optimisation diagnosis : Maximum found
hessian properties : Negative definite
maximum eigenvalue : -153.509396
reciprocal of condition number : 1.33772e-05
Number of individuals : 400
Number of rows in database : 4000
Number of modelled outcomes : 4000
Number of cores used : 1
Model without mixing
LL(start) : -2772.59
LL at equal shares, LL(0) : -2772.59
LL at observed shares, LL(C) : -2765.74
LL(final) : -2611.28
Rho-squared vs equal shares : 0.0582
Adj.Rho-squared vs equal shares : 0.0542
Rho-squared vs observed shares : 0.0558
Adj.Rho-squared vs observed shares : 0.0522
AIC : 5244.57
BIC : 5313.8
Estimated parameters : 11
Time taken (hh:mm:ss) : 00:00:1.63
pre-estimation : 00:00:0.78
estimation : 00:00:0.19
post-estimation : 00:00:0.67
Iterations : 6
Unconstrained optimisation.
Estimates:
Estimate s.e. t.rat.(0) p(1-sided) Rob.s.e. Rob.t.rat.(0) p(1-sided)
asc1 0.135263 0.03303 4.0947 2.114e-05 0.03678 3.6778 1.1764e-04
asc2 0.000000 NA NA NA NA NA NA
coeff_robot 0.000000 NA NA NA NA NA NA
coeff_human -0.160443 0.04577 -3.5052 2.2813e-04 0.04804 -3.3398 4.1919e-04
coeff_animal -0.463064 0.04665 -9.9271 0.000000 0.05568 -8.3160 0.000000
coeff_small -0.127603 0.04624 -2.7593 0.002896 0.04462 -2.8595 0.002122
coeff_medium 0.000000 NA NA NA NA NA NA
coeff_large -0.148183 0.04848 -3.0564 0.001120 0.04556 -3.2524 5.7213e-04
coeff_func1 0.000000 NA NA NA NA NA NA
coeff_func2 0.433066 0.05727 7.5618 1.987e-14 0.06515 6.6468 1.498e-11
coeff_func3 0.239602 0.05622 4.2618 1.014e-05 0.05519 4.3417 7.069e-06
coeff_func4 0.044368 0.05804 0.7644 0.222310 0.05878 0.7548 0.225191
coeff_surv 0.138042 0.03299 4.1840 1.432e-05 0.03605 3.8289 6.437e-05
coeff_help 0.144731 0.03300 4.3852 5.795e-06 0.03405 4.2511 1.064e-05
coeff_cost -0.002957 2.9733e-04 -9.9454 0.000000 3.9817e-04 -7.4266 5.573e-14
Running Delta method computation for user-defined function using robust standard errors
Expression Value s.e. t-ratio (0)
wtp_human_vs_robot 54.2577 17.0716 3.18
INFORMATION: The results of the Delta method calculations are returned invisibly as an output from this function. Calling the function via
result=apollo_deltaMethod(...) will save this output in an object called result (or otherwise named object).
>
> deltaMethod_settings=list(expression=c(wtp_animal_vs_robot="coeff_animal/coeff_cost"))
> apollo_deltaMethod(model, deltaMethod_settings)
Running Delta method computation for user-defined function using robust standard errors
Expression Value s.e. t-ratio (0)
wtp_animal_vs_robot 156.5959 24.979 6.27
INFORMATION: The results of the Delta method calculations are returned invisibly as an output from this function. Calling the function via
result=apollo_deltaMethod(...) will save this output in an object called result (or otherwise named object).
>
> deltaMethod_settings=list(expression=c(wtp_small_vs_medium="coeff_small/coeff_cost"))
> apollo_deltaMethod(model, deltaMethod_settings)
Running Delta method computation for user-defined function using robust standard errors
Expression Value s.e. t-ratio (0)
wtp_small_vs_medium 43.1518 15.9691 2.7
INFORMATION: The results of the Delta method calculations are returned invisibly as an output from this function. Calling the function via
result=apollo_deltaMethod(...) will save this output in an object called result (or otherwise named object).
>
> deltaMethod_settings=list(expression=c(wtp_large_vs_medium="coeff_large/coeff_cost"))
> apollo_deltaMethod(model, deltaMethod_settings)
Running Delta method computation for user-defined function using robust standard errors
Expression Value s.e. t-ratio (0)
wtp_large_vs_medium 50.1114 15.5464 3.22
INFORMATION: The results of the Delta method calculations are returned invisibly as an output from this function. Calling the function via
result=apollo_deltaMethod(...) will save this output in an object called result (or otherwise named object).
>
> deltaMethod_settings=list(expression=c(wtp_func2_vs_func1="coeff_func2/coeff_cost"))
> apollo_deltaMethod(model, deltaMethod_settings)
Running Delta method computation for user-defined function using robust standard errors
Expression Value s.e. t-ratio (0)
wtp_func2_vs_func1 -146.4514 27.1215 -5.4
INFORMATION: The results of the Delta method calculations are returned invisibly as an output from this function. Calling the function via
result=apollo_deltaMethod(...) will save this output in an object called result (or otherwise named object).
>
> deltaMethod_settings=list(expression=c(wtp_func3_vs_func1="coeff_func3/coeff_cost"))
> apollo_deltaMethod(model, deltaMethod_settings)
Running Delta method computation for user-defined function using robust standard errors
Expression Value s.e. t-ratio (0)
wtp_func3_vs_func1 -81.027 20.3672 -3.98
INFORMATION: The results of the Delta method calculations are returned invisibly as an output from this function. Calling the function via
result=apollo_deltaMethod(...) will save this output in an object called result (or otherwise named object).
>
> deltaMethod_settings=list(expression=c(wtp_func4_vs_func1="coeff_func4/coeff_cost"))
> apollo_deltaMethod(model, deltaMethod_settings)
Running Delta method computation for user-defined function using robust standard errors
Expression Value s.e. t-ratio (0)
wtp_func4_vs_func1 -15.0041 19.8736 -0.75
INFORMATION: The results of the Delta method calculations are returned invisibly as an output from this function. Calling the function via
result=apollo_deltaMethod(...) will save this output in an object called result (or otherwise named object).
>
> deltaMethod_settings=list(expression=c(wtp_surv="coeff_surv/coeff_cost"))
> apollo_deltaMethod(model, deltaMethod_settings)
Running Delta method computation for user-defined function using robust standard errors
Expression Value s.e. t-ratio (0)
wtp_surv -46.6821 12.0378 -3.88
INFORMATION: The results of the Delta method calculations are returned invisibly as an output from this function. Calling the function via
result=apollo_deltaMethod(...) will save this output in an object called result (or otherwise named object).
>
> deltaMethod_settings=list(expression=c(wtp_help="coeff_help/coeff_cost"))
> apollo_deltaMethod(model, deltaMethod_settings)
Running Delta method computation for user-defined function using robust standard errors
Expression Value s.e. t-ratio (0)
wtp_help -48.9443 11.5418 -4.24
INFORMATION: The results of the Delta method calculations are returned invisibly as an output from this function. Calling the function via
result=apollo_deltaMethod(...) will save this output in an object called result (or otherwise named object).
**********************************************LC 2 classes no covariates code*****************************************************************
# ################################################################# #
#### LOAD LIBRARY AND DEFINE CORE SETTINGS ####
# ################################################################# #
### Clear memory
rm(list = ls())
### Load Apollo library
library(apollo)
### Initialise code
apollo_initialise()
### Set core controls
apollo_control = list(
modelName = "LC_robot_hu_2_classes",
modelDescr = "LC model on HU robot data, no covariates in class allocation model",
indivID = "id",
nCores = 2,
outputDirectory = "output"
)
# ################################################################# #
#### LOAD DATA AND APPLY ANY TRANSFORMATIONS ####
# ################################################################# #
### Loading data from package
### if data is to be loaded from a file (e.g. called data.csv),
### the code would be: database = read.csv("data.csv",header=TRUE)
database=read.csv("robot_choices_data_hu.csv",header=TRUE)
### for data dictionary, use ?apollo_swissRouteChoiceData
# ################################################################# #
#### DEFINE MODEL PARAMETERS ####
# ################################################################# #
### Vector of parameters, including any that are kept fixed in estimation
apollo_beta = c( asc1=0,
asc2=0,
coeff_robot = 0,
coeff_human_a = -0.2,
coeff_human_b = 2.4,
coeff_animal_a = -0.3,
coeff_animal_b = -1.3,
coeff_small_a = -0.2,
coeff_small_b = -4,
coeff_medium = 0,
coeff_large_a = -0.050,
coeff_large_b = -2.8,
coeff_func1 = 0,
coeff_func2_a = 0.3,
coeff_func2_b = 3,
coeff_func3_a = 0.06,
coeff_func3_b = 4,
coeff_func4_a = -0.02,
coeff_func4_b = 1.28,
coeff_surv_a = -0.01,
coeff_surv_b = 0.28,
coeff_help_a = 0.04,
coeff_help_b = -0.9,
coeff_cost_a = -0.002,
coeff_cost_b = -0.02,
delta_a = 0,
delta_b = 0)
### Vector with names (in quotes) of parameters to be kept fixed at their starting value in apollo_beta, use apollo_beta_fixed = c() if none
apollo_fixed = c("delta_b", "coeff_medium", "coeff_robot", "coeff_func1", "asc2")
# ################################################################# #
#### DEFINE LATENT CLASS COMPONENTS ####
# ################################################################# #
apollo_lcPars=function(apollo_beta, apollo_inputs){
lcpars = list()
lcpars[["coeff_human"]] = list(coeff_human_a, coeff_human_b)
lcpars[["coeff_animal"]] = list(coeff_animal_a, coeff_animal_b)
lcpars[["coeff_small"]] = list(coeff_small_a, coeff_small_b)
lcpars[["coeff_large"]] = list(coeff_large_a, coeff_large_b)
lcpars[["coeff_func2"]] = list(coeff_func2_a, coeff_func2_b)
lcpars[["coeff_func3"]] = list(coeff_func3_a, coeff_func3_b)
lcpars[["coeff_func4"]] = list(coeff_func4_a, coeff_func4_b)
lcpars[["coeff_surv"]] = list(coeff_surv_a, coeff_surv_b)
lcpars[["coeff_help"]] = list(coeff_help_a, coeff_help_b)
lcpars[["coeff_cost"]] = list(coeff_cost_a, coeff_cost_b)
V=list()
V[["class_a"]] = delta_a
V[["class_b"]] = delta_b
classAlloc_settings = list(
classes = c(class_a=1, class_b=2),
utilities = V
)
lcpars[["pi_values"]] = apollo_classAlloc(classAlloc_settings)
return(lcpars)
}
# ################################################################# #
#### GROUP AND VALIDATE INPUTS ####
# ################################################################# #
apollo_inputs = apollo_validateInputs()
# ################################################################# #
#### DEFINE MODEL AND LIKELIHOOD FUNCTION ####
# ################################################################# #
apollo_probabilities=function(apollo_beta, apollo_inputs, functionality="estimate"){
### Attach inputs and detach after function exit
apollo_attach(apollo_beta, apollo_inputs)
on.exit(apollo_detach(apollo_beta, apollo_inputs))
### Create list of probabilities P
P = list()
### Define settings for MNL model component that are generic across classes
mnl_settings = list(
alternatives = c(alt1=1, alt2=2),
avail = list(alt1=1, alt2=1),
choiceVar = choice_
)
### Loop over classes
for(s in 1:2){
### Compute class-specific utilities
V=list()
V[["alt1"]] = asc1+ (coeff_robot*(a_type==0) + coeff_human[[s]]*(a_type==1)+ coeff_animal[[s]]*(a_type==2)
+ coeff_small[[s]]*(a_size==0) + coeff_medium*(a_size==1) + coeff_large[[s]]*(a_size==2)
+ coeff_func1*(a_function==0) + coeff_func2[[s]]*(a_function==1) + coeff_func3[[s]]*(a_function==2) + coeff_func4[[s]]*(a_function==3)
+ coeff_help[[s]]*a_help
+ coeff_surv[[s]]*a_surv
+ coeff_cost[[s]]*a_cost)
V[["alt2"]] = asc2+ ( coeff_robot*(b_type==0) + coeff_human[[s]]*(b_type==1)+ coeff_animal[[s]]*(b_type==2)
+ coeff_small[[s]]*(b_size==0) + coeff_medium*(b_size==1) + coeff_large[[s]]*(b_size==2)
+ coeff_func1*(b_function==0) + coeff_func2[[s]]*(b_function==1) + coeff_func3[[s]]*(b_function==2) + coeff_func4[[s]]*(b_function==3)
+ coeff_help[[s]]*b_help
+ coeff_surv[[s]]*b_surv
+ coeff_cost[[s]]*b_cost )
mnl_settings$utilities = V
#mnl_settings$componentName = paste0("Class_",s)
### Compute within-class choice probabilities using MNL model
P[[paste0("Class_",s)]] = apollo_mnl(mnl_settings, functionality)
### Take product across observation for same individual
P[[paste0("Class_",s)]] = apollo_panelProd(P[[paste0("Class_",s)]], apollo_inputs ,functionality)
}
### Compute latent class model probabilities
lc_settings = list(inClassProb = P, classProb=pi_values)
P[["model"]] = apollo_lc(lc_settings, apollo_inputs, functionality)
### Prepare and return outputs of function
P = apollo_prepareProb(P, apollo_inputs, functionality)
return(P)
}
# ################################################################# #
#### MODEL ESTIMATION ####
# ################################################################# #
model = apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, apollo_inputs)
# ################################################################# #
#### MODEL OUTPUTS ####
# ################################################################# #
# ----------------------------------------------------------------- #
#---- FORMATTED OUTPUT (TO SCREEN) ----
# ----------------------------------------------------------------- #
apollo_modelOutput(model)
****************************************************Results LC HU**********************************************
> # ################################################################# #
> #### MODEL ESTIMATION ####
> # ################################################################# #
>
>
> model = apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, apollo_inputs)
Preparing user-defined functions.
Testing likelihood function...
Apollo found a model component of type classAlloc without a componentName. The name was set to "classAlloc" by default.
INFORMATION: Setting "avail" is missing, so full availability is assumed.
Apollo found a model component of type MNL without a componentName. The name was set to "Class_1" by default.
Overview of choices for MNL model component Class_1:
alt1 alt2
Times available 4000.00 4000.00
Times chosen 2117.00 1883.00
Percentage chosen overall 52.92 47.08
Percentage chosen when available 52.92 47.08
Apollo found a model component of type MNL without a componentName. The name was set to "Class_2" by default.
Overview of choices for MNL model component Class_2:
alt1 alt2
Times available 4000.00 4000.00
Times chosen 2117.00 1883.00
Percentage chosen overall 52.92 47.08
Percentage chosen when available 52.92 47.08
Summary of class allocation for model component :
Mean prob.
Class_1 0.5000
Class_2 0.5000
Pre-processing likelihood function...
Creating cluster...
Preparing workers for multithreading...
Testing influence of parameters
Starting main estimation
BGW using analytic model derivatives supplied by caller...
Iterates will be written to:
output/LC_robot_hu_2_classes_iterations.csv
it nf F RELDF PRELDF RELDX MODEL stppar
0 1 2.825338658e+03
1 4 2.644627362e+03 6.396e-02 6.120e-02 2.60e-01 G 2.06e-01
2 5 2.594446967e+03 1.897e-02 3.212e-02 2.02e-01 G 2.06e-01
3 6 2.583512899e+03 4.214e-03 7.027e-03 1.23e-01 S 0.00e+00
4 7 2.571795672e+03 4.535e-03 6.724e-03 1.07e-01 S 0.00e+00
5 8 2.543792912e+03 1.089e-02 7.841e-03 2.21e-01 G 2.22e-03
6 9 2.537385427e+03 2.519e-03 7.203e-03 3.66e-01 G 0.00e+00
7 10 2.514140709e+03 9.161e-03 7.614e-03 1.04e-01 S 0.00e+00
8 11 2.506422177e+03 3.070e-03 2.552e-03 5.77e-02 G 0.00e+00
9 12 2.505463641e+03 3.824e-04 3.499e-04 2.58e-02 G 0.00e+00
10 13 2.505007443e+03 1.821e-04 1.881e-04 3.03e-02 G 0.00e+00
11 14 2.504629882e+03 1.507e-04 1.632e-04 2.34e-02 G 0.00e+00
12 15 2.504299890e+03 1.318e-04 1.556e-04 3.54e-02 G 0.00e+00
13 16 2.504106828e+03 7.709e-05 1.355e-04 1.85e-02 G 0.00e+00
14 17 2.504028884e+03 3.113e-05 1.273e-04 3.38e-02 G 0.00e+00
15 19 2.503861653e+03 6.678e-05 5.627e-05 8.70e-03 G-S 0.00e+00
16 20 2.503839916e+03 8.681e-06 6.654e-06 4.45e-03 S 0.00e+00
17 21 2.503833814e+03 2.437e-06 2.256e-06 4.08e-03 S 0.00e+00
18 22 2.503832764e+03 4.193e-07 3.925e-07 1.48e-03 S 0.00e+00
19 23 2.503832533e+03 9.215e-08 7.198e-08 2.37e-04 S 0.00e+00
20 24 2.503832505e+03 1.107e-08 9.828e-09 1.31e-04 G 0.00e+00
21 25 2.503832496e+03 3.818e-09 3.553e-09 7.84e-05 S 0.00e+00
22 26 2.503832494e+03 7.320e-10 7.200e-10 4.46e-05 S 0.00e+00
23 27 2.503832494e+03 1.022e-10 8.021e-11 1.15e-05 S 0.00e+00
***** Relative function convergence *****
Estimated parameters with approximate standard errors from BHHH matrix:
Estimate BHHH se BHH t-ratio (0)
asc1 0.135606 0.033401 4.05994
asc2 0.000000 NA NA
coeff_robot 0.000000 NA NA
coeff_human_a -0.125956 0.053869 -2.33820
coeff_human_b 0.277653 0.206570 1.34411
coeff_animal_a -0.389154 0.050754 -7.66740
coeff_animal_b -0.200773 0.151953 -1.32129
coeff_small_a -0.094980 0.056958 -1.66754
coeff_small_b -1.464487 0.256626 -5.70671
coeff_medium 0.000000 NA NA
coeff_large_a -0.046644 0.063193 -0.73811
coeff_large_b -0.763375 0.242989 -3.14160
coeff_func1 0.000000 NA NA
coeff_func2_a 0.348399 0.058918 5.91327
coeff_func2_b 0.568496 0.233541 2.43424
coeff_func3_a 0.085156 0.077261 1.10219
coeff_func3_b 1.298741 0.211695 6.13497
coeff_func4_a -0.082678 0.071542 -1.15567
coeff_func4_b 0.357310 0.267597 1.33525
coeff_surv_a 0.001239 0.038154 0.03247
coeff_surv_b 0.751819 0.167835 4.47952
coeff_help_a 0.071064 0.039192 1.81324
coeff_help_b 0.840713 0.193670 4.34096
coeff_cost_a 1.3075e-04 3.8917e-04 0.33596
coeff_cost_b -0.023436 0.002633 -8.90012
delta_a 0.987221 0.150119 6.57626
delta_b 0.000000 NA NA
Final LL: -2503.8325
Summary of class allocation for model component :
Mean prob.
Class_1 0.7285
Class_2 0.2715
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 numerical jacobian of analytical gradient.
0%....25%....50%....75%....100%
Negative definite Hessian with maximum eigenvalue: -4.118414
Computing score matrix...
Your model was estimated using the BGW algorithm. Please acknowledge this by citing Bunch et al. (1993) - DOI 10.1145/151271.151279
>
> # ################################################################# #
> #### MODEL OUTPUTS ####
> # ################################################################# #
>
> # ----------------------------------------------------------------- #
> #---- FORMATTED OUTPUT (TO SCREEN) ----
> # ----------------------------------------------------------------- #
>
> apollo_modelOutput(model)
Model run by cf21091 using Apollo 0.3.4 on R 4.3.0 for Windows.
Please acknowledge the use of Apollo by citing Hess & Palma (2019)
DOI 10.1016/j.jocm.2019.100170
www.ApolloChoiceModelling.com
Model name : LC_robot_hu_2_classes
Model description : LC model on HU robot data, no covariates in class allocation model
Model run at : 2025-09-05 11:56:38.111658
Estimation method : bgw
Model diagnosis : Relative function convergence
Optimisation diagnosis : Maximum found
hessian properties : Negative definite
maximum eigenvalue : -4.118414
reciprocal of condition number : 5.72976e-07
Number of individuals : 400
Number of rows in database : 4000
Number of modelled outcomes : 4000
Number of cores used : 2
Model without mixing
LL(start) : -2825.34
LL (whole model) at equal shares, LL(0) : -2772.59
LL (whole model) at observed shares, LL(C) : -2765.74
LL(final, whole model) : -2503.83
Rho-squared vs equal shares : 0.0969
Adj.Rho-squared vs equal shares : 0.089
Rho-squared vs observed shares : 0.0947
Adj.Rho-squared vs observed shares : 0.0875
AIC : 5051.66
BIC : 5190.13
LL(0,Class_1) : -2772.59
LL(final,Class_1) : -2685.86
LL(0,Class_2) : -2772.59
LL(final,Class_2) : -4600.83
Estimated parameters : 22
Time taken (hh:mm:ss) : 00:00:15.26
pre-estimation : 00:00:7.08
estimation : 00:00:1.13
post-estimation : 00:00:7.05
Iterations : 23
Unconstrained optimisation.
Estimates:
Estimate s.e. t.rat.(0) Rob.s.e. Rob.t.rat.(0)
asc1 0.135606 0.037182 3.64710 0.043828 3.09405
asc2 0.000000 NA NA NA NA
coeff_robot 0.000000 NA NA NA NA
coeff_human_a -0.125956 0.055935 -2.25183 0.065084 -1.93528
coeff_human_b 0.277653 0.204444 1.35809 0.258640 1.07351
coeff_animal_a -0.389154 0.059797 -6.50791 0.078144 -4.97996
coeff_animal_b -0.200773 0.170941 -1.17452 0.209671 -0.95756
coeff_small_a -0.094980 0.056775 -1.67291 0.061850 -1.53565
coeff_small_b -1.464487 0.293471 -4.99023 0.375489 -3.90022
coeff_medium 0.000000 NA NA NA NA
coeff_large_a -0.046644 0.059510 -0.78380 0.061146 -0.76283
coeff_large_b -0.763375 0.256639 -2.97451 0.324310 -2.35384
coeff_func1 0.000000 NA NA NA NA
coeff_func2_a 0.348399 0.069271 5.02953 0.083668 4.16408
coeff_func2_b 0.568496 0.219258 2.59282 0.275088 2.06660
coeff_func3_a 0.085156 0.071443 1.19194 0.075262 1.13146
coeff_func3_b 1.298741 0.273809 4.74324 0.402104 3.22986
coeff_func4_a -0.082678 0.071100 -1.16285 0.080438 -1.02785
coeff_func4_b 0.357310 0.323953 1.10297 0.472347 0.75646
coeff_surv_a 0.001239 0.042517 0.02913 0.052277 0.02370
coeff_surv_b 0.751819 0.156762 4.79591 0.156515 4.80349
coeff_help_a 0.071064 0.041127 1.72794 0.047137 1.50762
coeff_help_b 0.840713 0.151596 5.54575 0.137283 6.12394
coeff_cost_a 1.3075e-04 4.3610e-04 0.29980 5.8426e-04 0.22378
coeff_cost_b -0.023436 0.002779 -8.43196 0.003652 -6.41748
delta_a 0.987221 0.163042 6.05500 0.198568 4.97171
delta_b 0.000000 NA NA NA NA
Summary of class allocation for model component :
Mean prob.
Class_1 0.7285
Class_2 0.2715
> unconditionals=apollo_lcUnconditionals(model,apollo_probabilities,apollo_inputs)
Unconditional distributions computed
> classes=length(unconditionals[["pi_values"]])
> vhw_in_class=mapply("/",unconditionals[["coeff_human"]],unconditionals[["coeff_cost"]], SIMPLIFY=FALSE )
> -vhw_in_class[[1]]
[1] 963.3708
> -vhw_in_class[[2]]
[1] 11.84738
> vhw_unconditional=sum(mapply("*",vhw_in_class,unconditionals[["pi_values"]],SIMPLIFY=TRUE))
> -vhw_unconditional
[1] 705.0689
>
> unconditionals=apollo_lcUnconditionals(model,apollo_probabilities,apollo_inputs)
Unconditional distributions computed
> classes=length(unconditionals[["pi_values"]])
> vhw_in_class=mapply("/",unconditionals[["coeff_animal"]],unconditionals[["coeff_cost"]], SIMPLIFY=FALSE )
> -vhw_in_class[[1]]
[1] 2976.427
> -vhw_in_class[[2]]
[1] -8.566909
> vhw_unconditional=sum(mapply("*",vhw_in_class,unconditionals[["pi_values"]],SIMPLIFY=TRUE))
> -vhw_unconditional
[1] 2166.117
>
> unconditionals=apollo_lcUnconditionals(model,apollo_probabilities,apollo_inputs)
Unconditional distributions computed
> classes=length(unconditionals[["pi_values"]])
> vhw_in_class=mapply("/",unconditionals[["coeff_small"]],unconditionals[["coeff_cost"]], SIMPLIFY=FALSE )
> -vhw_in_class[[1]]
[1] 726.4489
> -vhw_in_class[[2]]
[1] -62.48922
> vhw_unconditional=sum(mapply("*",vhw_in_class,unconditionals[["pi_values"]],SIMPLIFY=TRUE))
> -vhw_unconditional
[1] 512.2827
>
> unconditionals=apollo_lcUnconditionals(model,apollo_probabilities,apollo_inputs)
Unconditional distributions computed
> classes=length(unconditionals[["pi_values"]])
> vhw_in_class=mapply("/",unconditionals[["coeff_large"]],unconditionals[["coeff_cost"]], SIMPLIFY=FALSE )
> -vhw_in_class[[1]]
[1] 356.7539
> -vhw_in_class[[2]]
[1] -32.57299
> vhw_unconditional=sum(mapply("*",vhw_in_class,unconditionals[["pi_values"]],SIMPLIFY=TRUE))
> -vhw_unconditional
[1] 251.0666
>
> unconditionals=apollo_lcUnconditionals(model,apollo_probabilities,apollo_inputs)
Unconditional distributions computed
> classes=length(unconditionals[["pi_values"]])
> vhw_in_class=mapply("/",unconditionals[["coeff_func2"]],unconditionals[["coeff_cost"]], SIMPLIFY=FALSE )
> -vhw_in_class[[1]]
[1] -2664.715
> -vhw_in_class[[2]]
[1] 24.25757
> vhw_unconditional=sum(mapply("*",vhw_in_class,unconditionals[["pi_values"]],SIMPLIFY=TRUE))
> -vhw_unconditional
[1] -1934.763
>
> unconditionals=apollo_lcUnconditionals(model,apollo_probabilities,apollo_inputs)
Unconditional distributions computed
> classes=length(unconditionals[["pi_values"]])
> vhw_in_class=mapply("/",unconditionals[["coeff_func3"]],unconditionals[["coeff_cost"]], SIMPLIFY=FALSE )
> -vhw_in_class[[1]]
[1] -651.3141
> -vhw_in_class[[2]]
[1] 55.41686
> vhw_unconditional=sum(mapply("*",vhw_in_class,unconditionals[["pi_values"]],SIMPLIFY=TRUE))
> -vhw_unconditional
[1] -459.4639
>
> unconditionals=apollo_lcUnconditionals(model,apollo_probabilities,apollo_inputs)
Unconditional distributions computed
> classes=length(unconditionals[["pi_values"]])
> vhw_in_class=mapply("/",unconditionals[["coeff_func4"]],unconditionals[["coeff_cost"]], SIMPLIFY=FALSE )
> -vhw_in_class[[1]]
[1] 632.3635
> -vhw_in_class[[2]]
[1] 15.24631
> vhw_unconditional=sum(mapply("*",vhw_in_class,unconditionals[["pi_values"]],SIMPLIFY=TRUE))
> -vhw_unconditional
[1] 464.84
>
>
> unconditionals=apollo_lcUnconditionals(model,apollo_probabilities,apollo_inputs)
Unconditional distributions computed
> classes=length(unconditionals[["pi_values"]])
> vhw_in_class=mapply("/",unconditionals[["coeff_help"]],unconditionals[["coeff_cost"]], SIMPLIFY=FALSE )
> -vhw_in_class[[1]]
[1] -543.5327
> -vhw_in_class[[2]]
[1] 35.87295
> vhw_unconditional=sum(mapply("*",vhw_in_class,unconditionals[["pi_values"]],SIMPLIFY=TRUE))
> -vhw_unconditional
[1] -386.2464
>
> unconditionals=apollo_lcUnconditionals(model,apollo_probabilities,apollo_inputs)
Unconditional distributions computed
> classes=length(unconditionals[["pi_values"]])
> vhw_in_class=mapply("/",unconditionals[["coeff_surv"]],unconditionals[["coeff_cost"]], SIMPLIFY=FALSE )
> -vhw_in_class[[1]]
[1] -9.474284
> -vhw_in_class[[2]]
[1] 32.07989
> vhw_unconditional=sum(mapply("*",vhw_in_class,unconditionals[["pi_values"]],SIMPLIFY=TRUE))
> -vhw_unconditional
[1] 1.806072
Important: Read this before posting to this forum
- This forum is for questions related to the use of Apollo. We will answer some general choice modelling questions too, where appropriate, and time permitting. We cannot answer questions about how to estimate choice models with other software packages.
- There is a very detailed manual for Apollo available at http://www.ApolloChoiceModelling.com/manual.html. This contains detailed descriptions of the various Apollo functions, and numerous examples are available at http://www.ApolloChoiceModelling.com/examples.html. In addition, help files are available for all functions, using e.g. ?apollo_mnl
- Before asking a question on the forum, users are kindly requested to follow these steps:
- Check that the same issue has not already been addressed in the forum - there is a search tool.
- Ensure that the correct syntax has been used. For any function, detailed instructions are available directly in Apollo, e.g. by using ?apollo_mnl for apollo_mnl
- Check the frequently asked questions section on the Apollo website, which discusses some common issues/failures. Please see http://www.apollochoicemodelling.com/faq.html
- Make sure that R is using the latest official release of Apollo.
- Users can check which version they are running by entering packageVersion("apollo").
- Then check what is the latest full release (not development version) at http://www.ApolloChoiceModelling.com/code.html.
- To update to the latest official version, just enter install.packages("apollo"). To update to a development version, download the appropriate binary file from http://www.ApolloChoiceModelling.com/code.html, and install the package from file
- If the above steps do not resolve the issue, then users should follow these steps when posting a question:
- provide full details on the issue, including the entire code and output, including any error messages
- posts will not immediately appear on the forum, but will be checked by a moderator first. We check the forum at least twice a week. It may thus take a couple of days for your post to appear and before we reply. There is no need to submit the post multiple times.
LC - positive (close to zero) cost coefficient in one class
-
- Site Admin
- Posts: 1320
- Joined: 24 Apr 2020, 16:29
Re: LC - positive (close to zero) cost coefficient in one class
Hi
have you tried a range of different starting values? How does the fit compare to MNL?
Stephane
have you tried a range of different starting values? How does the fit compare to MNL?
Stephane
Re: LC - positive (close to zero) cost coefficient in one class
Hi Stephan,
Yes, I have. With 0 initial values, it gives slightly different coefficients, but not too far from where I applied some random values (informed by MNL). When I used another set of different initial values, it still converged to the same model I copied in before.
Here are the model fits. I assume that even if model fit improved, its not a huge improvement given estimating twice as much coefficients.
MNL
LL(final) : -2611.28
AIC : 5244.57
BIC : 5313.8
Estimated parameters : 11
Starting values: random selection
LL(final, whole model) : -2503.83
AIC : 5051.66
BIC : 5190.13
Estimated parameters : 11
Estimated parameters: 21
Starting values are 0
LL(final, whole model) : -2510.49
AIC : 5062.99
BIC : 5195.16
Estimated parameters : 21
Thank you for considering this.
Best wishes,
Petra
Yes, I have. With 0 initial values, it gives slightly different coefficients, but not too far from where I applied some random values (informed by MNL). When I used another set of different initial values, it still converged to the same model I copied in before.
Here are the model fits. I assume that even if model fit improved, its not a huge improvement given estimating twice as much coefficients.
MNL
LL(final) : -2611.28
AIC : 5244.57
BIC : 5313.8
Estimated parameters : 11
Starting values: random selection
LL(final, whole model) : -2503.83
AIC : 5051.66
BIC : 5190.13
Estimated parameters : 11
Estimated parameters: 21
Starting values are 0
LL(final, whole model) : -2510.49
AIC : 5062.99
BIC : 5195.16
Estimated parameters : 21
Thank you for considering this.
Best wishes,
Petra
-
- Site Admin
- Posts: 1320
- Joined: 24 Apr 2020, 16:29
Re: LC - positive (close to zero) cost coefficient in one class
the difference is large enough for the LC to reject the MNL model
Re: LC - positive (close to zero) cost coefficient in one class
Thank you Stephan for looking into this, much appreciated. If LC has a better fit as you write, I'm now a bit uncertain how to interpret the conflicting results, or explain what is causing the large difference in WTP estimates, and which WTP estimates I should trust more. Would be grateful for any thoughts.
Many thanks,
Petra
Many thanks,
Petra
-
- Site Admin
- Posts: 1320
- Joined: 24 Apr 2020, 16:29
Re: LC - positive (close to zero) cost coefficient in one class
It's not uncommon for WTP to be very different across models, but in your case, the wrong sign for the cost coefficient of course cannot be accepted. What you could do is to restrict the cost coefficient to be shared between those classes where it is similar