SO5032: Lab Materials

Table of Contents

1 Week 10 Lab

1.1 More Logistic Regression

1.2 Classification tables

With the creditcard data, fit a logistic regression and use estat class to generate the classification table.

do http://teaching.sociology.ul.ie/so5032/creditcard.do
logit card income
estat class

Compare the results with those for the null model (i.e., fit the logistic regression with no explanatory variables and then do estat class).

Examine both tables and compare the figures for sensitivity (correctly saying someone has a card) and specificity (correctly saying someone doesn't).

1.3 Logistic regression and odds ratios

Load this data from Agresti & Finlay:

clear
do http://teaching.sociology.ul.ie/so5032/dp

It summarises murder convictions by defendant's and victim's race, and whether the death penalty was handed down.

First tabulate by defendant's race and verdict, and calculate the odds ratio by hand (black yes over black no, all over white yes over white no):

tab def pen

Interpret the odds ratio: what does it say about the relationship between defendant's race and penalty?

Then fit the logistic regression with defendant's race explaining the penalty. Exponentiate the slope coefficient, and satisfy yourself that it matches the OR you calculated by hand:

logit pen i.def
display exp(_b[2.def])

We can take account of victim's race as well. Since this is correlated with both defendant's race and penalty, it could change the results:

logit pen i.def i.vic

What happens to the effect of defendant's race when victim's race is included?

Author: brendan

Created: 2018-04-09 Mon 10:15

Emacs 26.0.50 (Org mode 8.2.10)

Validate