I am trying to run the reg
and geting back the coefficient values in Stata
. I did the following. Assume that y
is dependent variable, k
,l
,m
,n
are independent variables, and there is a new variable new
that I created.
loc vars k l m n
reg y `vars'
# I know that I can get back the coefficients using mat list e(b) but I need to
get coefficient of each variable and use it to compute the elasticity (one at a time).
# so, I run the following loop but it doesn't work.
foreach i in vars {
sca coeff`i' = _b[`i'] # main problem here
sca cons = _b[_cons] # main problem here
corr new `i' , c # correlation of new with each independent vars
sca cov_`i' = r(cov_12)
sum `i'
sca elas_`i' = (coeff`i'*r(mean))/10 # elasticity not working
}
Any help in this regard will be highly appreciated.
margins
in Stata 12? Have a look, Stata might be already doing what you want. – Fr.margins
which gives me the same answer. – Metrics