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.
-
Login or Register
- Log in with
. 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 | +------------------------------------------------------------------------------------------+
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
. ** 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
. * 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)
. . summ elast Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- elast | 2190 -.1833987 .3490297 -1.115784 .3557601
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
*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
mixlogit d $xlist [pw=pweight], group(id) rand(p) nrep(200) robust cluster(cluster)
*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
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
sum elast if fishmode=="private" Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- elast | 1,182 -1.089557 1.058432 -8.242974 1.38986
Comment