HOMEWORK 5 – SAMPLE SOLUTIONS
IMPORTANT NOTE
These homework solutions show multiple approaches and some optional extensions for most of
the questions in the assignment. You don’t need to submit all this in your assignments; they’re
included here just to help you learn more – because remember, the main goal of the homework
assignments, and of the entire course, is to help you learn as much as you can, and develop your
analytics skills as much as possible!
Question 8.1
Describe a situation or problem from your job, everyday life, current events, etc., for
which a linear regression model would be appropriate. List some (up to 5) predictors that
you might use.
I supervised a project for a company that builds machinery with custom features. Based on a
generic base model, potential customers specify additional features they need, and the company
quotes a price. The goal of the project was to create a linear regression model to estimate the cost
to build each unit, based on the number of units, time until delivery, and binary variables for
each of the potential features. (It could also include interaction terms between them.) The model
would be trained on data from previous completed projects.
Question 8.2
Using crime data from http://www.statsci.org/data/general/uscrime.txt (file uscrime.txt,
description at http://www.statsci.org/data/general/uscrime.html ), use regression (a useful R
function is lm or glm) to predict the observed crime rate in a city with the following data:
M = 14.0
So = 0
Ed = 10.0
Po1 = 12.0
Po2 = 15.5
LF = 0.640
M.F =
94.0 Pop
= 150
NW = 1.1
U1 =
0.120 U2
= 3.6
Wealth = 3200
Ineq = 20.1
Prob = 0.04
Time = 39.0
, Show your model (factors used and their coefficients), the software output, and the quality of fit.
IMPORTANT NOTE
These homework solutions show multiple approaches and some optional extensions for most of
the questions in the assignment. You don’t need to submit all this in your assignments; they’re
included here just to help you learn more – because remember, the main goal of the homework
assignments, and of the entire course, is to help you learn as much as you can, and develop your
analytics skills as much as possible!
Question 8.1
Describe a situation or problem from your job, everyday life, current events, etc., for
which a linear regression model would be appropriate. List some (up to 5) predictors that
you might use.
I supervised a project for a company that builds machinery with custom features. Based on a
generic base model, potential customers specify additional features they need, and the company
quotes a price. The goal of the project was to create a linear regression model to estimate the cost
to build each unit, based on the number of units, time until delivery, and binary variables for
each of the potential features. (It could also include interaction terms between them.) The model
would be trained on data from previous completed projects.
Question 8.2
Using crime data from http://www.statsci.org/data/general/uscrime.txt (file uscrime.txt,
description at http://www.statsci.org/data/general/uscrime.html ), use regression (a useful R
function is lm or glm) to predict the observed crime rate in a city with the following data:
M = 14.0
So = 0
Ed = 10.0
Po1 = 12.0
Po2 = 15.5
LF = 0.640
M.F =
94.0 Pop
= 150
NW = 1.1
U1 =
0.120 U2
= 3.6
Wealth = 3200
Ineq = 20.1
Prob = 0.04
Time = 39.0
, Show your model (factors used and their coefficients), the software output, and the quality of fit.