Residual variance formulas difference

There is a bi-dimensional table of frequencies:

Doing the regression analysis with the fit formula being $\hat y=a+bx^2$, where $\hat y$ is the same as $y^{est}$, the filled table looks like this:

Doing standard regression analysis (i.e. by calculator) and substituting calculated $a$ and $b$ yields linear fit formula $\hat y_i=0.1077+1.4154x^2$.

I need to calculate the residual variance. I have encountered two formulas for calculating, I residual variance in the statistics course presentations, I am currently taking:

$$V_r=\frac{\sum_i n_ie_i^2}{\sum_i n_i} - \left(\frac{\sum_i n_ix_i}{\sum_i n_i}\right)^2$$ $$V_r=\frac{\sum_i e_i^2}n - \left(\frac{\sum_i e_i}n\right)^2$$

They both give different results (1.5282 vs 2.6219). There is a also question concerning this, that has got a exhaustive answer and the formula there for residual variance is:

$$\text{Var}(e^0) = \sigma^2\cdot \left(1 + \frac 1n + \frac {(x^0-\bar x)^2}{S_{xx}}\right)$$

But it looks like a some different formula. I would like to use it to verify the results. I have found that $S_{xx}=\sum_i (x_i-\bar x)^2$, but I still do not understand what the $e^0$ and $x^0$ represents.

There are also multiple formulas on the internet for calculating residual variance, that are completely different and make me more confused. How do I compute residual variance from the given data?

Thank you for any help!

• You are compelling your readers to guess what this all means. I would suppose you might be doing an Analysis of variance and that the $n_i$ are the group sizes, but it's not entirely clear. Please edit this question to explain the notation, describe the context, and stipulate the sources of these formulas.
– whuber
May 11, 2015 at 19:42
• You still have your $e_i$ undefined. I am afraid you are mixing up several statistical concepts and methods. The concept of a residual comes from regression analysis where at least the dependent variable is continuous; when you talk about frequency tables, that seems to imply the analysis of categorical data only. Please keep clarifying. May 11, 2015 at 20:04
• I can't clearly understand what's going on here but it looks like you're trying to apply regression to a contingency table. Please clarify what you're doing and why you're doing it this way. May 12, 2015 at 2:50
• It seems like this is a table of (originally continuous )data collapsed into intervals, and what is wanted is an estimation of the model based on the original variables before it was collapsed into intervals? Is that a true interpretation? May 12, 2015 at 16:48
• @Glen_b I am not sure, the textbook is in Spanish. I was an exchange student. Most of the people did not pass the course. But it was how we were supposed to calculate it. Jul 1, 2015 at 12:51

So, I have found the answer. It is not this (first formula in the question): $$V_r=\frac{\sum_i n_ie_i^2}{\sum_i n_i} - \left(\frac{\sum_i n_ix_i}{\sum_i n_i}\right)^2$$
But this (somehow, the $e_i$ got replaced by $x_i$ in the presentation):
$$V_r=\frac{\sum_i n_ie_i^2}{\sum_i n_i} - \left(\frac{\sum_i n_ie_i}{\sum_i n_i}\right)^2$$