log type: text
opened on: 29 Oct 2003, 11:08:32
. set linesize 79
. use "C:\AAA Miker Files\newer web pages\soc_388_notes\death penalty, again.dt
> a", clear
. describe
Contains data from C:\AAA Miker Files\newer web pages\soc_388_notes\death penalty, again.d
> ta
obs: 8
vars: 8 29 Oct 2003 00:08
size: 152 (99.9% of memory free)
-------------------------------------------------------------------------------
storage display value
variable name type format label variable label
-------------------------------------------------------------------------------
count int %8.0g
defendant byte %8.0g race
victim byte %8.0g race
penalty byte %8.0g death
Logit_C float %9.0g Linear prediction
count_plus float %9.0g
_x_1 byte %8.0g defendant==2
_x_2 byte %8.0g victim==2
-------------------------------------------------------------------------------
Sorted by:
. tabulate penalty [fweight=count]
penalty | Freq. Percent Cum.
------------+-----------------------------------
no | 290 88.96 88.96
yes | 36 11.04 100.00
------------+-----------------------------------
Total | 326 100.00
. table defendant [fweight=count], contents(mean penalty)
-------------------------
defendant | mean(penalty)
----------+--------------
white | .11875
black | .10241
-------------------------
. *Whites in the sample are more likely to get the death penalty
.
. table victim defendant [fweight=count], contents (mean penalty freq)
----------------------------
| defendant
victim | white black
----------+-----------------
white | .125828 .174603
| 151 63
|
black | 0 .058252
| 9 103
----------------------------
. tabulate victim defendant penalty [fweight=count]
too many variables specified
r(103);
. sort victim
. by victim: tabulate defendant penalty [fweight=count]
_______________________________________________________________________________
-> victim = white
| penalty
defendant | no yes | Total
-----------+----------------------+----------
white | 132 19 | 151
black | 52 11 | 63
-----------+----------------------+----------
Total | 184 30 | 214
_______________________________________________________________________________
-> victim = black
| penalty
defendant | no yes | Total
-----------+----------------------+----------
white | 9 0 | 9
black | 97 6 | 103
-----------+----------------------+----------
Total | 106 6 | 112
. *First let me show a couple of loglinear models and logistic regressions models that
correspond, i.e., are the same
. desmat: poisson count penalty
------------------------------------------------------------------------------------------
Poisson regression
------------------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 8
Initial log likelihood: -215.798
Log likelihood: -103.089
LR chi square: 225.419
Model degrees of freedom: 1
Pseudo R-squared: 0.522
Prob: 0.000
------------------------------------------------------------------------------------------
nr Effect Coeff s.e.
------------------------------------------------------------------------------------------
count
penalty
1 yes -2.086** 0.177
2 _cons 4.284** 0.059
------------------------------------------------------------------------------------------
* p < .05
** p < .01
. poigof
unrecognized command: poigof
r(199);
. poisgof
Goodness-of-fit chi2 = 170.4961
Prob > chi2(6) = 0.0000
. logistic penalty [fweight=count], coef
Logistic regression Number of obs = 326
LR chi2(0) = 0.00
Prob > chi2 = .
Log likelihood = -113.2564 Pseudo R2 = 0.0000
------------------------------------------------------------------------------
penalty | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_cons | -2.086362 .176709 -11.81 0.000 -2.432705 -1.740019
------------------------------------------------------------------------------
. *These two models are the same in coefficient and predicted values.
. lfit, table
Logistic model for penalty, goodness-of-fit test
+--------------------------------------------------------+
| Group | Prob | Obs_1 | Exp_1 | Obs_0 | Exp_0 | Total |
|-------+--------+-------+-------+-------+-------+-------|
| 1 | 0.1104 | 36 | 36.0 | 290 | 290.0 | 326 |
+--------------------------------------------------------+
+----------------+
| Group | Prob |
|-------+--------|
| 1 | 0.1104 |
+----------------+
number of observations = 326
number of covariate patterns = 1
Pearson chi2(0) = 0.00
Prob > chi2 = .
. *The logistic regression models can be created to mimic some of the loglinear models,
that is they provide the same coefficients and the same predictions, but logistic regression
collapses the variables you don't use, so here it has zero residual degrees of freedom.
. desmat: poisson count defendant victim penalty
------------------------------------------------------------------------------------------
Poisson regression
------------------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 8
Initial log likelihood: -215.798
Log likelihood: -86.805
LR chi square: 257.986
Model degrees of freedom: 3
Pseudo R-squared: 0.598
Prob: 0.000
------------------------------------------------------------------------------------------
nr Effect Coeff s.e.
------------------------------------------------------------------------------------------
count
defendant
1 black 0.037 0.111
victim
2 black -0.647** 0.117
penalty
3 yes -2.086** 0.177
4 _cons 4.537** 0.091
------------------------------------------------------------------------------------------
* p < .05
** p < .01
. poisgof
Goodness-of-fit chi2 = 137.9293
Prob > chi2(4) = 0.0000
. desmat: poisson count defendant*victim penalty
------------------------------------------------------------------------------------------
Poisson regression
------------------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 8
Initial log likelihood: -215.798
Log likelihood: -21.907
LR chi square: 387.784
Model degrees of freedom: 4
Pseudo R-squared: 0.898
Prob: 0.000
------------------------------------------------------------------------------------------
nr Effect Coeff s.e.
------------------------------------------------------------------------------------------
count
defendant
1 black -0.874** 0.150
victim
2 black -2.820** 0.343
defendant.victim
3 black.black 3.312** 0.379
penalty
4 yes -2.086** 0.177
5 _cons 4.900** 0.084
------------------------------------------------------------------------------------------
* p < .05
** p < .01
. poisgof
Goodness-of-fit chi2 = 8.131552
Prob > chi2(3) = 0.0434
. *What about interactions of race of victim and death penalty?
. *The above model fits fairly well, while completely ignoring race effects on death penalty
. desmat: poisson count defendant*victim defendant*penalty
------------------------------------------------------------------------------------------
Poisson regression
------------------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 8
Initial log likelihood: -215.798
Log likelihood: -21.796
LR chi square: 388.005
Model degrees of freedom: 5
Pseudo R-squared: 0.899
Prob: 0.000
------------------------------------------------------------------------------------------
nr Effect Coeff s.e.
------------------------------------------------------------------------------------------
count
defendant
1 black -0.856** 0.155
victim
2 black -2.820** 0.343
defendant.victim
3 black.black 3.312** 0.379
penalty
4 yes -2.004** 0.244
defendant.penalty
5 black.yes -0.166 0.354
6 _cons 4.891** 0.086
------------------------------------------------------------------------------------------
* p < .05
** p < .01
. poisgof
Goodness-of-fit chi2 = 7.910102
Prob > chi2(2) = 0.0192
. *This suggests no relationship between defendant's race and the death penalty.
. desmat: poisson count defendant*penalty
------------------------------------------------------------------------------------------
Poisson regression
------------------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 8
Initial log likelihood: -215.798
Log likelihood: -102.923
LR chi square: 225.751
Model degrees of freedom: 3
Pseudo R-squared: 0.523
Prob: 0.000
------------------------------------------------------------------------------------------
nr Effect Coeff s.e.
------------------------------------------------------------------------------------------
count
defendant
1 black 0.055 0.117
penalty
2 yes -2.004** 0.244
defendant.penalty
3 black.yes -0.166 0.354
4 _cons 4.256** 0.084
------------------------------------------------------------------------------------------
* p < .05
** p < .01
. *Even here, without accounting for defendant*victim, the defendant*penalty interaction is indistinguishable from zero.
. desmat: poisson count defendant*penalty victim
------------------------------------------------------------------------------------------
Poisson regression
------------------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 8
Initial log likelihood: -215.798
Log likelihood: -86.695
LR chi square: 258.207
Model degrees of freedom: 4
Pseudo R-squared: 0.598
Prob: 0.000
------------------------------------------------------------------------------------------
nr Effect Coeff s.e.
------------------------------------------------------------------------------------------
count
defendant
1 black 0.055 0.117
penalty
2 yes -2.004** 0.244
defendant.penalty
3 black.yes -0.166 0.354
victim
4 black -0.647** 0.117
5 _cons 4.528** 0.093
------------------------------------------------------------------------------------------
* p < .05
** p < .01
. poisgof
Goodness-of-fit chi2 = 137.7078
Prob > chi2(3) = 0.0000
. desmat: poisson count defendant*victim victim*penalty
------------------------------------------------------------------------------------------
Poisson regression
------------------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 8
Initial log likelihood: -215.798
Log likelihood: -18.782
LR chi square: 394.033
Model degrees of freedom: 5
Pseudo R-squared: 0.913
Prob: 0.000
------------------------------------------------------------------------------------------
nr Effect Coeff s.e.
------------------------------------------------------------------------------------------
count
defendant
1 black -0.874** 0.150
victim
2 black -2.724** 0.345
defendant.victim
3 black.black 3.312** 0.379
penalty
4 yes -1.814** 0.197
victim.penalty
5 black.yes -1.058* 0.464
6 _cons 4.866** 0.086
------------------------------------------------------------------------------------------
* p < .05
** p < .01
. poisgof
Goodness-of-fit chi2 = 1.881837
Prob > chi2(2) = 0.3903
. *There does seem to be a significant interaction between victim's race and the death penalty
. desmat: poisson count defendant*victim victim*penalty defendant*penalty
------------------------------------------------------------------------------------------
Poisson regression
------------------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 8
Initial log likelihood: -215.798
Log likelihood: -18.191
LR chi square: 395.215
Model degrees of freedom: 6
Pseudo R-squared: 0.916
Prob: 0.000
------------------------------------------------------------------------------------------
nr Effect Coeff s.e.
------------------------------------------------------------------------------------------
count
defendant
1 black -0.940** 0.163
victim
2 black -2.725** 0.344
defendant.victim
3 black.black 3.358** 0.382
penalty
4 yes -1.958** 0.245
victim.penalty
5 black.yes -1.324* 0.519
defendant.penalty
6 black.yes 0.440 0.401
7 _cons 4.885** 0.087
------------------------------------------------------------------------------------------
* p < .05
** p < .01
. poisgof
Goodness-of-fit chi2 = .7006815
Prob > chi2(1) = 0.4026
. *the logistic equivalent looks like this:
. desmat: logistic penalty [fweight=count] defendant victim, coef
invalid 'defendant'
r(198);
. desmat: logistic penalty defendant victim [fweight=count], coef
------------------------------------------------------------------------------------------
logistic
------------------------------------------------------------------------------------------
Dependent variable penalty
Number of observations: 326
fweight: count
Initial log likelihood: -113.256
Log likelihood: -109.541
LR chi square: 7.431
Model degrees of freedom: 2
Pseudo R-squared: 0.033
Prob: 0.024
------------------------------------------------------------------------------------------
nr Effect Coeff s.e.
------------------------------------------------------------------------------------------
defendant
1 black 0.440 0.401
victim
2 black -1.324* 0.519
3 _cons -1.958** 0.245
------------------------------------------------------------------------------------------
* p < .05
** p < .01
. lfit, table
Logistic model for penalty, goodness-of-fit test
+--------------------------------------------------------+
| Group | Prob | Obs_1 | Exp_1 | Obs_0 | Exp_0 | Total |
|-------+--------+-------+-------+-------+-------+-------|
| 1 | 0.0362 | 0 | 0.3 | 9 | 8.7 | 9 |
| 2 | 0.0551 | 6 | 5.7 | 97 | 97.3 | 103 |
| 3 | 0.1237 | 19 | 18.7 | 132 | 132.3 | 151 |
| 4 | 0.1798 | 11 | 11.3 | 52 | 51.7 | 63 |
+--------------------------------------------------------+
+------------------------------+
| Group | Prob | _x_1 | _x_2 |
|-------+--------+------+------|
| 1 | 0.0362 | 0 | 1 |
| 2 | 0.0551 | 1 | 1 |
| 3 | 0.1237 | 0 | 0 |
| 4 | 0.1798 | 1 | 0 |
+------------------------------+
number of observations = 326
number of covariate patterns = 4
Pearson chi2(1) = 0.38
Prob > chi2 = 0.5400
. desmat: poisson count defendant*victim victim*penalty defendant*penalty
------------------------------------------------------------------------------------------
Poisson regression
------------------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 8
Initial log likelihood: -215.798
Log likelihood: -18.191
LR chi square: 395.215
Model degrees of freedom: 6
Pseudo R-squared: 0.916
Prob: 0.000
------------------------------------------------------------------------------------------
nr Effect Coeff s.e.
------------------------------------------------------------------------------------------
count
defendant
1 black -0.940** 0.163
victim
2 black -2.725** 0.344
defendant.victim
3 black.black 3.358** 0.382
penalty
4 yes -1.958** 0.245
victim.penalty
5 black.yes -1.324* 0.519
defendant.penalty
6 black.yes 0.440 0.401
7 _cons 4.885** 0.087
------------------------------------------------------------------------------------------
* p < .05
** p < .01
. poisgof, pearson
Goodness-of-fit chi2 = .3755398
Prob > chi2(1) = 0.5400
. *These two models, the loglinear and the logistic have the same key interaction coefficients,
the same interpretations, and the same goodness of fit statitics.
. *Now let's look at both versions of the saturated model.
. desmat: poisson count defendant*victim*penalty
------------------------------------------------------------------------------------------
Poisson regression
------------------------------------------------------------------------------------------
Dependent variable count
Optimization: ml
Number of observations: 8
Initial log likelihood: -215.798
Log likelihood: -17.841
LR chi square: 395.915
Model degrees of freedom: 7
Pseudo R-squared: 0.917
Prob: 0.000
------------------------------------------------------------------------------------------
nr Effect Coeff s.e.
------------------------------------------------------------------------------------------
count
defendant
1 black -0.932** 0.164
victim
2 black -2.686** 0.345
defendant.victim
3 black.black 3.309** 0.385
penalty
4 yes -1.938** 0.245
defendant.penalty
5 black.yes 0.385 0.413
victim.penalty
6 black.yes -15.555 2096.899
defendant.victim.penalty
7 black.black.yes 14.326 2096.899
8 _cons 4.883** 0.087
------------------------------------------------------------------------------------------
* p < .05
** p < .01
. *This is where the zero comes to bite us.
. poisgof
Goodness-of-fit chi2 = -.0000579
Prob > chi2(0) = .
. *now let's look at the logistic version of the saturated model.
. desmat: logistic penalty defendant*victim [fweight=count], coef
------------------------------------------------------------------------------------------
logistic
------------------------------------------------------------------------------------------
Dependent variable penalty
Number of observations: 326
fweight: count
Initial log likelihood: -113.256
Log likelihood: -109.191
LR chi square: 8.132
Model degrees of freedom: 3
Pseudo R-squared: 0.036
Prob: 0.043
------------------------------------------------------------------------------------------
nr Effect Coeff s.e.
------------------------------------------------------------------------------------------
defendant
1 black 0.385 0.413
victim
2 black -16.335** 0.536
defendant.victim
3 black.black 15.105 .
4 _cons -1.938** 0.245
------------------------------------------------------------------------------------------
* p < .05
** p < .01
. *The coefficents are not exactly the same here as above, because both saturated models choke on the zero.
. lfit, table
Logistic model for penalty, goodness-of-fit test
+--------------------------------------------------------+
| Group | Prob | Obs_1 | Exp_1 | Obs_0 | Exp_0 | Total |
|-------+--------+-------+-------+-------+-------+-------|
| 1 | 0.0000 | 0 | 0.0 | 9 | 9.0 | 9 |
| 2 | 0.0583 | 6 | 6.0 | 97 | 97.0 | 103 |
| 3 | 0.1258 | 19 | 19.0 | 132 | 132.0 | 151 |
| 4 | 0.1746 | 11 | 11.0 | 52 | 52.0 | 63 |
+--------------------------------------------------------+
+-------------------------------------+
| Group | Prob | _x_1 | _x_2 | _x_3 |
|-------+--------+------+------+------|
| 1 | 0.0000 | 0 | 1 | 0 |
| 2 | 0.0583 | 1 | 1 | 1 |
| 3 | 0.1258 | 0 | 0 | 0 |
| 4 | 0.1746 | 1 | 0 | 0 |
+-------------------------------------+
number of observations = 326
number of covariate patterns = 4
Pearson chi2(0) = 0.00
Prob > chi2 = .
-----------------------------------------------------------