Deviation vs Residual
Both terms below come up in the same part of the course, and students mix them up. Here is each one defined on its own, side by side, so you can see where they part company.
Deviation
Describing data
A deviation is how far one data value sits from the mean, found by subtracting the mean from that value.
A deviation describes a single observation rather than the whole data set, and you write it as , where (x-bar) is the mean. A positive deviation puts the value above the mean and a negative deviation puts it below. In the data 2, 4, 6, 8 the mean is 5, so the four deviations are -3, -1, 1, and 3. They add to zero, which is true for every data set and is exactly why the variance squares the deviations before adding them up.
Residual
Regression and correlation
A residual is the difference between an observed y-value and the value the regression line predicts for it: observed minus predicted.
A residual measures how far off the line is for a single point, so a positive residual sits above the line and a negative one below. It equals , the observed response minus the predicted response (read y-hat). For example, if the line predicts 72 but a student actually scored 80, the residual is . Least-squares regression chooses the line that makes the sum of the squared residuals as small as possible.