Linked Questions

Popular Questions

Produce Wally Plot using R

Asked by At

I want to produce Wally plot using R and the dataset savings from the faraway package.

You can load the data and fit a linear model using this command:

library(faraway)
model <- lm(sr ~ ., data = savings)
summary(model)

Wally plots consist of several "ideal" reference plots that are obtained through simulations. Their intention is to reflect data for which model assumptions hold. Wally plots can be obtained as follows:

  • simulate new responses using estimates from "model" together with simulated error terms verifying the necessary assumptions,
  • refit the model using the simulated responses,
  • re-calculate fitted values and residuals, and
  • plot fitted values vs. residuals
  • (these steps might be repeated e.g. 10 times to produce several plots)

I need the R code to produce these plots. I hope everything is clear !

Thanks for your help.

Related Questions