SO5032: Lab Materials

Table of Contents

1. Week 6 Lab

1.1. Non-linearity

1.1.1. Sketch a quadratic function

Using pen and paper and/or Excel, plot the curve \(Y=20+0.75X-0.03X^2\).

1.1.2. Age example

Age often has non-linear effects: how to handle it?

use http://teaching.sociology.ul.ie/so5032/example1

recode age = . if age < 15

drop if income >6000

scatter income age, mfcol(blue%05) mlcolor(white%00)

reg income age
reg income age if age<=34
reg income age if age>34

gen ageg = 5*int(age/5)

reg income c.ageg##c.ageg

1.1.3. Model a non-linear relationship

Run this do-file to load data on

do http://teaching.sociology.ul.ie/so5032/labs/birth

Fit models predicting birth rate using GNP as

  • a linear effect
  • a quadratic effect (GNP plus squared GNP)
  • logged GNP and
  • a grouped effect.

Consider the fit of the four models.

Plot the four predicted values as lines/curves on the same graph: how do they compare? Plot the residuals as well.

Author: Brendan Halpin

Created: 2022-03-15 Tue 15:55

Validate