Hi Statalisters,
I have a rather simple question. I am trying to save the estimate from margins after running margins multiple times to evaluate the margins of a 1 unit increase of age for different groups at the mean age of the group being evaluated. For example:
How would I save the dy/dx and the Std. Err.?
Thanks!
I have a rather simple question. I am trying to save the estimate from margins after running margins multiple times to evaluate the margins of a 1 unit increase of age for different groups at the mean age of the group being evaluated. For example:
Code:
use http://www.stata-press.com/data/r13/margex, clear
logistic outcome i.sex c.age##i.group
foreach num of numlist 1/3 {
margins if group==`num', at((mean)age) dydx(age)
}
Results below:
use http://www.stata-press.com/data/r13/margex, clear
(Artificial data for margins)
. logistic outcome i.sex c.age##i.group
Logistic regression Number of obs = 3000
LR chi2(6) = 596.53
Prob > chi2 = 0.0000
Log likelihood = -1067.8068 Pseudo R2 = 0.2183
------------------------------------------------------------------------------
outcome | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
sex |
female | 1.645435 .2217915 3.69 0.000 1.263414 2.142969
age | 1.095059 .0092606 10.74 0.000 1.077058 1.113361
|
group |
2 | .524537 .3500767 -0.97 0.334 .1418022 1.940301
3 | .4550779 .4768744 -0.75 0.452 .0583599 3.548597
|
group#c.age |
2 | 1.001389 .0140286 0.10 0.921 .9742675 1.029266
3 | .9852544 .0255426 -0.57 0.567 .9364425 1.036611
|
_cons | .0037717 .0016669 -12.63 0.000 .0015862 .0089686
------------------------------------------------------------------------------
.
. foreach num of numlist 1/3 {
2. margins if group==`num', at((mean)age) dydx(age)
3. }
Average marginal effects Number of obs = 1199
Model VCE : OIM
Expression : Pr(outcome), predict()
dy/dx w.r.t. : age
at : age = 46.71893 (mean)
------------------------------------------------------------------------------
| Delta-method
| dy/dx Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | .0183786 .0015931 11.54 0.000 .0152562 .021501
------------------------------------------------------------------------------
Average marginal effects Number of obs = 1118
Model VCE : OIM
Expression : Pr(outcome), predict()
dy/dx w.r.t. : age
at : age = 37.9025 (mean)
------------------------------------------------------------------------------
| Delta-method
| dy/dx Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | .0064137 .0006617 9.69 0.000 .0051169 .0077105
------------------------------------------------------------------------------
Average marginal effects Number of obs = 683
Model VCE : OIM
Expression : Pr(outcome), predict()
dy/dx w.r.t. : age
at : age = 30.75549 (mean)
------------------------------------------------------------------------------
| Delta-method
| dy/dx Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | .0013779 .0004068 3.39 0.001 .0005805 .0021753
------------------------------------------------------------------------------
Thanks!

Comment