Code:
corr r `X' [fw=hhw], c
Code:
describe r*
foreach keyword of local keywords { display "`keyword'" lookfor `keyword' local savevars `savevars' `r(varlist)' }
global X "age fem sah hc mob sym"
set trace on . foreach x of global X { 2. qui { 3. scal b_`x' = _b[`x'] 4. corr rank `x' [aw=dw_w6], c 5. sca cov_`x' = r(cov_12) 6. sum `x' [aw=dw_w6] 7. sca elas_`x' = (b_`x'*r(mean)) 8. sca CI_`x' = 8*cov_`x' 9. sca CI_`x' = 2*cov_`x'/r(mean) 10. sca con_`x' = 4*(elas_`x'*CI_`x') 11. sca prcnt_`x' = (con_`x'/CI_`x')*100 12. } 13. di “`x' elasticity:”, elas_`x' 14. di “`x' concentration index:”, CI_`x' 15. di “`x' contribution:”, con_`x' 16. di “`x' percentage contribution:”, prcnt_`x' 17. matrix Aaa = nullmat(Aaa)\/// 18. (elas_`x', CI_`x', con_`x', prcnt_`x') 19. }
`=CI_`x''
sysuse auto, clear cls foreach x of var wei head { qui corr pri `x' sca pearr_`x' = r(rho) scatter pri `x', caption(`=pearr_`x'') di "correlation is `=pearr_`x''" }
`=CI_`x''
sysuse auto, clear cls foreach x of var wei head { qui corr pri `x' sca pearr_`x' = r(rho) scatter pri `x', caption(`=pearr_`x'') di "correlation is `=pearr_`x''" }
* Example generated by -dataex-. To install: ssc install dataex clear input byte y1skc int age byte(fem sah) float(hc mob sym) 0 77 1 1 0 4 1 0 77 0 3 1 2 0 0 89 0 4 1 2 0 0 69 1 4 1 1 0 0 89 1 3 3 1 1 0 79 1 5 1 5 4 0 81 1 2 2 0 1 0 82 0 2 1 2 0 0 81 0 3 1 0 0 0 71 1 2 1 0 0 end label values y1skc dummi label def dummi 0 "Not selected", modify label values age age label values fem gender label def gender 0 "male", modify label def gender 1 "female", modify label values sah rate label def rate 1 "Excellent", modify label def rate 2 "Very good", modify label def rate 3 "Good", modify label def rate 4 "Fair", modify label def rate 5 "Poor", modify
*MEASURING HORIZONTAL EQUITY qui probit y2unskc $X $Z [pw=dw_w6] foreach z of global Z { gen copy_`z’=`z’ qui sum `z’ [aw=dw_w6] replace `z’ = r(mean) } predict yhat foreach z of global Z { replace `z’ = copy_`z’ drop copy_`z’ } sum m_yhat [aw=dw_w6] gen yst = y-yhat + r(mean) *EXPLAINING HORIZONTAL EQUITY dprobit y1skc $X $Z [pw=dw_w6] matrix dfdx=e(dfdx) sca need=0 foreach x of global X{ qui{ mat b_`x' = dfdx[1,"`x'"] sca b_`x' = b_`x'[1,1] corr r `x' [aw=dw_w6], c sca cov_`x' = r(cov_12) sum `x' [aw=dw_w6] sca m_`x' = r(mean) sca elas_`x' = (b_`x'*m_`x')/m_y sca CI_`x' = 2*cov_`x'/m_`x' sca con_`x' = elas_`x'*`=CI_`x'' sca prcnt_`x' = con_`x'/`=CI_`x'' sca need=need+con_`x' } di "`x' elasticity:", elas_`x' di "`x' concentration index:", CI_`x' di "`x' contribution:", con_`x' di "`x' percentage contribution:", prcnt_`x' } di "Inequality due to need factors:", need
* Example generated by -dataex-. To install: ssc install dataex clear qui { input byte y1skc int age byte(fem sah) float(hc mob sym) 0 77 1 1 0 4 1 0 77 0 3 1 2 0 0 89 0 4 1 2 0 0 69 1 4 1 1 0 0 89 1 3 3 1 1 0 79 1 5 1 5 4 0 81 1 2 2 0 1 0 82 0 2 1 2 0 0 81 0 3 1 0 0 0 71 1 2 1 0 0 end label values y1skc dummi label def dummi 0 "Not selected", modify label values age age label values fem gender label def gender 0 "male", modify label def gender 1 "female", modify label values sah rate label def rate 1 "Excellent", modify label def rate 2 "Very good", modify label def rate 3 "Good", modify label def rate 4 "Fair", modify label def rate 5 "Poor", modify } loc xs age fem sah hc mob sym *MEASURING HORIZONTAL EQUITY qui probit y1 `xs' foreach x of loc xs { gen copy_`x'=`x' qui sum `x' replace `x' = r(mean) }
* Example generated by -dataex-. To install: ssc install dataex clear qui { input byte y1skc int age byte(fem sah) float(hc mob sym) 0 77 1 1 0 4 1 0 77 0 3 1 2 0 0 89 0 4 1 2 0 0 69 1 4 1 1 0 0 89 1 3 3 1 1 0 79 1 5 1 5 4 0 81 1 2 2 0 1 0 82 0 2 1 2 0 0 81 0 3 1 0 0 0 71 1 2 1 0 0 end label values y1skc dummi label def dummi 0 "Not selected", modify label values age age label values fem gender label def gender 0 "male", modify label def gender 1 "female", modify label values sah rate label def rate 1 "Excellent", modify label def rate 2 "Very good", modify label def rate 3 "Good", modify label def rate 4 "Fair", modify label def rate 5 "Poor", modify } loc xs age fem sah hc mob sym *MEASURING HORIZONTAL EQUITY qui probit y1 `xs' foreach x of loc xs { gen copy_`x'=`x' qui sum `x' replace `x' = r(mean) }
Comment