MATH 315 Homework 09

Due 2025-11-12 by 11:59pm

  1. Load the dataset on donkeys. Our goal is to predict Weight (kg) using both Sex and Height (cm).

    a. Perform step 1 of any regression analysis, using ggplot2. Please color the points by Sex.

    You don't have to draw the linear regression lines if you don't want to, especially because doing so for the unique intercepts (per level of Sex) and shared slope (across all levels of Sex) is unfortunately challenging.

    b. Produce the code to fit the linear regression model to predict Weight using both Sex and Height that gives unique intercepts to each level of Sex and a shared slope across Height for all levels of Sex.

    c. Make a data frame that stores the standardized residuals and fitted values from this model.

    d. Make a ggplot2 scatter plot of the standardized residuals (y-axis) on the fitted values (x-axis). What assupmtions of linear regression does this plot help us check? Do the assumptions seem reasonably met? Why or why not?

    e. Make a ggplot2 histogram of the standardized residuals. What assumption of linear regression does this help us check? Does the assumption seem reasonably met? Why or why not?

    f. Are there any potential outliers that we need to be concerned with? Explain.

    Theoretically, if the assumptions of linear regression aren't satisfactorily met, you'd adjust your model and try again.

    g. Use adjusted R-squared to determine if including Sex as an explanatory variable improves the overall model fit, as compared to not including Sex. Report two adjusted R-squared numbers to justify your conclusion.

    h. Calculate the unique intercepts for each level of Sex.

    i. Interpret an intercept for a level of Sex in context of the data. Does this intercept value make logical sense?

    j. Interpret the slope in context of the data. Please be specific about which levels of Sex this slope is referring to.

    k. Using the p-values for the intercepts/offsets, what can you say about the differences between the Sex's weights?