logit nt i.S1
est store logm1
esttab logm1, b se(%9.3f)
7 Multilevel- und logit Modelle
7.1 logit
Um die Odds Ratios zu erhalten, müssen wir eform
verwenden:
Iteration 0: log likelihood = -6191.9354
Iteration 1: log likelihood = -6187.5538
Iteration 2: log likelihood = -6187.55
Iteration 3: log likelihood = -6187.55
Logistic regression Number of obs = 20,012
LR chi2(1) = 8.77
Prob > chi2 = 0.0031
Log likelihood = -6187.55 Pseudo R2 = 0.0007
------------------------------------------------------------------------------
nt | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
S1 |
weiblich | .1442729 .0487565 2.96 0.003 .048712 .2398339
_cons | -2.351375 .0353592 -66.50 0.000 -2.420678 -2.282073
------------------------------------------------------------------------------
----------------------------
(1)
nt
----------------------------
nt
1.S1 0
(.)
2.S1 0.144**
(0.049)
_cons -2.351***
(0.035)
----------------------------
N 20012
----------------------------
Standard errors in parentheses
* p<0.05, ** p<0.01, *** p<0.001
eform // eform für Odds Ratios esttab logm1, b se(%9.3f)
(1)
nt
----------------------------
nt
1.S1 1
(.)
2.S1 1.155**
(0.056)
----------------------------
N 20012
----------------------------
Exponentiated coefficients; Standard errors in parentheses
* p<0.05, ** p<0.01, *** p<0.001
Außerdem können wir mit estadd lrtest
direkt den LR-Test in die Tabelle aufnehmen:
logit nt i.S1 if !missing(zpalter)
est store logm1b
logit nt i.S1 zpalter
est store logm2
lrtest logm1b
estadd "lrtest_chi2 LRTest Chi²" lrtest_df lrtest_p) esttab logm*, b se(%9.3f) scalars(
(1) (2)
nt nt
--------------------------------------------
nt
1.S1 0 0
(.) (.)
2.S1 0.142** 0.158**
(0.049) (0.049)
zpalter -0.0108***
(0.002)
_cons -2.350*** -1.854***
(0.035) (0.103)
--------------------------------------------
N 19836 19836
LRTest Chi² 25.46
lrtest_df 1
lrtest_p 0.000000451
--------------------------------------------
Standard errors in parentheses
* p<0.05, ** p<0.01, *** p<0.001
Mit pr2
aic
bic
können wir Modellkennzahlen ausgeben lassen.
esttab logm*, b se(%9.3f) pr2 aic bic
(1)
nt
----------------------------
nt
1.S1 0
(.)
2.S1 0.158**
(0.049)
zpalter -0.0108***
(0.002)
_cons -1.854***
(0.103)
----------------------------
N 19836
LRTest Chi² 25.46
lrtest_df 1
lrtest_p 0.000000451
----------------------------
Standard errors in parentheses
* p<0.05, ** p<0.01, *** p<0.001
Bei margins
müssen wir darauf achten, die Option , post
zu verwenden:
logit nt i.S1 zpalter
dydx(*) post
margins, est store mar_mod2
"b(fmt(a3)) se(fmt(a3)) ci_l(fmt(a3)) ci_u(fmt(a3)) p(fmt(a3))") nonumbers esttab mar_mod2, cells(
b se min95 max95 p
-----------------------------------------------------------------------------
1.S1 0 . 0 0 .
2.S1 0.0133 0.00414 0.00523 0.0214 0.00126
zpalter -0.000911 0.000180 -0.00126 -0.000558 0.000000428
-----------------------------------------------------------------------------
N 19836
-----------------------------------------------------------------------------
Das funktioniert natürlich auch für die predictions mit ,at()
:
est restore logm2
at(zpalter = (18 20(5)65) ) post
margins, est store pred_mod2
"b(fmt(a3)) se(fmt(a3)) ci_l(fmt(a3)) ci_u(fmt(a3)) p(fmt(a3))") nonumbers esttab pred_mod2, cells(
b se min95 max95 p
-----------------------------------------------------------------------------
1._at 0.123 0.00697 0.109 0.136 0
2._at 0.120 0.00644 0.108 0.133 0
3._at 0.115 0.00520 0.105 0.125 0
4._at 0.109 0.00411 0.101 0.117 0
5._at 0.104 0.00318 0.0980 0.110 0
6._at 0.0993 0.00248 0.0944 0.104 0
7._at 0.0945 0.00210 0.0904 0.0987 0
8._at 0.0900 0.00212 0.0859 0.0942 0
9._at 0.0857 0.00243 0.0809 0.0904 0
10._at 0.0815 0.00288 0.0759 0.0872 0
11._at 0.0776 0.00337 0.0710 0.0842 0
-----------------------------------------------------------------------------
N 19836
-----------------------------------------------------------------------------
7.2 Mehrebenenmodelle
transform(ln*: exp(@) exp(@))
um die Werte im Random Part richtig anzuzeigen:
xtmixed F518_SUF i.S1 ||Bula:
est store mmodel
ln*: exp(@) exp(@)) esttab mmodel , transform(
(1)
F518_SUF
----------------------------
F518_SUF
1.S1 0
(.)
2.S1 -1437.4***
(-26.88)
_cons 4123.8***
(41.45)
----------------------------
lns1_1_1
_cons 354.8***
(28.17)
----------------------------
lnsig_e
_cons 3445.8***
(1484.91)
----------------------------
N 16635
----------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001
So können wir die ICC
hinzufügen:
xtmixed F518_SUF i.S1 ||Bula:
estat icc
scalar icc2 = r(icc2)
estadd wide transform(ln*: exp(@) exp(@)) ///
esttab, se varwidth(13) scalars(icc2)
(1)
F518_SUF
------------------------------------------
F518_SUF
1.S1 0 (.)
2.S1 -1437.4*** (53.47)
_cons 4123.8*** (99.48)
------------------------------------------
lns1_1_1
_cons 354.8*** (73.97)
------------------------------------------
lnsig_e
_cons 3445.8*** (18.90)
------------------------------------------
N 16635
icc2 0.0105
------------------------------------------
Standard errors in parentheses
* p<0.05, ** p<0.01, *** p<0.001