In Statistics and Optimization, Statistical Errors and Residuals are two closely related and easily confused measures of “Deviation of a sample from the mean”.

Error is a misnomer; an error is the amount by which an observation differs from its expected value. The errors $e$ are unobservable random variables, assumed to have zero mean and uncorrelated elements each with common variance $\sigma^2$.

The sum of the errors need not be zero; the errors are independent random variables if the individuals are chosen from the population independently.

R Programming Language