beta0 <- 1
beta1 <- 2
sig <- 3
n <- 10
x <- 1:n
y <- beta0+beta1*x+sig*rnorm(n)
y[8] <- y[8]+20
d <- data.frame(y=y,x=x)
fit1 <- lm(y~x,data=d)
fit2 <- lm(y~x,data=d[-8,])
par(mfrow=c(1,2))
plot(x,y)
abline(coef(fit1),col=1)
abline(coef(fit2),col=2)
legend("topleft",legend=c("All data","Outlier excluded"),lty=1,col=1:2)
plot(fit1$residuals)

plot(fit1)
