# Will quadratic-based estimation (not necessarily MSE) always generate a symmetric residuals after training it?

These are error's empirical distribution for XGB, RF and kNN, the last one have taken on another dataset. Neither of them is normally distribuited but they all are symmetric. None of used algorithms have even used MSE optimum, for example, both XGB and RF make a greedy approach for it due to being decision-tree-based and kNN uses euclidean distance which has nothing to do with MSE because that is not even a error-based estimation, my guess is that happens due to quadratic-based methods ignore error's signal but I can't link that to symmetry in probability density sense.

• I do wonder what quadratic estimation you have in mind that isn't equivalent to MSE. Remember that MSE, SSE, and RMSE all have the same argmin (and the same as the argmax of $R^2$), so I consider all to be equivalent loss functions (in some sense).
– Dave
Sep 18, 2021 at 5:32

NO

For a counterexample, fit an OLS regression with an exponential error term.

$$Y=X\beta+\epsilon\\ \epsilon_i\overset{iid}{\sim}exp(1)$$

When you do the OLS fit, which uses square loss, you will get asymmetric residuals.

(There’s an annoying issue where $$exp(1)$$ has a mean of $$1$$ instead of $$0$$. You can resolve this if you do a simulation in software like R by subtracting $$1$$ from every error value. That isn’t an exponential distribution but a shifted exponential, but the asymmetric residuals will be present.)

Here is a simulation demonstrating my counterexample.

set.seed(2021)
N <- 1000
x <- seq(0, 10, 10/(N - 1))
e <- rexp(N, 1) - 1 # subtract 1 so E(e) = 0
y <- x + e
plot(x, y)
L <- lm(y ~ x)
hist(resid(L))
plot(L)


The histogram of the residuals and first two plots of the model L show the marked asymmetry of the residuals.   • You're sure, I think the error should've got a distribution lying in $(-a,a)$ to OLS do what I supposed it'd do. Sep 18, 2021 at 0:11
• Why do you say that?
– Dave
Sep 18, 2021 at 1:21
• It was as I thought, I've simulated a non-symmetric distribution with symmetric interval then I used that as error and I've generated y=x^2+e, after I trained it by random forest via MSE impurity and I've gotten symmetric residuals even though error not being. I'm going to send you my script. Sep 18, 2021 at 4:32
• import numpy as np from sklearn.ensemble import RandomForestRegressor from matplotlib import pyplot as plt k=1/(np.exp(1)-np.exp(-1)) u=np.random.uniform(size=500) e=np.log((u+k*np.exp(-1))/k)##symetric_support-non_symmetric_distribution sample plt.hist(e) x=np.random.uniform(30,70,size=500) y=x**2+e plt.scatter(x,y) m=RandomForestRegressor().fit(x.reshape(-1,1),y) ye=m.predict(x.reshape(-1,1)) r=ye-y plt.hist(r)###run it after run before rows if youre using spyder, residuals arent symmetric even though error is Sep 18, 2021 at 4:40
• @DaviAmérico Please see my edit. While you may have demonstrated that the residuals can be symmetric despite an asymmetric error term, your question was looking for a counterexample to the claim that square loss produces symmetric errors, which I give.
– Dave
Sep 18, 2021 at 4:54