Consider the gonorrhoea
dataset containing infection rates in the US by year, age, ethnicity and gender:
Year Age.Group Ethnicity Gender Rate
1 2007 0 to 4 Non-Hispanic Whites Male 0.3
2 2007 5 to 9 Non-Hispanic Whites Male 0.0
3 2007 10 to 14 Non-Hispanic Whites Male 0.2
4 2007 15 to 19 Non-Hispanic Whites Male 31.0
5 2007 20 to 24 Non-Hispanic Whites Male 76.9
6 2007 25 to 29 Non-Hispanic Whites Male 63.4
7 2007 30 to 34 Non-Hispanic Whites Male 41.0
8 2007 35 to 39 Non-Hispanic Whites Male 31.8
9 2007 40 to 44 Non-Hispanic Whites Male 25.4
10 2007 45 to 54 Non-Hispanic Whites Male 13.7
...
Run a linear regression of the response variable Rate
on all the other variables as main effects. Restrict the analysis to the 15-to34-year olds. Store your result in an object called gonorrhoea_lm
.
(from: Cotton, 2013, Learning R, O’Reilly)