Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

I'm wondering what the difference is between:

  1. 'predicted by residual plot' where I plot the residuals of the regression with the predicted values of the regression ;
  2. the case where I plot the residuals with the predictor variables.

Also I'm wondering how to make such a plot in R in the case of multiple regression. Do I have to make a plot for each predictor separately?

share|improve this question

2 Answers

A plot of residuals versus predicted response is essentially used to spot possible heteroskedasticity (non-constant variance across the range of the predicted values), as well as influential observations (possible outliers). Usually, we expect such plot to exhibit no particular pattern (a funnel-like plot would indicate that variance increase with mean). Plotting residuals against one predictor can be used to check the linearity assumption. Again, we do not expect any systematic structure in this plot, which would otherwise suggest some transformation (of the response variable or the predictor) or the addition of higher-order (e.g., quadratic) terms in the initial model.

More information can be found in any textbook on regression or on-line, e.g. Graphical Residual Analysis or Using Plots to Check Model Assumptions.

As for the case where you have to deal with multiple predictors, you can use partial residual plot, available in R in the car (crPlot) or faraway (prplot) package. However, if you are willing to spend some time reading on-line documentation, I highly recommend installing the rms package and its ecosystem of goodies for regression modeling.

share|improve this answer
and in the case of plotting the residuals with the predictors to check linearity that means that you plot the same residuals with the different predictoes. does it need to be linear with each predictor? – Dbr Nov 11 '11 at 14:32
1  
No, when you have multiple predictors, you don't use the regular residuals but instead the partial residuals; this is known as either a component-plus-residual plot (crplot in car) or a partial residual plot (prplot in faraway); however, curvature from other predictors can "leak" into these plots, so they're not guaranteed to give you exactly what you want. A CERES plot (also in car) is better but still not perfect. These plots are indeed created for each predictor in the model separately, I believe car has a function to do them all at once and faraway may too. – Aaron Nov 11 '11 at 16:41
1  
Here's a function to make all the prplots for a given lm fit, using ggplot2: gist.github.com/3041812. – Quantitative Historian Jul 3 '12 at 22:18

After you fit an lm object, you can plot it.

e.g.:

model <- lm(y~x,data=data.frame(y=rnorm(25),x=rnorm(25)))
plot(model)
?plot.lm

edit: example 2, which you should have posted yourself:

rm(list = ls(all = TRUE)) #CLEAR WORKSPACE
library(foreign)
Data <- read.dta('http://dl.dropbox.com/u/22681355/child.iq.dta')
model <- lm(ppvt~momage+educ_cat, Data)
plot(model)
share|improve this answer
thanks! can you explain what each plot refers to? are these all predicted by residual plots? – Dbr Nov 11 '11 at 15:01
@DBR: Each plot is accurately titled, and you can read more in ?plot.lm. Plot 1 is the "predicted by residual plot" you are looking for. Plot 2 is to test the residuals for normality, and plots 3 and 4 are more advanced. – Zach Nov 11 '11 at 15:07
dl.dropbox.com/u/22681355/plot.tiff this is what mine looks like so its not really titled and I can't really figure out which one is which. plot.lm doesnt seem to help? – Dbr Nov 11 '11 at 15:17
@Dbr: Please post a reproducible example. Whatever you're plotting, it's not an lm object. Did you try the code I posted? – Zach Nov 11 '11 at 16:16
dl.dropbox.com/u/22681355/child.iq.dta this is the datafile. All I'm doing is model<-lm(ppvt~momage+educ_cat) and then plot(model) – Dbr Nov 11 '11 at 16:23
show 8 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.