Hi. I am doing a regression based decomposition analysis. This is my code
Code:
global X "Education respondents_current_age Education_husband Resp_age_at_birth wq1 wq3"
regr prenatal_care $X [aw=weight]
sum prenatal_care [aw=weight]
sca m_prenatal_care=r(mean)
sca m_prenatal_care=r(mean)
foreach  x of global X {
qui {
sca b_`x'=_b[`x']
corr rank `x' [aw=weight], c
sca cov_`x'=r(cov_12)
sum `x' [aw=weight]
sca elas_`x'=(b_`x'*r(mean))/m_prenatal_care
sca CI_`x'=2*cov_`x'/r(mean)
sca con_`x'=elas_`x'*CI_`x'
sca prcnt_`x'=(con_`x'/CI_`x')*100
sca prcnt_`x'=(con_`x'/CI_`x')*100
sca prcnt_`x'=(con_`x'/CI_`x')*100

matrix Aaa = nullmat(Aaa) \ ///
(elas_`x', CI_`x', con_`x', prcnt_`x')
}

di "`x' elasticity:", elas_`x'
di "`x' concentration index:", CI_`x'
di "`x' contribution:", con_`x'
di "`x' percentage contribution:", prcnt_`x'
}
matrix rownames Aaa= $X
matrix colnames Aaa = "Elasticity""CI""Absolute""%"
matrix list Aaa, format(%8.4f)
I keep getting the error / not found and then matrix Aaa not found. I have tried to fix it but i am stuck. someone please help me