# Partial regression plots in R

#### pinkfreud

##### New Member
Hey guys,

I'm slowly converting myself from an SPSS user to an R user. I'm running a pretty basic multiple regression model and want to produce partial regression plots to view the relationship between each predictor and the response, when the other predictors are controlled for. In SPSS this is very simple, however I'm struggling to find a way to do it in R.

Any help would be fantastic.

Kind Regards
Pinkfreud

#### Dason

Partial regression plots are also called added variable plots. The 'car' library has some nice functions to do these for you.
Code:
> # Make some test data
> x1 <- 1:30
> x2 <- rnorm(30)
> y <- x1 + x2 + rnorm(30)
> library(car)
> dat <- data.frame(y = y, x1 = x1, x2 = x2)
>
> # Fit the model
> o <- lm(y ~ x1 + x2, data = dat)
> # Get the added variable plots
> avPlots(o)