# 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 '15 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. – StasK May 11 '15 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. – Glen_b May 12 '15 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? – kjetil b halvorsen May 12 '15 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. – peter.babic Jul 1 '15 at 12:51

## 1 Answer

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$$

The second formula from the question is the same, but used when the frequency is not specified (no cross-table, just independent and dependent variable).

The solution wasn't that hard as the moderators in the comments were continuously stating!

• The issue is not with the simplicity of the solution, but with your question; people weren't saying the problem was hard, they were pointing out ways in which parts of the question were unclear, ill defined and so on. Indeed your question remains problematic in a variety of senses. You should seek to improve your question and address as many of the issues raised in comments as you can. A clear, well framed question would not only have attracted upvotes, you'd likely have had several good answers in quick time. – Glen_b Jun 23 '15 at 2:44
• @Glen_b You are right, I did overreact, but I was confused from all the formulas and frustrated from the endless question improving, without being just a bit closer to the answer. – peter.babic Jun 23 '15 at 16:39