2.CI分解,来源于世银的书,书名《Analyzing Health Equity Using Household Survey Data》,第十三章有详细的代码。
global X gender brithday marrystatus workstatus surrending healthselfassessment area edu insurence chronic disease iadls badls
qui sum noh1 [aw=weight]
sca m_y=r(mean)
qui regr noh1 $X [aw=weight] //
qui margins , dydx(*) post
foreach x of varlist $X {
sca b_`x'=_b[`x']
}
foreach x of varlist $X {
{
conindex `x' [pw=INDV_weight], rank(perspend1) truezero
sca CI_`x' = r(CI)
sum `x' [aw=weight]
sca elas_`x' = 4*(b_`x' * r(mean))
sca contri_`x' = elas_`x' * CI_`x'
sca prcnt_`x' = (contri_`x'/CI)*100
}
di "`x' elasticity:", elas_`x'
di "`x' concentration index:", CI_`x'
di "`x' contribution:", contri_`x'
di "`x' percentage contribution:", prcnt_`x'
}