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.

WTP for mixed logit with random parameters

Ask questions about post-estimation functions (e.g. prediction, conditionals, etc) or other processing of results.
JuliavB
Posts: 41
Joined: 18 Aug 2021, 13:36

WTP for mixed logit with random parameters

Post by JuliavB »

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.
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: WTP for mixed logit with random parameters

Post by stephanehess »

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
--------------------------------
Stephane Hess
www.stephanehess.me.uk
JuliavB
Posts: 41
Joined: 18 Aug 2021, 13:36

Re: WTP for mixed logit with random parameters

Post by JuliavB »

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!
JuliavB
Posts: 41
Joined: 18 Aug 2021, 13:36

Re: WTP for mixed logit with random parameters

Post by JuliavB »

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!
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: WTP for mixed logit with random parameters

Post by stephanehess »

Hi

replying to your two posts at the same time.
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
Working in WTP space will always give you the WTP directly, as long as your cost coefficient enters the utility in a linear way.
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?
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
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
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.

Hope this helps

Stephane
--------------------------------
Stephane Hess
www.stephanehess.me.uk
JuliavB
Posts: 41
Joined: 18 Aug 2021, 13:36

Re: WTP for mixed logit with random parameters

Post by JuliavB »

Hi Stephane,

your information helped a lot. Thank you very much.
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
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.
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"]]
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
I tried the following code but got an error message:

unconditionals <- apollo_unconditionals(model,apollo_probabilities, apollo_inputs)
WTP_A2_level1 = "b_ A2_level1 "/(unconditionals[["b_Cost"]])
Error: "non-numeric argument to binary operator"
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.
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)"))
apollo_deltaMethod(model, deltaMethod_settings)

Thank you very much.
stephanehess
Site Admin
Posts: 974
Joined: 24 Apr 2020, 16:29

Re: WTP for mixed logit with random parameters

Post by stephanehess »

Hi

apologies for the slow response, the forum was offline due to a technical issue.

You say
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"]]
what exactly do you mean that no results are given in R. They should be in WTP_A2

Regarding
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)"))
this gives you WTP in the two classes. I assumed you wanted the unconditional WTP too?
--------------------------------
Stephane Hess
www.stephanehess.me.uk
JuliavB
Posts: 41
Joined: 18 Aug 2021, 13:36

Re: WTP for mixed logit with random parameters

Post by JuliavB »

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)
dpalma
Posts: 190
Joined: 24 Apr 2020, 17:54

Re: WTP for mixed logit with random parameters

Post by dpalma »

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:

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)
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:

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.
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
JuliavB
Posts: 41
Joined: 18 Aug 2021, 13:36

Re: WTP for mixed logit with random parameters

Post by JuliavB »

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.
Post Reply