Announcement

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

  • new package on SSC: bayesmixedlogitwtp

    Dear Listers --

    Thanks once again to Kit Baum, a new command is available on statalist: bayesmixedlogitwtp. This command works in much the same fashion as bayesmixedlogit (or in similar fashion to Arne Risa Hole's mixlogit and mixlogitwtp, for that matter). The chief difference is that bayesmixedlogitwtp allows the user to specify a price variable. The price variable serves to normalize other estimated coefficients in the mixed logit model. The hows and whys of the model are described by Scarpa et. al. (2008) and Hole and Kolstad (2012); other references are given in the help file.

    Example of usage:

    Code:
    use http://fmwww.bc.edu/repec/bocode/t/traindata.dta
    
    bayesmixedlogitwtp y contract local wknown, group(gid) id(pid) ///
                price(price) rand(seasonal tod) draws(4000) burn(1000) thin(5) ///
                arater(.4) saving(draws) replace noisy
    The above example (which borrows from Arne Risa Hole's help file for mixlogitwtp) assumes that contract, local, and wknown have fixed coefficients, and that rand and seasonal
    have coefficients that vary at the gid level. Moreover, 4000 draws from the posterior are taken, the first 1000 are discarded, and then every fifth draw is kept. The draws are saved as draws.dta, and the drawing process is tuned to get an acceptance rate of .4,

    bayesmixedlogitwtp requires installation of the package of mata routines amcmc (ssc install amcmc).

    All the best,

    Matt Baker

    References:

    Hole, A. R. and J. R. Kolstad. 2012. Mixed logit estimation of willingness to pay distributions: a comparison of models in preference and WTP space using data from a health-related choice experiment. Empirical Economics 42: 445-469.

    R. Scarpa, M. Thiene, and K. Train. 2008. Utility in willingness to pay space: A tool to address confounding random scale effects in destination choice to the Alps. American Journal of Agricultural Economics 90: 994-1010.

    *Thanks to Kenneth Train for suggesting the command, and for Arne Risa Hole for allowing use of his examples.





  • #2
    Dear Matt, thank you for this. Question: when using the "noisy" option with bayesmixedlogitwtp is the function number displayed in ln_fc(p) the same as in bayesmlogit?
    The reason why I ask is because using the same data, in one case (with bayesmlogit) I obtain a string of negative numbers, while with bayesmixedlogitwtp the numbers are positive. Iam not sure how to intepret the change in sign.

    Comment


    • #3
      Dear Ric --

      Well, thanks for giving the package a try! You are the first user to contact me about it, so it might well be the case that something fishy is going on.

      The outputted number should in fact be the log likelihood calculated at the last iteration. In my experience, it is usually is negative. While I don't think it has to be, the change in sign is puzzling - how do the coefficient estimates look? And do you have an example of code that is producing this problem? If it is of a sensitive nature, please feel free to contact me offline.

      Best,

      Matt

      Comment


      • #4
        Dear Ric --

        A follow up - I did a little messing around, based on a hunch, and I think I found at least one thing that will flip a sign like that. I was able to reproduce this effect using Arne's Hole's examples in conjunction with my code. The problem emerges because he requires the user to specify a negative price variable (mprice in his example) while I just require the price variable.

        So, in his example, we have:


        Code:
        use http://fmwww.bc.edu.repec/bocode/t/traindata.dta
        gen mprice=-price
        mixlogitwtp y contract local wknown, group(gid) id(pid) price(mprice) rand(tod seasonal) nrep(500)
        To get the same results using my code, one would do something like:
        Code:
        use http://fmwww.bc.edu.repec/bocode/t/traindata.dta
        bayesmixedlogitwtp y contract local wknown, group(gid) id(pid) price(price) rand(tod seasonal) draws(4000) burn(1000) thin(5) arater(.4) saving(draws) replace noisy
        Notice that I use the variable price instead of mprice in my code, unlike in Arne's. If I were to instead do:
        Code:
        use http://fmwww.bc.edu.repec/bocode/t/traindata.dta
        bayesmixedlogitwtp y contract local wknown, group(gid) id(pid) price(mprice) rand(tod seasonal) draws(4000) burn(1000) thin(5) arater(.4) saving(draws) replace noisy
        I find that the log-likelihood flips signs and doesn't make much sense. It turns out that Kenneth Train had this problem with the code when he first used it to, so I'm wondering if I should redo it so that my code works just like Arne's. Does this help your problem?

        All the best,

        Matt




        Comment


        • #5
          Thank you Matt, yes using price, rather than mprice=-price works fine. An important difference to bear in mind. Cheers

          Comment


          • #6
            Dear Prof. Baker, thank you very much for developing these amazing commands. They are extremely helpful for people like me that come from traditional statistics.
            I have some questions about how these commands work.
            In particular, I was wondering does the bayesmixedlogit commands assume correlation across random coefficients?

            What is the corresponding behavioural model in maximum simulated likelihood?

            for instance: does
            Code:
            use http://fmwww.bc.edu/repec/bocode/t/traindata.dta, clear
            gen mprice = -price
            
            bayesmixedlogitwtp y , group(gid) id(pid) price(price) ///
            rand(contract  wknown  seasonal) draws(4000) burn(1000) thin(5) arater(.4) saving(draws) replace 
            
            Bayesian Mixed Logit Model - WTP Form              Observations    =      4780
                                                               Groups          =       100
            Acceptance rates:                                  Choices         =      1195
             Fixed coefs              =                        Total draws     =      4000
             Random coefs(ave,min,max)= 0.106, 0.070, 0.169    Burn-in draws   =      1000
                                                               *One of every 5 draws kept
            --------------------------------------------------------------------------------------
                               y | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
            ---------------------+----------------------------------------------------------------
            Random               |
                           price |  -5.330728    .476499   -11.19   0.000    -6.266536   -4.394919
                        contract |  -6.105727   2.302428    -2.65   0.008    -10.62752    -1.58393
                          wknown |   .7528115   .3928847     1.92   0.056    -.0187847    1.524408
                        seasonal |  -8.729855   2.798196    -3.12   0.002     -14.2253   -3.234407
            ---------------------+----------------------------------------------------------------
            Cov_Random           |
                       var_price |   4.370335   1.689797     2.59   0.010     1.051699    7.688971
               cov_pricecontract |   -.761065   3.698008    -0.21   0.837    -8.023677    6.501547
                 cov_pricewknown |  -1.024345   1.185355    -0.86   0.388    -3.352293    1.303604
               cov_priceseasonal |   -1.21949   2.830708    -0.43   0.667    -6.778791    4.339811
                    var_contract |   8.051819   6.801521     1.18   0.237    -5.305863     21.4095
              cov_contractwknown |  -1.362591   1.308084    -1.04   0.298     -3.93157    1.206388
            cov_contractseasonal |   5.437551   5.478745     0.99   0.321    -5.322296     16.1974
                      var_wknown |   1.756421   .8287828     2.12   0.034     .1287528    3.384088
              cov_wknownseasonal |  -.6792098   1.215828    -0.56   0.577    -3.067005    1.708585
                    var_seasonal |   6.108524   5.202826     1.17   0.241    -4.109439    16.32649
            --------------------------------------------------------------------------------------
            Corresponds to this model using maximum simulated likelihood, or I should remove the corr option?

            Code:
            mixlogitwtp y, group(gid) id(pid) price(mprice) rand(contract  wknown  seasonal) nrep(500) corr
            
            Mixed logit model in WTP space                          Number of obs =  4,780
                                                                    Wald chi2(4)  = 396.31
            Log likelihood = -1487.0707                             Prob > chi2   = 0.0000
            
            ------------------------------------------------------------------------------
                       y | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
            -------------+----------------------------------------------------------------
                contract |  -2.375441   .6796906    -3.49   0.000     -3.70761   -1.043272
                  wknown |   3.222715    1.48582     2.17   0.030       .31056    6.134869
                seasonal |  -9.390058   4.046123    -2.32   0.020    -17.32031   -1.459804
                   price |  -2.803907   .1704037   -16.45   0.000    -3.137893   -2.469922
            -------------+----------------------------------------------------------------
                    /l11 |   3.834134   .7396109     5.18   0.000     2.384523    5.283745
                    /l21 |    5.32714   2.050502     2.60   0.009     1.308231    9.346049
                    /l31 |   .0038983   2.768818     0.00   0.999    -5.422885    5.430682
                    /l41 |   .1463251   .1129576     1.30   0.195    -.0750676    .3677179
                    /l22 |  -2.188653   1.870518    -1.17   0.242    -5.854801    1.477496
                    /l32 |  -21.40142   4.737946    -4.52   0.000    -30.68762   -12.11522
                    /l42 |   .0333178   .1467153     0.23   0.820     -.254239    .3208746
                    /l33 |  -5.224479    3.14629    -1.66   0.097    -11.39109    .9421359
                    /l43 |   .6087522   .1298044     4.69   0.000     .3543401    .8631642
                    /l44 |   .1163286   .2175831     0.53   0.593    -.3101264    .5427835
            If so, why are the WTP estimates so different? the estimated WTP for contract is -6 cents for the bayesmixedlogitwtp, while it is -2 for the mixlogitwtp command. Am I doing something wrong?

            Moreover, I am not sure I fully understand the results of the bayesmixedlogit and how they compare to results of the bayesmixedlogitwtp.

            If I correctly understand this I should be able to generate WTP estimates using the `wtp` post estimation command after bayesmixedlogit.
            However, the results of two models that otherwise should be identical are extremely different. For instance WTP for the well, a Contract is 1.6472329 cents in the bayesmixedlogit while it is -6.1 cents for the bayesmixedlogitwtp. I am sure there is something I fail to understand, and I would be extremely grateful if you could help me clarify this.

            Code:
            bayesmixedlogit y, group(gid) id(pid) ///
            rand(contract  wknown  seasonal price) draws(4000) burn(1000) thin(5) arater(.4) saving(draws) replace
            wtp price seasonal contract wknown
            Bayesian Mixed Logit Model                         Observations    =      4780
                                                               Groups          =       100
            Acceptance rates:                                  Choices         =      1195
             Fixed coefs              =                        Total draws     =      4000
             Random coefs(ave,min,max)= 0.320, 0.287, 0.351    Burn-in draws   =      1000
                                                               *One of every 5 draws kept
            -----------------------------------------------------------------------------------
                            y | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
            ------------------+----------------------------------------------------------------
            Random            |
                     contract |  -.1498514   .0479138    -3.13   0.002    -.2439507   -.0557522
                       wknown |   .2914909   .1178378     2.47   0.014     .0600662    .5229156
                     seasonal |  -.4720396   .1900998    -2.48   0.013    -.8453814   -.0986978
                        price |   .0909716   .0310151     2.93   0.003     .0300603    .1518829
            ------------------+----------------------------------------------------------------
            Cov_Random        |
                 var_contract |   .1834006   .0357032     5.14   0.000     .1132822    .2535191
            cov_contractwkn~n |   .0664387   .0488276     1.36   0.174     -.029455    .1623325
            cov_contractsea~l |   .0993317   .0846303     1.17   0.241    -.0668759    .2655394
            cov_contractprice |   .0224328   .0146294     1.53   0.126    -.0062982    .0511638
                   var_wknown |   .6316606   .1713607     3.69   0.000      .295121    .9682002
            cov_wknownseaso~l |   -.021909     .19622    -0.11   0.911    -.4072704    .3634524
              cov_wknownprice |   .0133392   .0276956     0.48   0.630     -.041053    .0677314
                 var_seasonal |   1.898333   .5032228     3.77   0.000     .9100406    2.886625
            cov_seasonalprice |   .0672512   .0543333     1.24   0.216    -.0394553    .1739578
                    var_price |    .082338   .0132258     6.23   0.000     .0563635    .1083126
            -----------------------------------------------------------------------------------
             wtp price seasonal contract wknown
            
                   seasonal    contract      wknown
            wtp   5.1888666   1.6472329  -3.2041962
             ll  -.93333628   .01413976  -6.4075142
             ul    11.31107    3.280326  -.00087816
            
            bayesmixedlogitwtp y , group(gid) id(pid) price(price) ///
            rand(contract  wknown  seasonal) draws(4000) burn(1000) thin(5) arater(.4) saving(draws) replace
            
            Bayesian Mixed Logit Model - WTP Form              Observations    =      4780
                                                               Groups          =       100
            Acceptance rates:                                  Choices         =      1195
             Fixed coefs              =                        Total draws     =      4000
             Random coefs(ave,min,max)= 0.106, 0.070, 0.169    Burn-in draws   =      1000
                                                               *One of every 5 draws kept
            --------------------------------------------------------------------------------------
                               y | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
            ---------------------+----------------------------------------------------------------
            Random               |
                           price |  -5.330728    .476499   -11.19   0.000    -6.266536   -4.394919
                        contract |  -6.105727   2.302428    -2.65   0.008    -10.62752    -1.58393
                          wknown |   .7528115   .3928847     1.92   0.056    -.0187847    1.524408
                        seasonal |  -8.729855   2.798196    -3.12   0.002     -14.2253   -3.234407
            ---------------------+----------------------------------------------------------------
            Cov_Random           |
                       var_price |   4.370335   1.689797     2.59   0.010     1.051699    7.688971
               cov_pricecontract |   -.761065   3.698008    -0.21   0.837    -8.023677    6.501547
                 cov_pricewknown |  -1.024345   1.185355    -0.86   0.388    -3.352293    1.303604
               cov_priceseasonal |   -1.21949   2.830708    -0.43   0.667    -6.778791    4.339811
                    var_contract |   8.051819   6.801521     1.18   0.237    -5.305863     21.4095
              cov_contractwknown |  -1.362591   1.308084    -1.04   0.298     -3.93157    1.206388
            cov_contractseasonal |   5.437551   5.478745     0.99   0.321    -5.322296     16.1974
                      var_wknown |   1.756421   .8287828     2.12   0.034     .1287528    3.384088
              cov_wknownseasonal |  -.6792098   1.215828    -0.56   0.577    -3.067005    1.708585
                    var_seasonal |   6.108524   5.202826     1.17   0.241    -4.109439    16.32649
            --------------------------------------------------------------------------------------

            Comment


            • #7
              Dear @matthewjbaker,
              First of all thank you again to develop this extremely useful command.
              I have two questions?

              1) Is there a way to estimate this model assuming that there is no correlation across random parameters?
              2) is there a way to estimate the model assuming that the price coefficient is fixed rather than log normally distributed? In my field the baseline approach often uses a fixed price coefficient.

              Thank you very much in advance for your help on this matter

              Best

              Comment

              Working...
              X