Purpose
There are two useful plots called Added Variable Plot and Partial Residual Plot that are very useful for detecting outliers and non linearity in the data.

Let’s simulate data so as to construct linear models with and with out non linearity effects.

> x1 <- rep(sample(1:10), 100)
> x2 <- rep(sample(1:10), 100)
> beta1 <- rnorm(1000, 7, 0.5)
> beta2 <- rnorm(1000, -4, 0.75)
> e <- rnorm(1000)
> y <- x1 * beta1 + x2 * beta2 + e
> z <- data.frame(cbind(y, x1, x2))
> fit1 <- lm(y ~ x1 + x2, z)
> y <- x1^2 * beta1 + x2^2 * beta2 + e
> z <- data.frame(cbind(y, x1, x2))
> fit2 <- lm(y ~ x1 + x2, z)

Let’s simulate data so as to construct linear model with outliers in one of the independent variable.

> x1.o <- c(rep(sample(1:10), 100), c(60, 50))
> x1.o <- x1.o[-c(1, 2)]
> x2.o <- c(rep(sample(1:10), 100))
> beta1 <- rnorm(1000, 7, 0.5)
> beta2 <- rnorm(1000, -4, 0.75)
> e <- rnorm(1000)
> y <- x1.o * beta1 + x2.o * beta2 + e
> z <- data.frame(cbind(y, x1.o, x2.o))
> fit3 <- lm(y ~ x2.o, z)
> fit4 <- lm(x1.o ~ x2.o, z)

Partial Residual Plots help you spot the non linearity in the model

> par(mfrow = c(2, 2))
> vprplot(fit1, 1, "Linear")
> vprplot(fit2, 1, "Non Linear")
> vprplot(fit1, 2, "Linear")
> vprplot(fit2, 2, "Non Linear")

AddedVarPartialResPlot-003.jpg

Added Variable plot helps you detect outliers in the model

> par(mfrow = c(1, 1))
> plot(resid(fit4), resid(fit3), pch = 19, col = "blue", cex = 0.8)

AddedVarPartialResPlot-004.jpg

In a Multivariate environment, added variable and partial residual plots can be extremely useful for diagnostics