0

when i am trying to find a variance of a sample (10,20,30) in R with below command

var(c(10,20,30))

it's showing 100. I believe it should be 66.66667

Jagannath
  • 13
  • 1
  • 7
    It's the *sample* variance, not the *population* variance. So it is divided by $n - 1$, not $n$. – mkt Jul 28 '17 at 12:16
  • 2
    Yes 200/2 =100 as compared to 200/3 =66.667. The difference between these two estimates of variance is small when the sample size is large. The division by n-1 is done to get an unbiased estimate of the population variance. – Michael R. Chernick Jul 28 '17 at 12:53

1 Answers1

6

As per the documentation (?var):

The denominator $n - 1$ is used which gives an unbiased estimator of the (co)variance for i.i.d. observations.

That this "degrees-of-freedom correction" yields an unbiased estimator for $\sigma^2$ is for example discussed in How exactly did statisticians agree to using (n-1) as the unbiased estimator for population variance without simulation?.

What you have in mind is the population variance of a discrete random variable with three possible outcomes (or, alternatively, the ML estimator of $\sigma^2$).

The standardization you prefer is for example incorporated in the moments package:

library(moments)
moment(c(10,20,30), order = 2, central = T)
Christoph Hanck
  • 25,948
  • 3
  • 57
  • 106