Important: Read this before posting to this forum

  1. 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.
  2. 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
  3. Before asking a question on the forum, users are kindly requested to follow these steps:
    1. Check that the same issue has not already been addressed in the forum - there is a search tool.
    2. 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
    3. Check the frequently asked questions section on the Apollo website, which discusses some common issues/failures. Please see http://www.apollochoicemodelling.com/faq.html
    4. Make sure that R is using the latest official release of Apollo.
  4. If the above steps do not resolve the issue, then users should follow these steps when posting a question:
    1. provide full details on the issue, including the entire code and output, including any error messages
    2. posts will not immediately appear on the forum, but will be checked by a moderator first. This may take a day or two at busy times. There is no need to submit the post multiple times.

ASC in WTP space or preference based space

Ask questions about model specifications. Ideally include a mathematical explanation of your proposed model.
Post Reply
chlob
Posts: 2
Joined: 16 Dec 2022, 11:26

ASC in WTP space or preference based space

Post by chlob »

Dear Stephane and David,

I have data from a choice experiment with 3 alternatives in each choice set, the third being the status quo.

I am running a mixed logit in WTP space. I have tried to run two models : (i) one with the ASC parameter estimated in WTP space (model 1), and (ii) the other with the ASC parameter estimated in preference-based space (model 2).

The list of utilities in model 1 is :
######################################################################################
V = list()
V[["alt1"]] = b_taxe * (taxe_alternative_1 + b_extinction0 * (extinction_alternative_1 == 0) +
b_extinction1 * (extinction_alternative_1 == 1) + b_extinction2 * (extinction_alternative_1 == 2) +
b_couleur0 *(couleur_alternative_1 == 0) + b_couleur1 *(couleur_alternative_1 == 1) +
b_intensite * intensite_alternative_1 )

V[["alt2"]] = b_taxe * (taxe_alternative_2 + b_extinction0 * (extinction_alternative_2 == 0) +
b_extinction1 * (extinction_alternative_2 == 1) + b_extinction2 * (extinction_alternative_2 == 2) +
b_couleur0 *(couleur_alternative_2 == 0) + b_couleur1 *(couleur_alternative_2 == 1) +
b_intensite * intensite_alternative_2 )

V[["alt3"]] =b_taxe * ( asc_3 + taxe_alternative_3 + b_extinction0 * (extinction_alternative_3 == 0) +
b_extinction1 * (extinction_alternative_3 == 1) + b_extinction2 * (extinction_alternative_3 == 2) +
b_couleur0 *(couleur_alternative_3 == 0) + b_couleur1 *(couleur_alternative_3 == 1) +
b_intensite * intensite_alternative_3 )
########################################################################################

The list of utilities in model 2 is :
######################################################################################
V = list()
V[["alt1"]] = b_taxe * (taxe_alternative_1 + b_extinction0 * (extinction_alternative_1 == 0) +
b_extinction1 * (extinction_alternative_1 == 1) + b_extinction2 * (extinction_alternative_1 == 2) +
b_couleur0 *(couleur_alternative_1 == 0) + b_couleur1 *(couleur_alternative_1 == 1) +
b_intensite * intensite_alternative_1 )

V[["alt2"]] = b_taxe * (taxe_alternative_2 + b_extinction0 * (extinction_alternative_2 == 0) +
b_extinction1 * (extinction_alternative_2 == 1) + b_extinction2 * (extinction_alternative_2 == 2) +
b_couleur0 *(couleur_alternative_2 == 0) + b_couleur1 *(couleur_alternative_2 == 1) +
b_intensite * intensite_alternative_2 )

V[["alt3"]] = asc_3 + b_taxe * ( taxe_alternative_3 + b_extinction0 * (extinction_alternative_3 == 0) +
b_extinction1 * (extinction_alternative_3 == 1) + b_extinction2 * (extinction_alternative_3 == 2) +
b_couleur0 *(couleur_alternative_3 == 0) + b_couleur1 *(couleur_alternative_3 == 1) +
b_intensite * intensite_alternative_3 )
########################################################################################

I find very different coefficients for three of the parameters (b_extinction1, b_extinction2 and b_couleur1). They are much lower in the second model, and b_couleur1's sign changes, which leads to very different interpretation of the results in term of willingness to pay for a change in these attributes.

Results in model 1
########################################################################################
Estimate s.e.
asc_3 28.80981 1.069300
b_extinction0 0.00000 NA
mu_log_b_extinction1 -6.34243 1.006076
sigma_log_b_extinction1 1.99290 0.153827
mu_log_b_extinction2 -3.13658 0.803015
sigma_log_b_extinction2 -15.98749 0.814401
mu_log_b_taxe -2.19824 0.099250
sigma_log_b_taxe -2.32408 0.123056
b_couleur0 0.00000 NA
mu_log_b_couleur1 1.38682 0.584745
sigma_log_b_couleur1 9.76106 0.500763
mu_log_b_intensite -0.09755 0.005926
sigma_log_b_intensite 0.15961 0.007274
##########################################################################################

Result in model 2

##########################################################################################
Estimate s.e.
asc_3 -0.5774 0.13483
b_extinction0 0.0000 NA
mu_log_b_extinction1 -23.4695 3.80097
sigma_log_b_extinction1 49.3734 3.14467
mu_log_b_extinction2 -15.6152 2.76656
sigma_log_b_extinction2 -71.8881 4.78631
mu_log_b_taxe -2.7443 0.06511
sigma_log_b_taxe -0.7647 0.06211
b_couleur0 0.0000 NA
mu_log_b_couleur1 -15.5147 2.21077
sigma_log_b_couleur1 29.8669 2.01442
mu_log_b_intensite -0.2406 0.02580
sigma_log_b_intensite -0.4885 0.03036
#########################################################################################

I have two questions about these results :
1. Why are these coefficients so different ?
2. Which of these two models should I prefer ?

Thanks a lot,
Chloé

Complete script (model 1)
############################################################################################

# ################################################################# #
#### DEFINE MODEL PARAMETERS ####
# ################################################################# #

### Vector of parameters, including any that are kept fixed in estimation
apollo_beta = c(asc_3 = 0,
b_extinction0 = 0,
mu_log_b_extinction1 = 1,
sigma_log_b_extinction1 = 2,
mu_log_b_extinction2 = 0,
sigma_log_b_extinction2 = -3,
mu_log_b_taxe = -2,
sigma_log_b_taxe = -1,
b_couleur0 = 0,
mu_log_b_couleur1 = 0,
sigma_log_b_couleur1 = 1,
mu_log_b_intensite = 0,
sigma_log_b_intensite = 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("b_extinction0", "b_couleur0")

# ################################################################# #
#### DEFINE RANDOM COMPONENTS ####
# ################################################################# #

### Set parameters for generating draws
apollo_draws = list(
interDrawsType = "halton",
interNDraws = 500,
interUnifDraws = c(),
interNormDraws = c("draws_extinction1","draws_extinction2","draws_couleur1", "draws_intensite", "draws_taxe"),
intraDrawsType = "halton",
intraNDraws = 0,
intraUnifDraws = c(),
intraNormDraws = c()
)

### Create random parameters
apollo_randCoeff = function(apollo_beta, apollo_inputs){
randcoeff = list()

randcoeff[["b_taxe"]] = -exp( mu_log_b_taxe + sigma_log_b_taxe * draws_taxe )
randcoeff[["b_extinction1"]] = mu_log_b_extinction1 + sigma_log_b_extinction1 * draws_extinction1
randcoeff[["b_extinction2"]] = mu_log_b_extinction2 + sigma_log_b_extinction2 * draws_extinction2
randcoeff[["b_couleur1"]] = mu_log_b_couleur1 + sigma_log_b_couleur1 * draws_couleur1
randcoeff[["b_intensite"]] = mu_log_b_intensite + sigma_log_b_intensite * draws_intensite

return(randcoeff)
}

# ################################################################# #
#### GROUP AND VALIDATE INPUTS ####
# ################################################################# #

apollo_inputs = apollo_validateInputs()

# ################################################################# #
#### DEFINE MODEL AND LIKELIHOOD FUNCTION ####
# ################################################################# #

apollo_probabilities=function(apollo_beta, apollo_inputs, functionality="estimate"){

### Function initialisation: do not change the following three commands
### 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()

### List of utilities: these must use the same names as in mnl_settings, order is irrelevant
V = list()
V[["alt1"]] = b_taxe * (taxe_alternative_1 + b_extinction0 * (extinction_alternative_1 == 0) +
b_extinction1 * (extinction_alternative_1 == 1) + b_extinction2 * (extinction_alternative_1 == 2) +
b_couleur0 *(couleur_alternative_1 == 0) + b_couleur1 *(couleur_alternative_1 == 1) +
b_intensite * intensite_alternative_1 )

V[["alt2"]] = b_taxe * (taxe_alternative_2 + b_extinction0 * (extinction_alternative_2 == 0) +
b_extinction1 * (extinction_alternative_2 == 1) + b_extinction2 * (extinction_alternative_2 == 2) +
b_couleur0 *(couleur_alternative_2 == 0) + b_couleur1 *(couleur_alternative_2 == 1) +
b_intensite * intensite_alternative_2 )

V[["alt3"]] = b_taxe * ( asc_3 + taxe_alternative_3 + b_extinction0 * (extinction_alternative_3 == 0) +
b_extinction1 * (extinction_alternative_3 == 1) + b_extinction2 * (extinction_alternative_3 == 2) +
b_couleur0 *(couleur_alternative_3 == 0) + b_couleur1 *(couleur_alternative_3 == 1) +
b_intensite * intensite_alternative_3 )

### Define settings for MNL model component
mnl_settings = list(
alternatives = c(alt1=1, alt2=2, alt3 = 3),
avail = list(alt1=1, alt2=1, alt3 = 1),
choiceVar = choix,
utilities = V
)

### Compute probabilities using MNL model
P[["model"]] = apollo_mnl(mnl_settings, functionality)

### Take product across observation for same individual
P = apollo_panelProd(P, apollo_inputs, functionality)

### Average across inter-individual draws
P = apollo_avgInterDraws(P, 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) ----
# ----------------------------------------------------------------- #
modelOutput_settings <- list(printPVal = 2)
apollo_modelOutput(model, modelOutput_settings)

# ----------------------------------------------------------------- #
#---- FORMATTED OUTPUT (TO FILE, using model name) ----
# ----------------------------------------------------------------- #

apollo_saveOutput(model)
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: ASC in WTP space or preference based space

Post by stephanehess »

Hi

what happens in terms of log-likelihood?

Also, despite what some people think, you should also include an additional ASC here as there may be order effects. So you should have 2 ASCs

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
chlob
Posts: 2
Joined: 16 Dec 2022, 11:26

Re: ASC in WTP space or preference based space

Post by chlob »

Hi,

Thank you for your answer.

The log-likelihood equals -7959.72 in model 1, and -7571.1 in model 2.
When I include an additional ASC as you suggest, the LL equals -7954.46 in model 1 and -7540.53 in model 2.
Could you specify what order effects are ?

Thank you,

Chloé
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: ASC in WTP space or preference based space

Post by stephanehess »

Chloe

first, regarding order effects, let me explain. If you only include an asc for option 3, then you're saying that all else being equal (i.e. at the same attribute levels), alternative 1 and 2 have the same probability. But we often see that people choose the option on the left more often (that's what an order effect is), and that's what you're capturing with the new constant, which is why the fit is better.

In relation to preference space vs WTP space, this also makes sense.

In your WTP space model, the impact of the ASC on utility is constant across individuals, at a value of asc_3 for example, while in WTP space, you are multiplying it by a random coefficient, and in your present case, that seems to give you a better explanation of the data. You could of course instead try to make the asc a random coefficient directly.

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
Post Reply