I have a question about estimating WTP in the preference space.
I am estimating a mixed logit model. I have assumed all variables to be normally distributed, except for the cost variable which I have assumed as a negative lognormal, and the reference variables which I have fixed. The code for model estimation is as follows:
Code: Select all
choiceAnalysis_settings <- list(
alternatives = c(alt1=1, alt2=2, alt3=3),
avail = list(alt1=database$alt1.a1, alt2=database$alt2.a1, alt3=database$alt3.a1),
choiceVar = database$Preference)
# ################################################################# #
#### GROUP AND VALIDATE INPUTS ####
# ################################################################# #
### Vector of parameters, including any that are kept fixed in estimation
apollo_beta=c(mu_community_engagement = 0,
mu_basic_community_services = 0,
mu_community_holidays = 0,
mu_music_community = 0,
mu_no_maintenance = 0,
mu_essential_repair = 0,
mu_Comprehensive_repair = 0,
mu_open_6days = 0,
mu_weekly_service = 0,
mu_daily_reflection = 0,
mu_minimal_tech = 0,
mu_basic_tech = 0,
mu_high_tech = 0,
mu_price = -3,
sigma_basic_community_services = 0,
sigma_community_holidays = 0,
sigma_music_community = 0,
sigma_essential_repair = 0,
sigma_Comprehensive_repair = 0,
sigma_weekly_service = 0,
sigma_daily_reflection = 0,
sigma_basic_tech = 0,
sigma_high_tech = 0,
sigma_price = 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("mu_community_engagement", "mu_no_maintenance", "mu_open_6days", "mu_minimal_tech")
### Set parameters for generating draws
apollo_draws = list(
interDrawsType = "mlhs",
interNDraws = 200,
interUnifDraws = c(),
interNormDraws = c("draws_basic_community","draws_community_holidays","draws_music_community", "draws_essential_repair", "draws_comprehensive_repair", "draws_weekly_service", "draws_daily_reflection", "draws_basic_tech", "draws_high_tech", "draws_price"),
intraDrawsType = "pmc",
intraNDraws = 0,
intraUnifDraws = c(),
intraNormDraws = c()
)
apollo_randCoeff = function(apollo_beta, apollo_inputs){
randcoeff = list()
randcoeff[["basic_community_services"]] = ( mu_basic_community_services + sigma_basic_community_services * draws_basic_community)
randcoeff[["community_holidays"]] = (mu_community_holidays + sigma_community_holidays * draws_community_holidays)
randcoeff[["music_community"]] = ( mu_music_community + sigma_music_community * draws_music_community)
randcoeff[["essential_repair"]] = ( mu_essential_repair + sigma_essential_repair * draws_essential_repair)
randcoeff[["Comprehensive_repair"]] = ( mu_Comprehensive_repair + sigma_Comprehensive_repair * draws_comprehensive_repair)
randcoeff[["weekly_service"]] = ( mu_weekly_service + sigma_weekly_service * draws_weekly_service)
randcoeff[["daily_reflection"]] = ( mu_daily_reflection + sigma_daily_reflection* draws_daily_reflection)
randcoeff[["basic_tech"]] = ( mu_basic_tech + sigma_basic_tech * draws_basic_tech)
randcoeff[["high_tech"]] = ( mu_high_tech + sigma_high_tech * draws_high_tech)
randcoeff[["price"]] = -exp(mu_price + sigma_price * draws_price)
return(randcoeff)
}
apollo_inputs = apollo_validateInputs()
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[['A']] = (
mu_community_engagement * ( alt1.a1 == 1)
+ basic_community_services * ( alt1.a1 == 2)
+ community_holidays * ( alt1.a1 == 3)
+ music_community * ( alt1.a1 == 4)
+ mu_no_maintenance * ( alt1.b1 == 1)
+ essential_repair * ( alt1.b1 == 2)
+ Comprehensive_repair * ( alt1.b1 == 3)
+ mu_open_6days * ( alt1.c1 == 1)
+ weekly_service * ( alt1.c1 == 2)
+ daily_reflection * (alt1.c1 == 3)
+ mu_minimal_tech * ( alt1.d1 == 1)
+ basic_tech * ( alt1.d1 == 2)
+ high_tech * (alt1.d1 == 3)
+ price * ( ( alt1.e1 == 2) * 2
+( alt1.e1 == 4) * 4
+( alt1.e1 == 6) * 6
+( alt1.e1 == 8) * 8
+( alt1.e1 ==10) * 10
+( alt1.e1 ==12) * 12
+( alt1.e1 ==14) * 14
+( alt1.e1 ==16) * 16 ))
V[['B']] = (
mu_community_engagement * ( alt2.a1 == 1)
+ basic_community_services * ( alt2.a1 == 2)
+ community_holidays * ( alt2.a1 == 3)
+ music_community * ( alt2.a1 == 4)
+ mu_no_maintenance * ( alt2.b1 == 1)
+ essential_repair * ( alt2.b1 == 2)
+ Comprehensive_repair * ( alt2.b1 == 3)
+ mu_open_6days * ( alt2.c1 == 1)
+ weekly_service * ( alt2.c1 == 2)
+ daily_reflection * (alt2.c1 == 3)
+ mu_minimal_tech * ( alt2.d1 == 1)
+ basic_tech * ( alt2.d1 == 2)
+ high_tech * (alt2.d1 == 3)
+ price * ( ( alt2.e1 == 2) * 2
+( alt2.e1 == 4) * 4
+( alt2.e1 == 6) * 6
+( alt2.e1 == 8) * 8
+( alt2.e1 ==10) * 10
+( alt2.e1 ==12) * 12
+( alt2.e1 ==14) * 14
+( alt2.e1 ==16) * 16 ))
V[['C']] = (
mu_community_engagement * ( alt3.a1 == 1)
+ mu_no_maintenance * ( alt3.b1 == 1)
+ mu_open_6days * ( alt3.c1 == 1)
+ mu_minimal_tech * (alt3.d1 ==1)
+ price * ( alt3.e1_status == 0) *0)
### Define settings for MNL model component
mnl_settings = list(
alternatives = c(A=1,B=2, C=3),
choiceVar = Preference,
V = 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 = apollo_estimate(apollo_beta, apollo_fixed, apollo_probabilities, apollo_inputs, estimate_settings=list(maxIterations=1000))
apollo_modelOutput(model)
Based on previous posts in this forum and some online literature, I think I have a number of options for calculating WTP. I am hoping someone can help me decide which is correct/the best one to use.
1) Simply take the ratio of the marginal utilities such that WTP = mu_attribute/mu_price
2) If the moments of the WTP distribution are finite, then one can find the mean of the WTP by sampling from each of the distributions of the coefficients in the WTP calculation. I think for my case this is as follows:
Code: Select all
N=10000
x = rnorm(N, mean= model$estimate['mu_essential_repair'], sd = abs(model$estimate['sigma_essential_repair']))
y = -exp(rlnorm(N, mean= model$estimate['mu_price'], sd = abs(model$estimate['sigma_price'])))
wtp = x/y
mean(wtp)
Any help is really appreciated!