# Finding residual and error term of a regression model [duplicate]

I am a bit confused on the difference between the residual term and the error term and how you go about finding each of these.

Suppose we have $$\hat{y_i}=\hat{\beta_0}+\hat{\beta_1}x_1+\hat{\beta_2}x_2+\hat{\beta_3}x_3+\hat{\beta_4}x_4+\hat{u_i}$$

Would the residual $\hat{u_i}$ just be: $$\hat{u_i}=\hat{y_i}-\hat{\beta_0}-\hat{\beta_1}x_1-\hat{\beta_2}x_2-\hat{\beta_3}x_3-\hat{\beta_4}x_4$$ ?

How would you then go about finding the error term $u_i$?

Well, technically what you wrote there is not correct, the term $u_i$ is on both sides of the equation, and from there I understand your perplexity. The Error term is one thing and the residuals are another. The error term is a random variable and the residuals are the outcome of this variable. You can find the residuals with the formula you wrote (removing the $u_i$ term of the second part) but you cannot find the error term (only it's outcomes).