MATH 314 Quiz 21

Given on 2025-11-17

Please submit a Jupyter notebook to the Quiz 21 repository by the end of class today.

  1. Use Polars to read in the possum dataset and select the columns pop, skullW, and totalL. Remove any missing data (nulls). Here's the README for these data. Pay attention to units.

  2. Fit a unique intercepts (shared slope) linear model to predict totalL using the categorical variable pop and the numeric variable skullW.

  3. Use the method predict on the class returned by sm.OLS(y, X).fit() to calculate the mean total length of possums from each pop (other and vic) for a possum with skull width equal to the mean of the appropriate pop from the model in 2. Interpret each mean in context of the data.

  4. Re-do the calculation in 3. without the method predict, but you should use the property params on the class returned by sm.OLS(y, X).fit().

  5. Fit a unique intercepts and unique slope linear model to predict totalL using the categorical variable pop and the numeric variable skullW.

  6. Use the method predict on the class returned by sm.OLS(y, X).fit() to calculate the mean total length of possums from each pop (other and vic) for a possum with skull width equal to the mean of the appropriate pop from the model in 4. Interpret each mean in context of the data.

  7. Re-do the calculation in 6. without the method predict, but you should use the property params on the class returned by sm.OLS(y, X).fit().

  8. Pick a value of skull width from amongst the values of skullW in the dataset. Make a prediction using the appropriate level of pop from each model (2. and 5. above). Quantify how far from the matching value of totalL is from your predictions.

  9. Which model predicts totalL better? Why?

  10. Make a plot of either model for all levels of pop.