1. Learn
  2. /
  3. Courses
  4. /
  5. Inference for Linear Regression in R

Exercise

Adjusting for non-constant errors

In this next example, it appears as though the variance of the response variable increases as the explanatory variable increases. Note that the fix in this exercise has the effect of changing both the variability as well as modifying the linearity of the relationship.

Instructions 1/2

undefined XP
  • 1
    • Run a linear regression of response versus explanatory on hypdata_nonequalvar.
    • Get the observation-level information from the model.
    • Using modeled_observations, plot the residuals versus the fitted values.
      • Add a point layer.
      • Add a horizontal line at y = 0 using geom_hline() and setting yintercept to 0.
  • 2
    • Update the model so that the left-hand side of the formula is log(response).
    • Rerun the code and look at how the plots change.