Announcement

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

  • Price elasticity in mixlogit model in stata

    I am wondering if any routine has been written for price elasticity in mixlogit in stata. It seems that simulation is still needed to obtain proper price elasticity.

  • #2
    There is no dedicated routine, but the procedure described here http://www.stata.com/statalist/archi.../msg00283.html can (with some minor modifications) be used to calculate elasticities instead of marginal effects.

    Comment


    • #3
      Would the modification be to increase the relevant vbl by 1% instead of 1 unit?

      Comment


      • #4
        Would the modification be to increase the relevant vbl by 1% instead of 1 unit?
        Yes, that's right. Also in step 4) you should calculate the percentage change in the probabilities, instead of the difference.
        Last edited by Arne Risa Hole; 10 Dec 2015, 09:28.

        Comment


        • #5
          Is what I post below the correct way of computing the elasticity (toward the end of the post, in blue font)? If so, how can I specify which outcome to predict in mixlpred, for example for cross-elasticities? As I understand it, because there is no IIA restriction for mixed logit, the elasticities are allowed to vary by alternative. I have also attached the dataset I used in this toy example:

          Code:
          . use mixed_fishing,clear
          . sort id fishmode
          . list id fishmode d q p income dbeach dprivate ybeach yprivate in 1/6,sepby(id) noobs
          
            +------------------------------------------------------------------------------------------+
            | id   fishmode   d       q         p     income   dbeach   dprivate     ybeach   yprivate |
            |------------------------------------------------------------------------------------------|
            |  3      beach   0   .5333   161.874       3.75        1          0       3.75          0 |
            |  3       pier   0   .4522   161.874       3.75        0          0          0          0 |
            |  3    private   1   .2413    24.334       3.75        0          1          0       3.75 |
            |------------------------------------------------------------------------------------------|
            |  4      beach   0   .0678    15.134   2.083333        1          0   2.083333          0 |
            |  4       pier   1   .0789    15.134   2.083333        0          0          0          0 |
            |  4    private   0   .1643     55.93   2.083333        0          1          0   2.083333 |
            +------------------------------------------------------------------------------------------+
          where:
          Code:
                        storage   display    value
          variable name   type    format     label      variable label
          -----------------------------------------------------------------------------------------------------------------------
          id              float   %9.0g                 person id number
          fishmode        str7    %9s                   available alternatives
          d               float   %9.0g                 =1 if chosen alternative
          q               float   %9.0g                 catch rate for available alternatives
          p               float   %9.0g                 price for available alternatives
          income          float   %9.0g                 monthly income in thousands $
          dbeach          float   %9.0g                 =1 if beach is chosen alternative
          dprivate        float   %9.0g                 =1 if private is chosen alternative
          ybeach          float   %9.0g                 =dbeach*income
          yprivate        float   %9.0g                 =dprivate*income

          First, fit the model:
          Code:
          . ** Set macros
          . * Outcome
          . global ylist d
          .
          . * Model covariate
          . global xlist q dbeach dprivate ybeach yprivate
          . global rand p
          . global id id
          . global group id
          .
          . * Mixed logit or random-parameters logit model
          . mixlogit $ylist $xlist, group ($group) id($id) rand($rand) nrep(200)
          
          Iteration 0:   log likelihood = -602.08535  (not concave)
          Iteration 1:   log likelihood = -447.20449  
          Iteration 2:   log likelihood = -434.71017  
          Iteration 3:   log likelihood = -433.83131  
          Iteration 4:   log likelihood = -433.79169  
          Iteration 5:   log likelihood = -433.79161  
          Iteration 6:   log likelihood = -433.79161  
          
          Mixed logit model                                 Number of obs   =       2190
                                                            LR chi2(1)      =      66.04
          Log likelihood = -433.79161                       Prob > chi2     =     0.0000
          
          ------------------------------------------------------------------------------
                     d |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
          Mean         |
                     q |   .8526843   .9235166     0.92   0.356     -.957375    2.662743
                dbeach |  -.7796412   .2245532    -3.47   0.001    -1.219757    -.339525
              dprivate |  -.2189507   .3033658    -0.72   0.470    -.8135368    .3756353
                ybeach |   .1203407   .0492813     2.44   0.015     .0237512    .2169302
              yprivate |   .1735461   .0709019     2.45   0.014     .0345809    .3125114
                     p |  -.1072691   .0258052    -4.16   0.000    -.1578464   -.0566917
          -------------+----------------------------------------------------------------
          SD           |
                     p |   .0592371    .017146     3.45   0.001     .0256316    .0928427
          ------------------------------------------------------------------------------
          . preserve

          Then manually compute elasticities:
          Code:
          . * Manually compute elasticities (http://www.stata.com/statalist/archive/2012-02/msg00283.html)
          . * see also Cameron and Trivedi p. 353
          . * 1) Use -mixlpred- to calculate predicted probabilities in the original scenario
          .
          . mixlpred pred0,nrep(200)
          .
          .
          . * 2) Increase the relevant variable by 1 unit for all individuals in the sample
          .
          . replace p=p*1.01
          (2190 real changes made)
          .
          .
          .
          . * 3) Use -mixlpred- to calculate predicted probabilities in the alternative scenario
          .
          . mixlpred pred1,nrep(200)
          .
          .
          .
          . *4) Calculate the difference between the predicted probabilities in 1)
          . *and 3) and average this difference over individuals. This gives you an
          . *estimate of the marginal effect.
          .
          . * in step 4) you should calculate the percentage change in the probabilities, instead of the difference.
          
          . generate elast=((pred1-pred0)/pred0)/(.01)
          Finally, get average elasticity by using -summarize-

          Code:
          .
          . summ elast
          
              Variable |       Obs        Mean    Std. Dev.       Min        Max
          -------------+--------------------------------------------------------
                 elast |      2190   -.1833987    .3490297  -1.115784   .3557601
          Attached Files
          Last edited by Hawa Harahap; 10 Dec 2015, 15:33.

          Comment


          • #6
            That's not quite right, as you typically want to increase e.g. the price of one specific alternative, not all of the alternatives. Note also that you should not include indicators of an alternative being chosen as explanatory variables in the model, but you can include alternative-specific constants and their interactions with individual-level characteristics. See the example below which uses the same data set as in your example:

            Code:
            use http://www.stata-press.com/data/mus/mus15data.dta
            
            * Set up data and estimate model
            generate id = _n
            reshape long d p q, i(id) j(fishmode beach pier private charter) string
            
            gen charter = fishmode=="charter"
            gen pier = fishmode=="pier"
            gen private = fishmode=="private"
            
            gen charter_inc = charter*income
            gen pier_inc = pier*income
            gen private_inc = private*income
            
            global xlist q charter pier private charter_inc pier_inc private_inc
            mixlogit d $xlist, group(id) rand(p) nrep(200)
            
            *Calculate direct and cross price elasticities w.r.t. the private mode
            preserve
            mixlpred pred0, nrep(200)
            replace p = p*1.01 if fishmode=="private"
            mixlpred pred1, nrep(200)
            generate elast = 100*(pred1-pred0)/pred0
            
            *Cross elasticity, beach mode
            sum elast if fishmode=="beach"
            
            *Cross elasticity, charter mode
            sum elast if fishmode=="charter"
            
            *Cross elasticity, pier mode
            sum elast if fishmode=="pier"
            
            *Direct elasticity, private mode
            sum elast if fishmode=="private"
            restore

            Comment


            • #7
              OK, thank you, Arne. I thought I was missing something (and I was). I appreciate your help!

              HH

              Comment


              • #8
                I have a follow-up question about standard errors when pweights and clusters are used in estimating mixlogit. Using the same dataset:

                Code:
                *make bogus cluster and pweight variables
                egen cluster=cut(id),group(197)
                gen pweight=abs(rnormal())
                svyset cluster [pweight=pweight]
                
                reshape long d p q, i(id) j(fishmode beach pier private charter) string
                
                gen charter = fishmode=="charter"
                gen pier = fishmode=="pier"
                gen private = fishmode=="private"
                
                gen charter_inc = charter*income
                gen pier_inc = pier*income
                gen private_inc = private*income
                
                global xlist q charter pier private charter_inc pier_inc private_inc
                Add weights and clustering to estimation
                Code:
                mixlogit d $xlist [pw=pweight], group(id) rand(p) nrep(200) robust cluster(cluster)
                Now when we calculate and cross elasticities, should we weight and cluster to get the robust SE? In other words, would svy: mean have to be used instead of -summarize-, or can -summarize- be used as-is, because the weighting and clustering has already been applied to get the parameter estimates?

                For example:
                Code:
                *Calculate direct and cross price elasticities w.r.t. the private mode
                preserve
                mixlpred pred0, nrep(200)
                replace p = p*1.01 if fishmode=="private"
                mixlpred pred1, nrep(200)
                generate elast = 100*(pred1-pred0)/pred0
                
                *Cross elasticity, beach mode
                *sum elast if fishmode=="beach"
                svy: mean elast if fishmode=="beach"
                
                *Cross elasticity, charter mode
                *sum elast if fishmode=="charter"
                svy: mean elast if fishmode=="charter"
                
                *Cross elasticity, pier mode
                *sum elast if fishmode=="pier"
                svy: mean elast if fishmode=="pier"
                
                *Direct elasticity, private mode
                *sum elast if fishmode=="private"
                svy: mean elast if fishmode=="private"
                
                restore

                Comment


                • #9
                  You don't get SEs at all using this approach unfortunately (cluster-adjusted or otherwise). You could use bootstrapping but that's likely to be impractical in most applications given the time it typically takes to estimate mixed logit models.

                  Comment


                  • #10
                    Noted. Thanks again for your help!

                    Comment


                    • #11
                      Following the above post I have a specific question.
                      What if I have in the model an interacted variable with the variable price, p.
                      And I want again to calculate the elasticity. Should I increase the interacted variable 2 besides the variable p?

                      Comment


                      • #12
                        Originally posted by Arne Risa Hole View Post
                        That's not quite right, as you typically want to increase e.g. the price of one specific alternative, not all of the alternatives. Note also that you should not include indicators of an alternative being chosen as explanatory variables in the model, but you can include alternative-specific constants and their interactions with individual-level characteristics. See the example below which uses the same data set as in your example:

                        Code:
                        use http://www.stata-press.com/data/mus/mus15data.dta
                        
                        * Set up data and estimate model
                        generate id = _n
                        reshape long d p q, i(id) j(fishmode beach pier private charter) string
                        
                        gen charter = fishmode=="charter"
                        gen pier = fishmode=="pier"
                        gen private = fishmode=="private"
                        
                        gen charter_inc = charter*income
                        gen pier_inc = pier*income
                        gen private_inc = private*income
                        
                        global xlist q charter pier private charter_inc pier_inc private_inc
                        mixlogit d $xlist, group(id) rand(p) nrep(200)
                        
                        *Calculate direct and cross price elasticities w.r.t. the private mode
                        preserve
                        mixlpred pred0, nrep(200)
                        replace p = p*1.01 if fishmode=="private"
                        mixlpred pred1, nrep(200)
                        generate elast = 100*(pred1-pred0)/pred0
                        
                        *Cross elasticity, beach mode
                        sum elast if fishmode=="beach"
                        
                        *Cross elasticity, charter mode
                        sum elast if fishmode=="charter"
                        
                        *Cross elasticity, pier mode
                        sum elast if fishmode=="pier"
                        
                        *Direct elasticity, private mode
                        sum elast if fishmode=="private"
                        restore
                        Thank you Arne so much for the code. I tried running and have some questions.

                        1. If individual-specific variables are binary or categorical, I can let it interact like price and income in this example?
                        2. Interpretation
                        In the output, as "private" is chosen for direct elasticity, I got the following:

                        Code:
                        sum elast if fishmode=="private"
                        
                            Variable |        Obs        Mean    Std. Dev.       Min        Max
                        -------------+---------------------------------------------------------
                               elast |      1,182   -1.089557    1.058432  -8.242974    1.38986
                        Can I interpret that for 10% price increase in private mode, there will be 108% less demand for private mode itself?

                        3. Is it essential to test the significance of the elasticity in this case, as mixlogit results show that private mode is statistically insignificant and it may impact the direct elasticity?

                        Thank you so much.

                        Comment

                        Working...
                        X