|
|
|
||||
|
|
|||||
Page 283. The coefficients at the top of the page.
use http://www.ats.ucla.edu/stat/stata/examples/cama4/depress, clear
logit cases age income
Iteration 0: log likelihood = -134.06225
Iteration 1: log likelihood = -127.42024
Iteration 2: log likelihood = -127.01794
Iteration 3: log likelihood = -127.01305
Iteration 4: log likelihood = -127.01304
Logit estimates Number of obs = 294
LR chi2(2) = 14.10
Prob > chi2 = 0.0009
Log likelihood = -127.01304 Pseudo R2 = 0.0526
------------------------------------------------------------------------------
cases | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.0201671 .0088966 -2.27 0.023 -.0376041 -.0027301
income | -.0413479 .0140587 -2.94 0.003 -.0689025 -.0137933
_cons | .0279774 .4872007 0.06 0.954 -.9269184 .9828732
------------------------------------------------------------------------------
Table 12.1, page 285.
tab sex cases
| depressed is cesd >=16
|
sex | normal depressed | Total
-----------+----------------------+----------
male | 101 10 | 111
female | 143 40 | 183
-----------+----------------------+----------
Total | 244 50 | 294
Page 286. The odds ratios at the top of the page.
logit cases sex, or
Iteration 0: log likelihood = -134.06225
Iteration 1: log likelihood = -129.83832
Iteration 2: log likelihood = -129.69929
Iteration 3: log likelihood = -129.69883
Logit estimates Number of obs = 294
LR chi2(1) = 8.73
Prob > chi2 = 0.0031
Log likelihood = -129.69883 Pseudo R2 = 0.0325
------------------------------------------------------------------------------
cases | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
sex | 2.825175 1.064196 2.76 0.006 1.350243 5.911243
------------------------------------------------------------------------------
Page 286. The estimates at the bottom of the page.
gen sex1 = sex - 1
logit cases sex1
Iteration 0: log likelihood = -134.06225
Iteration 1: log likelihood = -129.83832
Iteration 2: log likelihood = -129.69929
Iteration 3: log likelihood = -129.69883
Logit estimates Number of obs = 294
LR chi2(1) = 8.73
Prob > chi2 = 0.0031
Log likelihood = -129.69883 Pseudo R2 = 0.0325
------------------------------------------------------------------------------
cases | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
sex1 | 1.03857 .3766834 2.76 0.006 .3002844 1.776856
_cons | -2.312535 .3315077 -6.98 0.000 -2.962279 -1.662792
------------------------------------------------------------------------------
Page 287. Top of the page.
logit cases age income sex1
Iteration 0: log likelihood = -134.06225
Iteration 1: log likelihood = -124.45941
Iteration 2: log likelihood = -123.78013
Iteration 3: log likelihood = -123.76979
Iteration 4: log likelihood = -123.76979
Logit estimates Number of obs = 294
LR chi2(3) = 20.58
Prob > chi2 = 0.0001
Log likelihood = -123.76979 Pseudo R2 = 0.0768
------------------------------------------------------------------------------
cases | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.0209575 .0090401 -2.32 0.020 -.0386758 -.0032392
income | -.0365635 .0140897 -2.60 0.009 -.0641787 -.0089482
sex1 | .9294487 .3858256 2.41 0.016 .1732444 1.685653
_cons | -.6764559 .5788124 -1.17 0.243 -1.810907 .4579955
------------------------------------------------------------------------------
Page 287. Table of coefficients and standard errors at the bottom.
logit cases age income
Iteration 0: log likelihood = -134.06225
Iteration 1: log likelihood = -127.42024
Iteration 2: log likelihood = -127.01794
Iteration 3: log likelihood = -127.01305
Iteration 4: log likelihood = -127.01304
Logit estimates Number of obs = 294
LR chi2(2) = 14.10
Prob > chi2 = 0.0009
Log likelihood = -127.01304 Pseudo R2 = 0.0526
------------------------------------------------------------------------------
cases | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.0201671 .0088966 -2.27 0.023 -.0376041 -.0027301
income | -.0413479 .0140587 -2.94 0.003 -.0689025 -.0137933
_cons | .0279774 .4872007 0.06 0.954 -.9269184 .9828732
------------------------------------------------------------------------------
Page 288. These numbers are obtained from the output from page 287.
Page 290. Table at the top of the page.
gen duminc = 1
replace duminc = 0 if income >=10
gen dumemp = 0
replace dumemp = 1 if employ == 2 | employ == 3
replace dumemp = . if employ == 7
logit cases duminc dumemp
Iteration 0: log likelihood = -131.73021
Iteration 1: log likelihood = -127.6761
Iteration 2: log likelihood = -127.42821
Iteration 3: log likelihood = -127.42796
Logit estimates Number of obs = 290
LR chi2(2) = 8.60
Prob > chi2 = 0.0135
Log likelihood = -127.42796 Pseudo R2 = 0.0327
------------------------------------------------------------------------------
cases | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
duminc | .2722943 .3376895 0.81 0.420 -.3895651 .9341536
dumemp | 1.028483 .3487117 2.95 0.003 .3450204 1.711945
_cons | -1.934537 .2259083 -8.56 0.000 -2.377309 -1.491765
------------------------------------------------------------------------------
Page 291. Table in the middle of the page.
gen dincemp = duminc*dumemp
logit cases duminc dumemp dincemp
Iteration 0: log likelihood = -131.73021
Iteration 1: log likelihood = -125.18993
Iteration 2: log likelihood = -123.52872
Iteration 3: log likelihood = -123.31292
Iteration 4: log likelihood = -123.31287
Logit estimates Number of obs = 290
LR chi2(3) = 16.83
Prob > chi2 = 0.0008
Log likelihood = -123.31287 Pseudo R2 = 0.0639
------------------------------------------------------------------------------
cases | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
duminc | -.3756121 .4349381 -0.86 0.388 -1.228075 .4768508
dumemp | .317535 .4520206 0.70 0.482 -.5684091 1.203479
dincemp | 2.198143 .7888294 2.79 0.005 .6520661 3.74422
_cons | -1.734601 .2214037 -7.83 0.000 -2.168544 -1.300658
------------------------------------------------------------------------------
Page 292. Bottom of the page.
di 2.198143/.7888294
2.7865886
di (2.7865886)^2
7.765076
logit cases duminc dumemp
Iteration 0: log likelihood = -131.73021
Iteration 1: log likelihood = -127.6761
Iteration 2: log likelihood = -127.42821
Iteration 3: log likelihood = -127.42796
Logit estimates Number of obs = 290
LR chi2(2) = 8.60
Prob > chi2 = 0.0135
Log likelihood = -127.42796 Pseudo R2 = 0.0327
------------------------------------------------------------------------------
cases | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
duminc | .2722943 .3376895 0.81 0.420 -.3895651 .9341536
dumemp | 1.028483 .3487117 2.95 0.003 .3450204 1.711945
_cons | -1.934537 .2259083 -8.56 0.000 -2.377309 -1.491765
------------------------------------------------------------------------------
logit cases duminc dumemp dincemp
Iteration 0: log likelihood = -131.73021
Iteration 1: log likelihood = -125.18993
Iteration 2: log likelihood = -123.52872
Iteration 3: log likelihood = -123.31292
Iteration 4: log likelihood = -123.31287
Logit estimates Number of obs = 290
LR chi2(3) = 16.83
Prob > chi2 = 0.0008
Log likelihood = -123.31287 Pseudo R2 = 0.0639
------------------------------------------------------------------------------
cases | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
duminc | -.3756121 .4349381 -0.86 0.388 -1.228075 .4768508
dumemp | .317535 .4520206 0.70 0.482 -.5684091 1.203479
dincemp | 2.198143 .7888294 2.79 0.005 .6520661 3.74422
_cons | -1.734601 .2214037 -7.83 0.000 -2.168544 -1.300658
------------------------------------------------------------------------------
di 16.83-8.6
8.23
Page 298. Middle of the page.
gen age0 = 0
replace age0 = 1 if age < 28
gen age1 = 0
replace age1 = 1 if age >=28 & age <= 42
gen age2 = 0
replace age2 = 1 if age >=43 & age <= 58
gen age3 = 0
replace age3 = 1 if age >=59 & age <= 89
logit cases age1 age2 age3 income sex
Iteration 0: log likelihood = -134.06225
Iteration 1: log likelihood = -124.33006
Iteration 2: log likelihood = -123.58989
Iteration 3: log likelihood = -123.57661
Iteration 4: log likelihood = -123.57661
Logit estimates Number of obs = 294
LR chi2(5) = 20.97
Prob > chi2 = 0.0008
Log likelihood = -123.57661 Pseudo R2 = 0.0782
------------------------------------------------------------------------------
cases | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age1 | .0747259 .4318019 0.17 0.863 -.7715902 .9210421
age2 | -.5706276 .4743977 -1.20 0.229 -1.50043 .3591747
age3 | -.8853103 .4563059 -1.94 0.052 -1.779654 .0090329
income | -.0379521 .014852 -2.56 0.011 -.0670616 -.0088426
sex | .9238035 .3864416 2.39 0.017 .1663919 1.681215
_cons | -2.159495 .7830424 -2.76 0.006 -3.69423 -.6247601
------------------------------------------------------------------------------
Figure 12.2, page 299.
gen female = (sex == 2)
logit cases age1 age2 age3 income female
matrix b = e(b)
gen b0 = 0 in 1
svmat b
list b0 - b6 in 1
* The point of the next two commands is to drop all of the
* unnecessary variables and observations. You may need to
* modify the variable names on the drop command to match
* your variables.
drop sex - age3
drop in 2/l
reshape long b, i(id)
list
gen newage = 22.5
replace newage = 35 if _j == 1
replace newage = 50.5 if _j == 2
replace newage = 74 if _j == 3
* You need to calculate the midpoint of each interval based on the
* table on page 298. The minimum of age is 18.
graph twoway scatter b newage in 1/4, msymbol(O) connect(L) ylabel(-1(.5)0, nogrid) ///
ytitle(Coefficient b) xlabel(20(10)80) xtitle(Age)
Figure 12.3, page 302.
use http://www.ats.ucla.edu/stat/stata/examples/cama4/depress, clear logit cases sex income age predict p predict db, db graph twoway scatter db p
Table 12.2, page 303.
logit cases age income sex
Iteration 0: log likelihood = -134.06225
Iteration 1: log likelihood = -124.45941
Iteration 2: log likelihood = -123.78013
Iteration 3: log likelihood = -123.76979
Iteration 4: log likelihood = -123.76979
Logit estimates Number of obs = 294
LR chi2(3) = 20.58
Prob > chi2 = 0.0001
Log likelihood = -123.76979 Pseudo R2 = 0.0768
------------------------------------------------------------------------------
cases | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.0209575 .0090401 -2.32 0.020 -.0386758 -.0032392
income | -.0365635 .0140897 -2.60 0.009 -.0641787 -.0089482
sex | .9294487 .3858256 2.41 0.016 .1732444 1.685653
_cons | -1.605905 .8465372 -1.90 0.058 -3.265087 .0532779
------------------------------------------------------------------------------
list db in -4/l
+----------+
| db |
|----------|
291. | .0004829 |
292. | .0001442 |
293. | .0006498 |
294. | .0111896 |
+----------+
gen x = 0
replace x = 3 if db > .1637310
(5 real changes made)
replace x = 2 if db > .1789604
(4 real changes made)
replace x = 1 if db > .2084397
(3 real changes made)
logit cases age income sex if x ~= 1
Iteration 0: log likelihood = -131.91495
Iteration 1: log likelihood = -121.29438
Iteration 2: log likelihood = -120.39934
Iteration 3: log likelihood = -120.3796
Iteration 4: log likelihood = -120.37958
Logit estimates Number of obs = 291
LR chi2(3) = 23.07
Prob > chi2 = 0.0000
Log likelihood = -120.37958 Pseudo R2 = 0.0874
------------------------------------------------------------------------------
cases | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.0215037 .0091147 -2.36 0.018 -.0393683 -.0036391
income | -.0416866 .0149928 -2.78 0.005 -.071072 -.0123013
sex | 1.022995 .4007114 2.55 0.011 .2376152 1.808375
_cons | -1.692541 .8721181 -1.94 0.052 -3.401861 .016779
------------------------------------------------------------------------------
logit cases age income sex if x ~= 2
Iteration 0: log likelihood = -132.28233
Iteration 1: log likelihood = -121.82603
Iteration 2: log likelihood = -121.03222
Iteration 3: log likelihood = -121.01885
Iteration 4: log likelihood = -121.01885
Logit estimates Number of obs = 293
LR chi2(3) = 22.53
Prob > chi2 = 0.0001
Log likelihood = -121.01885 Pseudo R2 = 0.0851
------------------------------------------------------------------------------
cases | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.023414 .0092536 -2.53 0.011 -.0415507 -.0052774
income | -.0357778 .0141515 -2.53 0.011 -.0635142 -.0080415
sex | 1.050539 .4007857 2.62 0.009 .2650138 1.836065
_cons | -1.756961 .871175 -2.02 0.044 -3.464433 -.0494895
------------------------------------------------------------------------------
logit cases age income sex if x ~= 3
Iteration 0: log likelihood = -132.28233
Iteration 1: log likelihood = -121.54471
Iteration 2: log likelihood = -120.67498
Iteration 3: log likelihood = -120.65779
Iteration 4: log likelihood = -120.65778
Logit estimates Number of obs = 293
LR chi2(3) = 23.25
Prob > chi2 = 0.0000
Log likelihood = -120.65778 Pseudo R2 = 0.0879
------------------------------------------------------------------------------
cases | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.0228888 .0092002 -2.49 0.013 -.0409209 -.0048567
income | -.0389067 .0145405 -2.68 0.007 -.0674056 -.0104078
sex | 1.04192 .4008515 2.60 0.009 .2562651 1.827574
_cons | -1.71381 .8720871 -1.97 0.049 -3.423069 -.0045506
------------------------------------------------------------------------------
logit cases age income sex if x == 0
Iteration 0: log likelihood = -128.31745
Iteration 1: log likelihood = -115.44875
Iteration 2: log likelihood = -114.1166
Iteration 3: log likelihood = -114.074
Iteration 4: log likelihood = -114.07392
Logit estimates Number of obs = 289
LR chi2(3) = 28.49
Prob > chi2 = 0.0000
Log likelihood = -114.07392 Pseudo R2 = 0.1110
------------------------------------------------------------------------------
cases | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | -.0262663 .0095311 -2.76 0.006 -.0449469 -.0075856
income | -.0439743 .015642 -2.81 0.005 -.074632 -.0133166
sex | 1.30267 .4406845 2.96 0.003 .4389443 2.166396
_cons | -2.018118 .9403468 -2.15 0.032 -3.861163 -.1750718
------------------------------------------------------------------------------
Table 12.3, page 304.
list age income sex cases p if id == 288 | id==99 | id==143 | id == 232 | id == 68
+---------------------------------------+
| age income sex cases p |
|---------------------------------------|
68. | 40 45 1 1 .0406946 |
99. | 72 11 1 1 .069941 |
143. | 40 45 1 0 .0406946 |
232. | 40 45 1 0 .0406946 |
288. | 61 28 1 1 .0484001 |
+---------------------------------------+
Figure 12.4, page 305.
logit cases sex income age
Iteration 0: log likelihood = -134.06225
Iteration 1: log likelihood = -124.45941
Iteration 2: log likelihood = -123.78013
Iteration 3: log likelihood = -123.76979
Iteration 4: log likelihood = -123.76979
Logit estimates Number of obs = 294
LR chi2(3) = 20.58
Prob > chi2 = 0.0001
Log likelihood = -123.76979 Pseudo R2 = 0.0768
------------------------------------------------------------------------------
cases | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
sex | .9294487 .3858256 2.41 0.016 .1732444 1.685653
income | -.0365635 .0140897 -2.60 0.009 -.0641787 -.0089482
age | -.0209575 .0090401 -2.32 0.020 -.0386758 -.0032392
_cons | -1.605905 .8465372 -1.90 0.058 -3.265087 .0532779
------------------------------------------------------------------------------
predict dx2, dx2
graph twoway scatter dx2 p [w = db], msymbol(Oh) ylabel(0(5)25, nogrid) xlabel(0(.1).5)
Figure 12.5, page 307.
lsens
Figure 12.6, page 307.
lroc
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