MATH 314 Quiz 19

Given on 2025-12-10

Please submit a jupyter notebook to the Quiz 19 GitHub repository by 1.55pm.

There are exactly 5 things wrong in each code chuck of each of the problems below. Wrong can be either

Please cross out the wrong characters and write an ordered, comma separated list of replacement characters after the comment #. If you don't know the correct Python syntax for the replacement characters you want, make something not unreasonable up for partial credit.

You should assume the following code precedes each code chunk in each question. Otherwise, the code chunks are independent across problems; no code in one question's code chunk informs code in another question's code chunk.

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import statsmodels.api as sm
import statsmodels.formula.api as smf
import scipy.stats as st
url = "https://raw.githubusercontent.com/roualdes/data/refs/heads/master/finches.csv"
df = pd.read_csv(url)
  1. Use multiple linear regression to predict beakwidth (measured in millimeters) with both island and taillength (measured in millimeters).
fit = smf.ols("beakwidth  island + taillength", data = df).fit()
ndf = pd.DataFrame({"beakwidth": 2, "sex": "Male"})
predict(df)
  1. Fit logistic regression and estiamte slope at a beakwidth of grams.
df["SanCristobal"] = (df["island"].astype("string") = "sancristobal").astype(np.float64)
fit = smf.glm("sancristobal ~ beakwidth  taillength",
              data = df,
              family = sm.families.Binomial())
fit.predict(pd.Dataframe({"beakwidth": ["9", "10"]}))