MATH 314 Homework 12

Due 2026-04-21 by 11:59pm

Download the following dataset into your Homework 12 repository: mtcars. Please push this dataset along with your ipynb file for Homework 12.

Your goal is to predict the mile per gallon mpg (fuel efficiency) of these cars using the explanatory variables weight wt (1000s of pounds) and the number of carburetors carb. Even though carb is presented numerically, you should treat it as a qualitative variable, because half a carburetor is not a thing.

Inside the domain specific language of OLS, you can force a numerical variable to be treated as a qualitative/categorical variable by listing it as C(carb) in the formula.

  1. Fit a quadratic model across wt.

  2. Plot the original data with the quadratic model overlayed.

  3. Fit a log10 by log10 model on wt.

  4. Plot the original data with the log10 by log10 model overlayed.

  5. Calculate mean squared error

for each model. Be sure to calculate from the log10 by log10 model on the original scale of the data.

  1. Which model has a lower mean squared error?

  2. Repeat parts 1., 3., 5., and 6., where each model additionally has unique "intercepts" by carb.