Linear regression in R with mathematics of residual errors.