Page 1 of 1

'MNL' Best-worst estimation settings for Conjoint based dataset

Posted: 09 Jan 2022, 20:02
by Yashin
Dear Concern,

I have a conjoint based data set where I have recorded the responses of the respondents in a response column giving them best-worst choice experiment. Hence, the response column has been coded as effects coding as: best =1, worst =-1 and the rest/not chosen = 0.

Here is the code that I have used for MNL joint Best-worst estimation from the Apollo choice modeling forum (drug choice data):
N:B= Here, Concepts= alternatives, Response= Choice

rm(list = ls())
#install.packages("apollo")

### Load Apollo library
library(apollo)


### Initialise code
apollo_initialise()



### Set core controls
apollo_control = list(
modelName = "MNL",
modelDescr = "logit model for best-worst",
indivID = "sys_RespNum",
outputDirectory = "output"
)


database_A = read.csv("test_machen.csv",header=TRUE)
database_B = read.csv("CBC02.csv",header=TRUE)
total <- merge(database_A,database_B,by="sys_RespNum", all.database_B = TRUE)
#write.csv(total,"final.csv", row.names = FALSE)
database<-total


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

### Vector of parameters, including any that are kept fixed in estimation
apollo_beta = c(b_Distance = 0,
b_Rev_Waiting_Time= 0,
b_Charging_Power= 0,
b_Charging_Time = 0,
b_Price = 0,
mu_worst= 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_Distance", "b_Rev_Waiting_Time", "b_Charging_Power", "b_Charging_Time", "b_Price")

# ################################################################# #
#### 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()

### List of utilities: these must use the same names as in mnl_settings, order is irrelevant
V = list()
V[["Concept1"]] = ( b_Distance*Distance==1 + b_Rev_Waiting_Time*(Rev_Waiting_Time==1)
+ b_Charging_Power*(Charging_Power==1) + b_Charging_Time*(Charging_Time==1)
+ b_Price*(Price==1))
V[["Concept2"]] = ( b_Distance*Distance==2 + b_Rev_Waiting_Time*(Rev_Waiting_Time==2)
+ b_Charging_Power*(Charging_Power==2) + b_Charging_Time*(Charging_Time==2)
+ b_Price*(Price==2))
V[["Concept3"]] = ( b_Distance*Distance==3 + b_Rev_Waiting_Time*(Rev_Waiting_Time==3)
+ b_Charging_Power*(Charging_Power==3) + b_Charging_Time*(Charging_Time==3)
+ b_Price*(Price==3))

### Compute probabilities for "best" choice using MNL model
mnl_settings_best = list(
alternatives = c(Concept1=1, Concept2=-1, Concept3=0),
avail = 1,
choiceVar = "Response"==1,
utilities = V,
componentName = "Response"
)
P[["choice_best"]] = apollo_mnl(mnl_settings_best, functionality)



### Compute probabilities for "worst" choice using MNL model
mnl_settings_worst = list(
alternatives = c(Concept1=1, Concept2=-1, Concept3=0),
avail = 1,
choiceVar = "Response"==1,
utilities = list(Concept1 = -mu_worst*V[["Concept1"]],
Concept2 = -mu_worst*V[["Concept2"]],
Concept3 = -mu_worst*V[["Concept3"]],
componentName = "Response"!=1 )
)

P[["choice_worst"]] = apollo_mnl(mnl_settings_worst, functionality)

### Combined model
P = apollo_combineModels(P, apollo_inputs, 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 ####
# ################################################################# #

model = apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, apollo_inputs)

After this code, I am receiving the following information in my R console:


Testing likelihood function...
WARNING: some alternatives are never chosen in your data!
WARNING: Availability not provided (or some elements are NA). Full availability assumed.

Overview of choices for MNL model component Response:
Concept1 Concept2 Concept3
Times available 750 750 750.00
Times chosen 0 0 1.00
Percentage chosen overall 0 0 0.13
Percentage chosen when available 0 0 0.13
Apollo found a model component of type MNL without a componentName. The name was set to "choice_worst" by default.
WARNING: some alternatives are never chosen in your data!
WARNING: Availability not provided (or some elements are NA). Full availability assumed.

Overview of choices for MNL model component choice_worst:
Concept1 Concept2 Concept3
Times available 750 750 750.00
Times chosen 0 0 1.00
Percentage chosen overall 0 0 0.13
Percentage chosen when available 0 0 0.13

Pre-processing likelihood function...

Testing influence of parametersError in apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, :
Parameter mu_worst does not influence the log-likelihood of your model!


I am bit confused, which core setting do I have to change for using this Apollo package. Any suggestions will be highly appreciated.

Re: 'MNL' Best-worst estimation settings for Conjoint based dataset

Posted: 13 Jan 2022, 08:51
by stephanehess
Hi

sorry, your description of the experiment/data is not very clear, and looking at the utilities doesn't really clarify it to me either. What did people see in the experiment?

Stephane