SO5032: Lab Materials

Table of Contents

1 Week 9 Lab

1.1 Logistic Regression

This file contains Stata code to run the credit card example in A&F:


Execute the code to create the working data file, and examine the relationship between having a credit card and income (compare means, group income and cross tabulate, etc.). The variable card records whether a credit card is held, and income is the explanatory variable.

Now fit the linear probability model and interpret it:

reg card income

Save the predicted values:

predict plin

Now fit the logistic regression, and interpret it:

logit card income

Save the predicted values and graph them against income.

predict plog
scatter care plog income

Compare this graph with that relating the first model's predicted values to income:

scatter care plog plin income

1.1.1 Predicted values by hand

Calculate predicted values by hand (log-odds, odds and probabilities) for income = 10, 11, 60, and 61.

1.1.2 Age and health

Repeat the exercise with this alternative data file:


which has data on age and whether the respondent finds their health limits their daily activities.

Author: brendan

Created: 2018-03-12 Mon 12:02

Emacs 26.0.50 (Org mode 8.2.10)