# example where r^2 is close to 0, # but there is a strong nonlinear fit x1 <- seq(-1,1,.01) y1 <- x1^2 + rnorm(length(x1),0,.02) fit1 <- lm(y1 ~ x1) summary(fit1) plot(x1,fit1$residuals) # example where r^2 is close to 1, but a linear fit # is far inferior to a nonlinear fit. x2 <- seq(0,1,.005) y2 <- x2^2 + rnorm(length(x2),0,.005) fit2 <- lm(y2~x2) summary(fit2) plot(x2,fit2$residuals)