2

first question so I apologize in advance if my formatting is rough.

I'm currently working on a project with a professor I'll be starting a MSc in statistics with soon. One curious thing I've been asked to do when making residual plots is to have our predictor variables on the x axis instead of the fitted values from the model.

Heres an example using the iris dataset

library(tidyverse)
library(broom)

fit <- lm(Sepal.Length ~ Petal.Length, data = iris)

d <- fit %>% 
  augment()

##Residuals vs fitted
ggplot(data = d, aes(x = .fitted, y = .resid)) +
  geom_point() + 
  geom_smooth(se = FALSE, col = "red") + #Adds the line of fit
  geom_hline(yintercept = 0, linetype = 2) + #Adds the horizontal dashed line
  labs(x ="Fitted Values", y ="Residuals", title = "Residual vs Fitted") +
  theme_bw()

##Residuals vs Petal.Length (what my prof wants)
ggplot(data = d, aes(x = Petal.Length, y = .resid)) +
  geom_point() + 
  geom_smooth(se = FALSE, col = "red") + #Adds the line of fit
  geom_hline(yintercept = 0, linetype = 2) + #Adds the horizontal dashed line
  labs(x ="Petal.Length Values", y ="Residuals", title = "Residual vs Petal.Length") +
  theme_bw()

Which lead to these (mostly) identical graphs Residuals vs Fitted

Residuals vs Petal. Length

While I understand that theoretically that fitted values and observed values should be equivalent, and we can clearly see this example is the same, everything i've been taught, seen, or read plots residuals against fitted values.

Is there any benefit or statistical reason to do otherwise?

  • This post should be helpful in finding the answer to your question. https://newonlinecourses.science.psu.edu/stat501/node/278/ – davo.biainili Jul 26 '19 at 02:14
  • https://stats.stackexchange.com/questions/96563/trend-in-residuals-vs-dependent-but-not-in-residuals-vs-fitted/ and also https://stats.stackexchange.com/questions/5235/what-is-the-expected-correlation-between-residual-and-the-dependent-variable – Glen_b Jul 26 '19 at 03:05
  • Ah thank you! I understand now. That resolved my question nicely. I wasn't using the right search terms to find my answer – Matthew Lowe Jul 29 '19 at 14:07

0 Answers0