# SO5032: Lab Materials

## 1 Week 9 Lab

### 1.1 Logistic Regression

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

```do http://teaching.sociology.ul.ie/so5032/creditcard.do
```

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
```

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:

```do http://teaching.sociology.ul.ie/so5032/labs/limit.do
```

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

Created: 2021-03-23 Tue 15:59

Validate