Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • WTP calculation

    Dear Stata community, I am doing a mixed logit model with a lognormal price and I have to transform the price to normal and getting the mean price in order to calculate WTP. I did that with nlcom command. The problem is that then I generate a WTP through gen WTP but I cannot put the newly calculated mean price by nlcom because stata does not recognize it as a variable because it is not part of the mixed logit (in the mixed logit model I have the lognormal price). So my question would be how can I put the mean price generated by nlcom into a WTP equation? Thank you
    Last edited by Edoardo Maria Pelli; 13 Sep 2023, 07:04.

  • #2
    Edoardo Maria Pelli: I'm afraid that I don't quite follow your explanation. Could you write down the actual sequence of command lines that you've executed?

    Comment


    • #3
      Dear Hong II Yoo,

      Thanks for the answer. So I wrote this command for nlcom to get the mean price with nlcom (As done by Hole)

      nlcom (mean_price:-1*exp([Mean]_b[mprice]+0.5*[SD]_b[mprice]^2)))
      nlcom (med_price:-1*exp([Mean]_b[mprice]))
      nlcom (sd_price:exp([Mean]_b[mprice]+0.5*[SD]_b[mprice]^2))
      And I got it.

      Then I generate the WTP through gen WTP

      gen WTPorganic= -(_b[organic]+_b[organic_treatment]*treatment+_b[care_organic]*m_careharm+_b[fairness_organic]*m_fairnesscheating+_b[loyalty_organic]*m_loyaltybetrayal +_b[authority_organic]*m_authoritysubversion +_b[purity_organic]*m_puritydegradation)/mean price

      but Stata does not recognize this mean price as a variable

      Comment


      • #4
        Edoardo Maria Pelli: Considering that you only need the point estimate, perhaps the easiest way to handle this is to define a local macro. For example:
        Code:
        local mean_price (-1*exp([Mean]_b[mprice]+0.5*[SD]_b[mprice]^2)
        gen WTPorganic= -(_b[organic]+_b[organic_treatment]*treatment+_b[care_organic]*m_careharm+_b[fairness_organic]*m_fairnesscheating+_b[loyalty_organic]*m_loyaltybetrayal +_b[authority_organic]*m_authoritysubversion +_b[purity_organic]*m_puritydegradation)/`mean price'
        Just to add two cents: You can combine your three -nlcom- command lines into a single command line containing three distinct expressions if you prefer: -nlcom (mean_price: ...) (med_pricee: ...) (sd_price: ...)-. If you'd like to change the estimates in Stata's memory to your -nlcom- output, you can add the option -post- to the end of your -nlcom- command line. See -help nlcom-. This will allow you to reference the -nlcom- output directly in subsequent Stata operations by typing _b[mean_price], _b[med_price], etc. But this also means that Stata will forget your raw mixed logit estimate, so you'll need to create copies of your raw estimates as part of your -nlcom- statement (e.g., by adding -(organic: _b[organic])- to your -nlcom- expressions) if your goal is to combine your raw output and -nlcom- results as you seem to be doing in your -generate- command line.

        Comment


        • #5
          Dear Hong II Yoo, thank you very much for the suggestion and sorry for my late response.
          Last edited by Edoardo Maria Pelli; 10 Oct 2023, 09:41.

          Comment

          Working...
          X