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