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. This may take a day or two at busy times. There is no need to submit the post multiple times.
WTP for mixed logit with random parameters
WTP for mixed logit with random parameters
Dear Stephane,
I have a question on the calculation of willingness to pay in mixed logit:
Is it appropriate to randomise the price attribute as well as the other two attributes of my experiment AND then use the random parameter averages to calculate the WTP (mu_Attribute/mu_price)?
I am not sure if it might make more sense to not randomise the price due to the fact that it might be imprecise to devide randomised parameter by randomised parameter (even if the sigma of the price is significant and therefore indicates that there is heterogeneity in price).
Could you give any insights on this?
Thank you in advance and best wishes,
J.
I have a question on the calculation of willingness to pay in mixed logit:
Is it appropriate to randomise the price attribute as well as the other two attributes of my experiment AND then use the random parameter averages to calculate the WTP (mu_Attribute/mu_price)?
I am not sure if it might make more sense to not randomise the price due to the fact that it might be imprecise to devide randomised parameter by randomised parameter (even if the sigma of the price is significant and therefore indicates that there is heterogeneity in price).
Could you give any insights on this?
Thank you in advance and best wishes,
J.
-
- Site Admin
- Posts: 1066
- Joined: 24 Apr 2020, 16:29
Re: WTP for mixed logit with random parameters
The cost coefficient is quite likely to be the one with the most heterogeneity in the population, so you should definitely test for such heterogeneity.
But you would never calculate WTP as the ratio of the means - you need the full distribution
Please have a look at https://doi.org/10.1007/s11116-011-9331-3
But you would never calculate WTP as the ratio of the means - you need the full distribution
Please have a look at https://doi.org/10.1007/s11116-011-9331-3
Re: WTP for mixed logit with random parameters
Thank you very much for clarifying.
So, if I assume my cost coefficient being lognomally distributed and the other coefficients being normally distributed - so all three coefficients being random I have two options:
1. Estimating the model in WTP space to directly get the WTP values
2. Estimating the model in preference space and then using bootstrap method to manually average the WTP results of bootstrap estimations in order to get WTP for whole sample? And if yes, is there any specific example provided on how to do that code-wise in apollo?
Thank you very much in advance!
So, if I assume my cost coefficient being lognomally distributed and the other coefficients being normally distributed - so all three coefficients being random I have two options:
1. Estimating the model in WTP space to directly get the WTP values
2. Estimating the model in preference space and then using bootstrap method to manually average the WTP results of bootstrap estimations in order to get WTP for whole sample? And if yes, is there any specific example provided on how to do that code-wise in apollo?
Thank you very much in advance!
Re: WTP for mixed logit with random parameters
Two more things just to be sure:
1. If my cost coefficient is lognormally distributed (the only random coefficient in my model) and the other attributes are dummy coded and therefore fixed coefficients, the WTP can be computed via delta method like b_A2/mu_cost or is there also other approach needed?
2. In latent class models the WTP can be calculated via delta method just that it is calculated separately for each class via b_A2_class_a/b_cost_class_a and b_A2_class_b/b_cost_class_b, right?
Thank you in advance!
1. If my cost coefficient is lognormally distributed (the only random coefficient in my model) and the other attributes are dummy coded and therefore fixed coefficients, the WTP can be computed via delta method like b_A2/mu_cost or is there also other approach needed?
2. In latent class models the WTP can be calculated via delta method just that it is calculated separately for each class via b_A2_class_a/b_cost_class_a and b_A2_class_b/b_cost_class_b, right?
Thank you in advance!
-
- Site Admin
- Posts: 1066
- Joined: 24 Apr 2020, 16:29
Re: WTP for mixed logit with random parameters
Hi
replying to your two posts at the same time.
It's easy to get the full distribution in Apollo using apollo_unconditionals
Hope this helps
Stephane
replying to your two posts at the same time.
Working in WTP space will always give you the WTP directly, as long as your cost coefficient enters the utility in a linear way.So, if I assume my cost coefficient being lognomally distributed and the other coefficients being normally distributed - so all three coefficients being random I have two options:
1. Estimating the model in WTP space to directly get the WTP values
Bootstrapping is not the answer here. But maybe you don't mean bootstrapping but simulation of the ratio? This is only possible if the inverse moments exist - see http://www.stephanehess.me.uk/papers/jo ... n_2012.pdfEstimating the model in preference space and then using bootstrap method to manually average the WTP results of bootstrap estimations in order to get WTP for whole sample? And if yes, is there any specific example provided on how to do that code-wise in apollo?
It's easy to get the full distribution in Apollo using apollo_unconditionals
No, this is not correct. Mu is the mean of the distribution of the log of the coefficient. You need to divide b_A2 by the full distribution, using simulation. It's easy to get the full distribution in Apollo using apollo_unconditionalsIf my cost coefficient is lognormally distributed (the only random coefficient in my model) and the other attributes are dummy coded and therefore fixed coefficients, the WTP can be computed via delta method like b_A2/mu_cost or is there also other approach needed?
You don't need the delta method for the calculation of the wtp, only for the standard errors thereof. But your calculation above is correct, but you then still need to take the weighted average across classes.In latent class models the WTP can be calculated via delta method just that it is calculated separately for each class via b_A2_class_a/b_cost_class_a and b_A2_class_b/b_cost_class_b, right?
Hope this helps
Stephane
Re: WTP for mixed logit with random parameters
Hi Stephane,
your information helped a lot. Thank you very much.
I tried the following code but no results are given in R.
unconditionals <- apollo_unconditionals(model,apollo_probabilities, apollo_inputs)
WTP_A2 = unconditionals[["b_A2"]]/unconditionals[["b_cost"]]
unconditionals <- apollo_unconditionals(model,apollo_probabilities, apollo_inputs)
WTP_A2_level1 = "b_ A2_level1 "/(unconditionals[["b_Cost"]])
Error: "non-numeric argument to binary operator"
deltaMethod_settings=list(expression=c(WTP_A2_a="(b_A2_class_a/b_cost_class_a )", WTP_A2_b="(b_A2_class_b/b_cost_class_b)"))
apollo_deltaMethod(model, deltaMethod_settings)
Thank you very much.
your information helped a lot. Thank you very much.
Referring to your mentioned paper in my case it should be fine using simulation of the ratio as my cost coefficient is lognormally distributed and the other attributes are normally distributed.Bootstrapping is not the answer here. But maybe you don't mean bootstrapping but simulation of the ratio? This is only possible if the inverse moments exist - see http://www.stephanehess.me.uk/papers/jo ... n_2012.pdf
It's easy to get the full distribution in Apollo using apollo_unconditionals
I tried the following code but no results are given in R.
unconditionals <- apollo_unconditionals(model,apollo_probabilities, apollo_inputs)
WTP_A2 = unconditionals[["b_A2"]]/unconditionals[["b_cost"]]
I tried the following code but got an error message:If my cost coefficient is lognormally distributed (the only random coefficient in my model) and the other attributes are dummy coded and therefore fixed coefficients, the WTP can be computed via delta method like b_A2/mu_cost or is there also other approach needed?
No, this is not correct. Mu is the mean of the distribution of the log of the coefficient. You need to divide b_A2 by the full distribution, using simulation. It's easy to get the full distribution in Apollo using apollo_unconditionals
unconditionals <- apollo_unconditionals(model,apollo_probabilities, apollo_inputs)
WTP_A2_level1 = "b_ A2_level1 "/(unconditionals[["b_Cost"]])
Error: "non-numeric argument to binary operator"
Can you explain what you mean to take the weighted average across classes when I´ve put my calculation with delta method like this:In latent class models the WTP can be calculated via delta method just that it is calculated separately for each class via b_A2_class_a/b_cost_class_a and b_A2_class_b/b_cost_class_b, right?
You don't need the delta method for the calculation of the wtp, only for the standard errors thereof. But your calculation above is correct, but you then still need to take the weighted average across classes.
deltaMethod_settings=list(expression=c(WTP_A2_a="(b_A2_class_a/b_cost_class_a )", WTP_A2_b="(b_A2_class_b/b_cost_class_b)"))
apollo_deltaMethod(model, deltaMethod_settings)
Thank you very much.
-
- Site Admin
- Posts: 1066
- Joined: 24 Apr 2020, 16:29
Re: WTP for mixed logit with random parameters
Hi
apologies for the slow response, the forum was offline due to a technical issue.
You say
Regarding
apologies for the slow response, the forum was offline due to a technical issue.
You say
what exactly do you mean that no results are given in R. They should be in WTP_A2I tried the following code but no results are given in R.
unconditionals <- apollo_unconditionals(model,apollo_probabilities, apollo_inputs)
WTP_A2 = unconditionals[["b_A2"]]/unconditionals[["b_cost"]]
Regarding
this gives you WTP in the two classes. I assumed you wanted the unconditional WTP too?Can you explain what you mean to take the weighted average across classes when I´ve put my calculation with delta method like this:
deltaMethod_settings=list(expression=c(WTP_A2_a="(b_A2_class_a/b_cost_class_a )", WTP_A2_b="(b_A2_class_b/b_cost_class_b)"))
Re: WTP for mixed logit with random parameters
When I assume the price parameter to be fixed and the other two parameters being random, can the WTP and its confidence intervalls be computed with the following code or am I missing anything: Do I have to account for the sigma in any way or is it considered when using the delta method code already?
deltaMethod_settings=list(expression=c(WTP_A2="(mu_A2/b_price)", WTP_A3="(mu_A3/b_price)"))
apollo_deltaMethod(model, deltaMethod_settings)
deltaMethod_settings=list(expression=c(WTP_A2="(mu_A2/b_price)", WTP_A3="(mu_A3/b_price)"))
apollo_deltaMethod(model, deltaMethod_settings)
Re: WTP for mixed logit with random parameters
Hi,
The function apollo_deltaMethod will not take into consideration sigma_A2 and sigma_A3 unless you specifically include them in the expression. So when you write:
The answer is no, your results will ignore the randomness of coefficients b_A2 and b_A3. Where b_A2 and b_A3 are the coefficients with mean mu_A2 and mu_A3, respectively, and standard deviation sigma_A2 and sigma_A3, respectively.
Now, if b_A2 and b_A3 follow a normal distribution, then your code would be calculating the expected value (and its s.e.) of the WTP for A2 and A3. Which is probably what you want.
But in the more general case (e.g. when you are not using normally distributed random coefficients), what I would recommend is simulating the expected value of the WTP. You can do this by getting the unconditional draws of b_A2 and b_A3, divide those draws by b_price, and that would give you the distribution of the WTPs. You can then get the average of that, which will be the expected value of the WTPs. The code below should do that for A2:
Note that doing sd(un$beta_A2/model$estimate["b_price"]) will not give you the s.e. of the expected value of the WTP, but instead will just give you s.d. of the WTP, which should be very close to sigma_A2/b_price
Hope this helps
Best wishes
David
The function apollo_deltaMethod will not take into consideration sigma_A2 and sigma_A3 unless you specifically include them in the expression. So when you write:
Code: Select all
deltaMethod_settings=list(expression=c(WTP_A2="(mu_A2/b_price)", WTP_A3="(mu_A3/b_price)"))
apollo_deltaMethod(model, deltaMethod_settings)
Now, if b_A2 and b_A3 follow a normal distribution, then your code would be calculating the expected value (and its s.e.) of the WTP for A2 and A3. Which is probably what you want.
But in the more general case (e.g. when you are not using normally distributed random coefficients), what I would recommend is simulating the expected value of the WTP. You can do this by getting the unconditional draws of b_A2 and b_A3, divide those draws by b_price, and that would give you the distribution of the WTPs. You can then get the average of that, which will be the expected value of the WTPs. The code below should do that for A2:
Code: Select all
un <- apollo_unconditionals(model, apollo_probabilities, apollo_inputs)
mean(un$beta_A2/model$estimate["b_price"]) # expected value of WTP for A2.
Hope this helps
Best wishes
David
Re: WTP for mixed logit with random parameters
Hi David,
your response helps a lot, thank you very much.
So just to get you right: With my initial code below I can indeed calculate the expected value of the WTP for A2 and A3 and its s.e. - all under the assumption that A2 and A3 are normally distributed random parameters.
deltaMethod_settings=list(expression=c(WTP_A2="(mu_A2/b_price)", WTP_A3="(mu_A3/b_price)"))
apollo_deltaMethod(model, deltaMethod_settings)
Now, why is the more general case for you to have not normally distributed coefficients, from what I have understood from other research, the standard case is to have normally distributed random parameters, isn´t it?
Following your approach I get the results below:
> ### Simulating expected value of WTP for A2
> un <- apollo_unconditionals(model, apollo_probabilities, apollo_inputs)
Unconditional distributions computed
> mean(un$b_HoeheEEE/model$estimate["b_Beitr"])
[1] 0.4087403
> sd(un$b_HoeheEEE/model$estimate["b_Beitr"])
[1] 0.3404505
The s.d. looks quite high, whilst the s.e. of the calculation with delta method with my initial code seems to be much lower. Could that be for the accounted randomness in your proposed code? Or what might be the reason?
Expression Value Robust s.e. Rob t-ratio (0)
WTP_Hoehe 0.4026 0.0542 7.43
Now when sd(un$b_HoeheEEE/model$estimate["b_Beitr"]) only gives me the s.d. of the WTP and not of the expected value of the WTP which confidence intervall can be reported then for the expected value of the WTP?
Thank you very much for your support on this.
your response helps a lot, thank you very much.
So just to get you right: With my initial code below I can indeed calculate the expected value of the WTP for A2 and A3 and its s.e. - all under the assumption that A2 and A3 are normally distributed random parameters.
deltaMethod_settings=list(expression=c(WTP_A2="(mu_A2/b_price)", WTP_A3="(mu_A3/b_price)"))
apollo_deltaMethod(model, deltaMethod_settings)
Now, why is the more general case for you to have not normally distributed coefficients, from what I have understood from other research, the standard case is to have normally distributed random parameters, isn´t it?
Following your approach I get the results below:
> ### Simulating expected value of WTP for A2
> un <- apollo_unconditionals(model, apollo_probabilities, apollo_inputs)
Unconditional distributions computed
> mean(un$b_HoeheEEE/model$estimate["b_Beitr"])
[1] 0.4087403
> sd(un$b_HoeheEEE/model$estimate["b_Beitr"])
[1] 0.3404505
The s.d. looks quite high, whilst the s.e. of the calculation with delta method with my initial code seems to be much lower. Could that be for the accounted randomness in your proposed code? Or what might be the reason?
Expression Value Robust s.e. Rob t-ratio (0)
WTP_Hoehe 0.4026 0.0542 7.43
Now when sd(un$b_HoeheEEE/model$estimate["b_Beitr"]) only gives me the s.d. of the WTP and not of the expected value of the WTP which confidence intervall can be reported then for the expected value of the WTP?
Thank you very much for your support on this.