-1

Calculate variance:

v=c(1,2,3)  
print(var(v)) 
#Result:1

#Calculate manually:2/3
Maurits Evers
  • 49,617
  • 4
  • 47
  • 68

2 Answers2

3

There are typically two ways to estimate variance. One is 1/n * sum( (x-mean(x))^2 ) and another is 1/(n-1) * sum( (x - mean(x))^2 ). The second is an unbiased estimator for the variance, which R uses.

The comments about sample variance versus population variance seem a bit misleading to me. The population variance is usually thought of as the fixed, unknown variance of a population. We want to estimate that variance, and we do so with a sample of the data, hence a sample variance (which can be estimated in more than one way, as mentioned above).

mickey
  • 2,168
  • 2
  • 11
  • 20
  • 2
    Your answer is correct but you should keep in mind that finite populations exist and for some of them you can measure every member of the population. – Roland Dec 07 '18 at 07:00
0

var in R computes sample variance. The other way of doing it is for population variance. http://www.r-tutor.com/elementary-statistics/numerical-measures/variance

Erin
  • 386
  • 1
  • 7