|
|
|
||||
|
Stat Computing > Seminars
> LogStata
|
|
||||
The purpose of this seminar is to help you increase your skills in using logistic regression analysis with Stata. The seminar does not teach logistic regression, per se, but focuses on how to perform logistic regression analyses and interpret the results using Stata. It is assumed that you are familiar with Logistic Regression (e.g. have had a class in logistic regression or have read about logistic regression, see our Statistics Books for Loan for books you can borrow on logistic regression).
In addition to the built-in Stata commands we will be demonstrating the use of a number on user-written ado's, in particular, listcoef, fitstat, prchange, prtab, prgen, etc. To find out more about these programs or to download them type findit followed by the program name in the Stata command window (example: findit listcoef). These add-on programs ease the running and interpretation of ordinal logistic models. Or, you can download the complete spostado package by typing the following in the Stata command window.:
net from http://www.indiana.edu/~jslsoc/stata/ net install spost9_ado
We will use the hsb2 dataset. It doesn't have a binary response variable so we will create one. The variable hiwrite will indicate students with writing scores greater than or equal to 52. We will looks at some descriptive statistics before we begin our first logistic regression model.
use http://www.ats.ucla.edu/stat/stata/notes/hsb2, clear
generate hiwrite = write>=52
describe hiwrite read female prog
storage display value
variable name type format label variable label
-------------------------------------------------------------------------------
hiwrite float %9.0g
read float %9.0g reading score
female float %9.0g fl
prog float %9.0g sel type of program
summarize hiwrite read female prog
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
hiwrite | 200 .63 .4840159 0 1
read | 200 52.23 10.25294 28 76
female | 200 .545 .4992205 0 1
prog | 200 2.025 .6904772 1 3
tab1 hiwrite female prog
-> tabulation of hiwrite
hiwrite | Freq. Percent Cum.
------------+-----------------------------------
0 | 74 37.00 37.00
1 | 126 63.00 100.00
------------+-----------------------------------
Total | 200 100.00
-> tabulation of female
female | Freq. Percent Cum.
------------+-----------------------------------
male | 91 45.50 45.50
female | 109 54.50 100.00
------------+-----------------------------------
Total | 200 100.00
-> tabulation of prog
type of |
program | Freq. Percent Cum.
------------+-----------------------------------
general | 45 22.50 22.50
academic | 105 52.50 75.00
vocation | 50 25.00 100.00
------------+-----------------------------------
Total | 200 100.00
xi: logit hiwrite read female i.prog
i.prog _Iprog_1-3 (naturally coded; _Iprog_1 omitted)
Iteration 0: log likelihood = -131.79114
Iteration 1: log likelihood = -91.787685
Iteration 2: log likelihood = -87.382389
Iteration 3: log likelihood = -87.017358
Iteration 4: log likelihood = -87.013521
Iteration 5: log likelihood = -87.013521
Logit estimates Number of obs = 200
LR chi2(4) = 89.56
Prob > chi2 = 0.0000
Log likelihood = -87.013521 Pseudo R2 = 0.3398
------------------------------------------------------------------------------
hiwrite | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
read | .1504846 .0269589 5.58 0.000 .0976462 .2033231
female | 1.775335 .4176567 4.25 0.000 .9567429 2.593927
_Iprog_2 | .5915962 .4600557 1.29 0.198 -.3100963 1.493289
_Iprog_3 | -.8139846 .5073391 -1.60 0.109 -1.808351 .1803819
_cons | -8.053889 1.468961 -5.48 0.000 -10.933 -5.174778
------------------------------------------------------------------------------
estimates store M1
/* Wald test */
test _Iprog_2 _Iprog_3
( 1) _Iprog_2 = 0
( 2) _Iprog_3 = 0
chi2( 2) = 9.03
Prob > chi2 = 0.0110
/* Likelihood ratio-test */
logit hiwrite read female, nolog
Logit estimates Number of obs = 200
LR chi2(2) = 80.17
Prob > chi2 = 0.0000
Log likelihood = -91.703855 Pseudo R2 = 0.3042
------------------------------------------------------------------------------
hiwrite | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
read | .1656448 .0259864 6.37 0.000 .1147124 .2165771
female | 1.667059 .3962125 4.21 0.000 .8904968 2.443621
_cons | -8.700539 1.388431 -6.27 0.000 -11.42181 -5.979264
------------------------------------------------------------------------------
lrtest M1
likelihood-ratio test LR chi2(2) = 9.38
(Assumption: . nested in M1) Prob > chi2 = 0.0092
/* rerun full model */
xi: logit hiwrite read female i.prog, nolog /* displays coefficients */
i.prog _Iprog_1-3 (naturally coded; _Iprog_1 omitted)
Logit estimates Number of obs = 200
LR chi2(4) = 89.56
Prob > chi2 = 0.0000
Log likelihood = -87.013521 Pseudo R2 = 0.3398
------------------------------------------------------------------------------
hiwrite | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
read | .1504846 .0269589 5.58 0.000 .0976462 .2033231
female | 1.775335 .4176567 4.25 0.000 .9567429 2.593927
_Iprog_2 | .5915962 .4600557 1.29 0.198 -.3100963 1.493289
_Iprog_3 | -.8139846 .5073391 -1.60 0.109 -1.808351 .1803819
_cons | -8.053889 1.468961 -5.48 0.000 -10.933 -5.174778
------------------------------------------------------------------------------
xi: logistic hiwrite read female i.prog, nolog /* displays odds ratios */
i.prog _Iprog_1-3 (naturally coded; _Iprog_1 omitted)
Logistic regression Number of obs = 200
LR chi2(4) = 89.56
Prob > chi2 = 0.0000
Log likelihood = -87.013521 Pseudo R2 = 0.3398
------------------------------------------------------------------------------
hiwrite | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
read | 1.162397 .0313369 5.58 0.000 1.102573 1.225468
female | 5.902258 2.465117 4.25 0.000 2.603204 13.38222
_Iprog_2 | 1.80687 .831261 1.29 0.198 .7333763 4.451712
_Iprog_3 | .443089 .2247964 -1.60 0.109 .1639242 1.197675
------------------------------------------------------------------------------
Now we will demonstrate some of the utilities developed by J. Scott Long & Jeremy Freese.
listcoef
logistic (N=200): Factor Change in Odds
Odds of: 1 vs 0
----------------------------------------------------------------------
hiwrite | b z P>|z| e^b e^bStdX SDofX
-------------+--------------------------------------------------------
read | 0.15048 5.582 0.000 1.1624 4.6782 10.2529
female | 1.77533 4.251 0.000 5.9023 2.4261 0.4992
_Iprog_2 | 0.59160 1.286 0.198 1.8069 1.3447 0.5006
_Iprog_3 | -0.81398 -1.604 0.109 0.4431 0.7023 0.4341
----------------------------------------------------------------------
listcoef, percent
logistic (N=200): Percentage Change in Odds
Odds of: 1 vs 0
----------------------------------------------------------------------
hiwrite | b z P>|z| % %StdX SDofX
-------------+--------------------------------------------------------
read | 0.15048 5.582 0.000 16.2 367.8 10.2529
female | 1.77533 4.251 0.000 490.2 142.6 0.4992
_Iprog_2 | 0.59160 1.286 0.198 80.7 34.5 0.5006
_Iprog_3 | -0.81398 -1.604 0.109 -55.7 -29.8 0.4341
----------------------------------------------------------------------
fitstat
Measures of Fit for logistic of hiwrite
Log-Lik Intercept Only: -131.791 Log-Lik Full Model: -87.014
D(195): 174.027 LR(4): 89.555
Prob > LR: 0.000
McFadden's R2: 0.340 McFadden's Adj R2: 0.302
Maximum Likelihood R2: 0.361 Cragg & Uhler's R2: 0.493
McKelvey and Zavoina's R2: 0.556 Efron's R2: 0.384
Variance of y*: 7.403 Variance of error: 3.290
Count R2: 0.775 Adj Count R2: 0.392
AIC: 0.920 AIC*n: 184.027
BIC: -859.145 BIC': -68.362
Another fit indicator is the Hosmer & Lemeshow goodness-of-fit given by the lfit
command which is part of Stata.
lfit, group(10)
Logistic model for hiwrite, goodness-of-fit test
(Table collapsed on quantiles of estimated probabilities)
number of observations = 200
number of groups = 10
Hosmer-Lemeshow chi2(8) = 7.08
Prob > chi2 = 0.5279
Let's look at some logistic regression diagnostics.
predict pprob /* predicted probabilities */ predict r, resid /* pearson residulas */ predict h, hat /* leverage*/ predict db, dbeta /* pregobon dbeta */ predict dx2, dx2 /* hosmer & lemeshow influence */ scatter h r, xline(0) msym(Oh) jitter(2)Some researchers find log-odds and odds ratios difficult to interpret and prefer to interpret their results in terms of predicted probabilities.twoway (scatter dx2 pprob if hiwrite, msym(Oh) jitter(2)) /// (scatter dx2 pprob if ~hiwrite, msym(Oh) jitter(2))
scatter dx2 pprob if hiwrite [w=db], msym(Oh) jitter(2)
summarize pprob Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- pprob | 200 .63 .3032638 .0147326 .9968269 histogram pprob (bin=14, start=.01473261, width=.0701496)
list hiwrite pprob in 1/30
+--------------------+
| hiwrite pprob |
|--------------------|
1. | 1 .6280209 |
2. | 1 .9585295 |
3. | 0 .1926994 |
4. | 0 .6485471 |
5. | 1 .4038342 |
|--------------------|
6. | 1 .3013308 |
7. | 1 .3705969 |
8. | 0 .087399 |
9. | 1 .8063778 |
10. | 1 .7531218 |
|--------------------|
11. | 0 .5402142 |
12. | 1 .7531218 |
13. | 1 .9713376 |
14. | 1 .660131 |
15. | 1 .3339254 |
|--------------------|
16. | 0 .1501361 |
17. | 1 .4038342 |
18. | 1 .6280209 |
19. | 1 .9410698 |
20. | 0 .5554624 |
|--------------------|
21. | 0 .8063778 |
22. | 1 .6485471 |
23. | 0 .5154799 |
24. | 1 .8273249 |
25. | 0 .0355732 |
|--------------------|
26. | 0 .0229461 |
27. | 1 .9104555 |
28. | 1 .1424491 |
29. | 0 .3013308 |
30. | 0 .443076 |
+--------------------+
Here is another utility (leastlikely) by Jeremy Freese that is not part of
the spostado package.
leastlikely hiwrite read female prog
Outcome: 0
+-----------------------------------------------+
| Prob hiwrite read female prog |
|-----------------------------------------------|
69. | .1173011 0 63 male academic |
127. | .137374 0 50 female academic |
140. | .105435 0 52 female academic |
162. | .0526169 0 57 female academic |
190. | .137374 0 50 female academic |
|-----------------------------------------------|
198. | .0912 0 57 female general |
+-----------------------------------------------+
Outcome: 1
+-----------------------------------------------+
| Prob hiwrite read female prog |
|-----------------------------------------------|
6. | .3013308 1 44 male academic |
28. | .1424491 1 47 male vocation |
134. | .3160069 1 42 female vocation |
158. | .3160069 1 42 female vocation |
191. | .3160069 1 42 female vocation |
|-----------------------------------------------|
192. | .2971081 1 36 female general |
+-----------------------------------------------+
prchange
logit: Changes in Predicted Probabilities for hiwrite
min->max 0->1 -+1/2 -+sd/2 MargEfct
read 0.9293 0.0002 0.0312 0.3119 0.0312
female 0.3657 0.3657 0.3560 0.1822 0.3678
_Iprog_2 0.1229 0.1229 0.1221 0.0613 0.1226
_Iprog_3 -0.1801 -0.1801 -0.1675 -0.0731 -0.1686
0 1
Pr(y|x) 0.2931 0.7069
read female _Iprog_2 _Iprog_3
x= 52.23 .545 .525 .25
sd(x)= 10.2529 .49922 .500628 .434099
prchange, fromto
logit: Changes in Predicted Probabilities for hiwrite
from: to: dif: from: to: dif: from: to: dif:
x=min x=max min->max x=0 x=1 0->1 x-1/2 x+1/2 -+1/2
read 0.0592 0.9885 0.9293 0.0009 0.0011 0.0002 0.6911 0.7223 0.0312
female 0.4783 0.8440 0.3657 0.4783 0.8440 0.3657 0.4982 0.8542 0.3560
_Iprog_2 0.6388 0.7616 0.1229 0.6388 0.7616 0.1229 0.6422 0.7643 0.1221
_Iprog_3 0.7473 0.5671 -0.1801 0.7473 0.5671 -0.1801 0.7837 0.6162 -0.1675
from: to: dif:
x-1/2sd x+1/2sd -+sd/2 MargEfct
read 0.5273 0.8392 0.3119 0.0312
female 0.6076 0.7898 0.1822 0.3678
_Iprog_2 0.6754 0.7367 0.0613 0.1226
_Iprog_3 0.7422 0.6691 -0.0731 -0.1686
0 1
Pr(y|x) 0.2931 0.7069
read female _Iprog_2 _Iprog_3
x= 52.23 .545 .525 .25
sd(x)= 10.2529 .49922 .500628 .434099
prchange, x(_Iprog_2=0 _Iprog_3=0)
logit: Changes in Predicted Probabilities for hiwrite
min->max 0->1 -+1/2 -+sd/2 MargEfct
read 0.9337 0.0001 0.0325 0.3237 0.0325
female 0.3778 0.3778 0.3689 0.1896 0.3835
_Iprog_2 0.1123 0.1123 0.1273 0.0639 0.1278
_Iprog_3 -0.1944 -0.1944 -0.1744 -0.0762 -0.1759
0 1
Pr(y|x) 0.3157 0.6843
read female _Iprog_2 _Iprog_3
x= 52.23 .545 0 0
sd(x)= 10.2529 .49922 .500628 .434099
prchange, x(_Iprog_2=1 _Iprog_3=0)
logit: Changes in Predicted Probabilities for hiwrite
min->max 0->1 -+1/2 -+sd/2 MargEfct
read 0.9002 0.0002 0.0244 0.2502 0.0244
female 0.2997 0.2997 0.2878 0.1437 0.2877
_Iprog_2 0.1123 0.1123 0.0959 0.0480 0.0959
_Iprog_3 -0.1622 -0.1622 -0.1320 -0.0573 -0.1319
0 1
Pr(y|x) 0.2034 0.7966
read female _Iprog_2 _Iprog_3
x= 52.23 .545 1 0
sd(x)= 10.2529 .49922 .500628 .434099
prchange, x(_Iprog_2=0 _Iprog_3=1)
logit: Changes in Predicted Probabilities for hiwrite
min->max 0->1 -+1/2 -+sd/2 MargEfct
read 0.9473 0.0001 0.0376 0.3675 0.0376
female 0.4156 0.4156 0.4167 0.2179 0.4437
_Iprog_2 0.1445 0.1445 0.1468 0.0739 0.1478
_Iprog_3 -0.1944 -0.1944 -0.2007 -0.0881 -0.2034
0 1
Pr(y|x) 0.5101 0.4899
read female _Iprog_2 _Iprog_3
x= 52.23 .545 0 1
sd(x)= 10.2529 .49922 .500628 .434099
prvalue, x(female=0 _Iprog_2=1 _Iprog_3=0) rest(mean)
logit: Predictions for hiwrite
Pr(y=1|x): 0.5981 95% ci: (0.4424,0.7362)
Pr(y=0|x): 0.4019 95% ci: (0.2638,0.5576)
read female _Iprog_2 _Iprog_3
x= 52.23 0 1 0
prtab read
logit: Predicted probabilities of positive outcome for hiwrite
----------------------
reading |
score | Prediction
----------+-----------
28 | 0.0592
31 | 0.0900
34 | 0.1344
35 | 0.1529
36 | 0.1734
37 | 0.1960
39 | 0.2478
41 | 0.3080
42 | 0.3410
43 | 0.3756
44 | 0.4115
45 | 0.4483
46 | 0.4858
47 | 0.5234
48 | 0.5607
50 | 0.6330
52 | 0.6997
53 | 0.7304
54 | 0.7589
55 | 0.7854
57 | 0.8318
60 | 0.8859
61 | 0.9003
63 | 0.9242
65 | 0.9428
66 | 0.9504
68 | 0.9628
71 | 0.9760
73 | 0.9821
76 | 0.9885
----------------------
read female _Iprog_2 _Iprog_3
x= 52.23 .545 .525 .25
prtab read female
logit: Predicted probabilities of positive outcome for hiwrite
--------------------------
reading | female
score | male female
----------+---------------
28 | 0.0234 0.1237
31 | 0.0362 0.1815
34 | 0.0557 0.2583
35 | 0.0642 0.2881
36 | 0.0738 0.3199
37 | 0.0848 0.3535
39 | 0.1113 0.4249
41 | 0.1447 0.4996
42 | 0.1643 0.5372
43 | 0.1860 0.5743
44 | 0.2099 0.6106
45 | 0.2360 0.6457
46 | 0.2642 0.6794
47 | 0.2944 0.7112
48 | 0.3266 0.7411
50 | 0.3959 0.7946
52 | 0.4696 0.8394
53 | 0.5072 0.8587
54 | 0.5447 0.8760
55 | 0.5817 0.8914
57 | 0.6527 0.9173
60 | 0.7469 0.9457
61 | 0.7743 0.9529
63 | 0.8226 0.9647
65 | 0.8623 0.9737
66 | 0.8792 0.9773
68 | 0.9077 0.9831
71 | 0.9392 0.9892
73 | 0.9543 0.9919
76 | 0.9704 0.9949
--------------------------
read female _Iprog_2 _Iprog_3
x= 52.23 .545 .525 .25
prtab read female, x(_Iprog_2=1 _Iprog_3=0)
logit: Predicted probabilities of positive outcome for hiwrite
--------------------------
reading | female
score | male female
----------+---------------
28 | 0.0374 0.1864
31 | 0.0575 0.2647
34 | 0.0874 0.3611
35 | 0.1002 0.3965
36 | 0.1146 0.4330
37 | 0.1307 0.4703
39 | 0.1689 0.5454
41 | 0.2154 0.6184
42 | 0.2420 0.6533
43 | 0.2706 0.6865
44 | 0.3013 0.7180
45 | 0.3339 0.7474
46 | 0.3682 0.7748
47 | 0.4038 0.7999
48 | 0.4405 0.8229
50 | 0.5155 0.8626
52 | 0.5897 0.8946
53 | 0.6256 0.9079
54 | 0.6601 0.9198
55 | 0.6930 0.9302
57 | 0.7531 0.9474
60 | 0.8273 0.9658
61 | 0.8478 0.9705
63 | 0.8827 0.9780
65 | 0.9105 0.9836
66 | 0.9220 0.9859
68 | 0.9411 0.9895
71 | 0.9617 0.9933
73 | 0.9713 0.9950
76 | 0.9816 0.9968
--------------------------
read female _Iprog_2 _Iprog_3
x= 52.23 .545 1 0
prgen read, from(0) to(100) gen(prg1) x(_Iprog_2=0 _Iprog_3=0 female=1) n(11)
prgen read, from(0) to(100) gen(prg2) x(_Iprog_2=1 _Iprog_3=0 female=1) n(11)
prgen read, from(0) to(100) gen(prg3) x(_Iprog_2=0 _Iprog_3=1 female=1) n(11)
graph twoway scatter prg1p1 prg2p1 prg3p1 prg1x, con(l l l) msym(O D S)

In the next section we will by using the commands xi3 and postgr3 developed by Michael
Mitchell of ATS. You can obtain these commands by typing findit xi3 and findit postgr3
at the Stata command line.
Note these also require the spostado package by typing findit spostado.xi3: logit hiwrite read female i.prog
i.prog _Iprog_1-3 (naturally coded; _Iprog_1 omitted)
Iteration 0: log likelihood = -131.79114
Iteration 1: log likelihood = -91.787685
Iteration 2: log likelihood = -87.382389
Iteration 3: log likelihood = -87.017358
Iteration 4: log likelihood = -87.013521
Iteration 5: log likelihood = -87.013521
Logit estimates Number of obs = 200
LR chi2(4) = 89.56
Prob > chi2 = 0.0000
Log likelihood = -87.013521 Pseudo R2 = 0.3398
------------------------------------------------------------------------------
hiwrite | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
read | .1504846 .0269589 5.58 0.000 .0976462 .2033231
female | 1.775335 .4176567 4.25 0.000 .9567429 2.593927
_Iprog_2 | .5915962 .4600557 1.29 0.198 -.3100963 1.493289
_Iprog_3 | -.8139846 .5073391 -1.60 0.109 -1.808351 .1803819
_cons | -8.053889 1.468961 -5.48 0.000 -10.933 -5.174778
------------------------------------------------------------------------------
postgr3 read, by(prog) x(female=1)

Next, we will demonstrate some alternative coding systems using xi3.
xi: logit hiwrite i.ses
i.ses _Ises_1-3 (naturally coded; _Ises_1 omitted)
Iteration 0: log likelihood = -131.79114
Iteration 1: log likelihood = -126.42346
Iteration 2: log likelihood = -126.38058
Iteration 3: log likelihood = -126.38056
Logit estimates Number of obs = 200
LR chi2(2) = 10.82
Prob > chi2 = 0.0045
Log likelihood = -126.38056 Pseudo R2 = 0.0411
------------------------------------------------------------------------------
hiwrite | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_Ises_2 | .6218519 .3608067 1.72 0.085 -.0853163 1.32902
_Ises_3 | 1.369547 .4296508 3.19 0.001 .5274464 2.211647
_cons | -.1278334 .2923261 -0.44 0.662 -.700782 .4451152
------------------------------------------------------------------------------
test _Ises_2 _Ises_3
( 1) _Ises_2 = 0
( 2) _Ises_3 = 0
chi2( 2) = 10.16
Prob > chi2 = 0.0062
xi3: logit hiwrite o.ses
o.ses _Ises_1-3 (_Ises_3 for ses==3 omitted)
Iteration 0: log likelihood = -131.79114
Iteration 1: log likelihood = -126.42346
Iteration 2: log likelihood = -126.38058
Iteration 3: log likelihood = -126.38056
Logit estimates Number of obs = 200
LR chi2(2) = 10.82
Prob > chi2 = 0.0045
Log likelihood = -126.38056 Pseudo R2 = 0.0411
------------------------------------------------------------------------------
hiwrite | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_Ises_1 | .4970091 .1561627 3.18 0.001 .1909359 .8030823
_Ises_2 | .0313389 .1501452 0.21 0.835 -.2629404 .3256181
_cons | .5647148 .1521475 3.71 0.000 .2665112 .8629183
------------------------------------------------------------------------------
describe _Ises_1 _Ises_2
storage display value
variable name type format label variable label
-------------------------------------------------------------------------------
_Ises_1 double %10.0g deg=1 orth. poly. for ses
_Ises_2 double %10.0g deg=2 orth. poly. for ses
test _Ises_1 _Ises_2
( 1) _Ises_1 = 0
( 2) _Ises_2 = 0
chi2( 2) = 10.16
Prob > chi2 = 0.0062
We continue with the use of xi3 with categorical predictors. These models are
logistic equivalents of analysis of variance models. The next example is the logistic
equivalent of a 3-by-2 factorial anova and is followed by the equivalent of a 3-by-2
factorial ancova.
xi3: logit hiwrite g.prog*g.female
g.prog _Iprog_1-3 (naturally coded; _Iprog_1 omitted)
g.female _Ifemale_0-1 (naturally coded; _Ifemale_0 omitted)
Iteration 0: log likelihood = -131.79114
Iteration 1: log likelihood = -108.03058
Iteration 2: log likelihood = -107.54459
Iteration 3: log likelihood = -107.53451
Iteration 4: log likelihood = -107.5345
Logit estimates Number of obs = 200
LR chi2(5) = 48.51
Prob > chi2 = 0.0000
Log likelihood = -107.5345 Pseudo R2 = 0.1841
------------------------------------------------------------------------------
hiwrite | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_Iprog_2 | 1.019718 .3965045 2.57 0.010 .2425836 1.796853
_Iprog_3 | -1.363926 .5229104 -2.61 0.009 -2.388812 -.3390409
_Ifemale_1 | 1.415893 .3839096 3.69 0.000 .6634439 2.168342
_Ipr2Xfe1 | -.6768107 .7930089 -0.85 0.393 -2.23108 .8774582
_Ipr3Xfe1 | 1.399533 1.045821 1.34 0.181 -.6502375 3.449304
_cons | .1850745 .1919548 0.96 0.335 -.19115 .5612989
------------------------------------------------------------------------------
test _Iprog_2 _Iprog_3
( 1) _Iprog_2 = 0
( 2) _Iprog_3 = 0
chi2( 2) = 25.69
Prob > chi2 = 0.0000
test _Ipr2Xfe1 _Ipr3Xfe1
( 1) _Ipr2Xfe1 = 0
( 2) _Ipr3Xfe1 = 0
chi2( 2) = 4.68
Prob > chi2 = 0.0965
postgr3 prog, by(female)
xi3: logit hiwrite g.prog*g.female read
g.prog _Iprog_1-3 (naturally coded; _Iprog_1 omitted)
g.female _Ifemale_0-1 (naturally coded; _Ifemale_0 omitted)
Iteration 0: log likelihood = -131.79114
Iteration 1: log likelihood = -88.489831
Iteration 2: log likelihood = -83.519038
Iteration 3: log likelihood = -82.980688
Iteration 4: log likelihood = -82.970372
Iteration 5: log likelihood = -82.970367
Logit estimates Number of obs = 200
LR chi2(6) = 97.64
Prob > chi2 = 0.0000
Log likelihood = -82.970367 Pseudo R2 = 0.3704
------------------------------------------------------------------------------
hiwrite | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_Iprog_2 | .5592136 .4655076 1.20 0.230 -.3531645 1.471592
_Iprog_3 | -1.114651 .5972121 -1.87 0.062 -2.285165 .0558632
_Ifemale_1 | 2.24037 .4921306 4.55 0.000 1.275812 3.204929
_Ipr2Xfe1 | -1.83987 .9600167 -1.92 0.055 -3.721468 .0417287
_Ipr3Xfe1 | .85677 1.194374 0.72 0.473 -1.484161 3.1977
read | .1637165 .0291826 5.61 0.000 .1065197 .2209134
_cons | -8.04175 1.476084 -5.45 0.000 -10.93482 -5.148679
------------------------------------------------------------------------------
test _Iprog_2 _Iprog_3
( 1) _Iprog_2 = 0
( 2) _Iprog_3 = 0
chi2( 2) = 9.68
Prob > chi2 = 0.0079
test _Ipr2Xfe1 _Ipr3Xfe1
( 1) _Ipr2Xfe1 = 0
( 2) _Ipr3Xfe1 = 0
chi2( 2) = 7.32
Prob > chi2 = 0.0258
postgr3 prog, by(female)
postgr3 prog, by(female) x(read=42)
postgr3 prog, by(female) x(read=62)

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services