SO5032: Lab Materials

Table of Contents

1 Week 10 Lab

1.1 Logistic regression and odds ratios

Load this death penalty data from Agresti:

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. We've seen it briefly before.

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?

1.2 Model search

Load the following extract from the European Social Survey (Ireland, wave 9):

use http://teaching.sociology.ul.ie/so5032/labs/logitessie

Examine the variables, and use logistic regression to model what affects the odds of being married. Use z-tests and likelihood ratio tests to build a good model.

For example, a likelihood ratio test for adding var4 and var5 to a model that already contains var1, var2 and var3:

logit married var1 var2 var3
est store mod1
logit married var1 var2 var3 var4 var5
lrtest mod1

Think about the model that you end up with. What matter and what doesn't? Think about the order of causality: why should age have an effect? Is your health now a legitimate predictor of whether you got married in the past (and stayed married)?

Author: brendan

Created: 2021-04-06 Tue 16:00

Validate