# Thread: Negative Variance - help!

1. ## Negative Variance - help!

I'm currently writing up a scientific project and I've come to a complete standstill when calculating the variance. The formula I am using to calculate Variance (from the textbook) is one that is obtained from Linear regression theory as the variance of the slope of the regression. (apparently anyway!)

I have to do the calculations for 3 different data sets. First two - no problem. Third one.. I am getting a negative value. I've gone over and over and over double checking that I haven't mis-calculated anything but I definitely haven't. What's going on?!! I am SO stuck!

2. If you are sure you haven't made a mistake, the "negative variance" could be due to round-off error. I suppose you are using the textbook formula based on the sum of the X's and the sum of their squares. If so, try this instead.

First compute $\bar{x} = \sum_{i=1}^n x_i$.

Then compute $var(x) = \sum_{i=1}^n (x_i - \bar{x})^2$.

3. Thanks for your reply! I understand what you are saying and understand those formulas you have given me. However.... the formulas I am using are adapted specifically for Ecology and my methodology. I know the two formulas must be linked and one derived from the other, but I cannot figure out how.

I have attached the formulas to this post here..

To make sense of that formula, essentially what I have done is a mark-recapture biological study on a population of animals.

Ct = total number of individuals caught in sample t
Rt = Number of individuals already marked when caught in sample t
Ut= Number of individuals marked for the first time and released in sample t
Mt = Number of marked individuals in the population just before sample t is taken.

So essentially, using the variance formula given in that attachment.. I am getting a negative result, and not being a Maths student I just can't figure out the reasoning why. Does the formula shed any light?!

4. Given your formula, it still seems to me that you might get a "negative variance" due to round-off error, but I don't see a quick fix in this case, unlike in my initial post.

It might help to know if the variance you compute is a "small" negative number by comparison with your raw data. That would lend support to the theory that it's due to round-off.

You haven't said how you are doing your calculations. Are you using a hand calculator, a computer, or what? If you know how to use a spreadsheet and have Microsoft Excel, you might try doing the calculations in Excel. Excel uses double precision in all its calculations so there is very little round-off.