[R] How to find more about Covariance (in R)

Alaios alaios at yahoo.com
Wed Jan 19 15:29:54 CET 2011


Hello everyone,
I am trying to understand how covariance work. So I created a vector called sr<-c(2,5,7,5,2)

so according to wikipedia Cov(X,X)=E[XX]-E[x]*E[x] which in R is


mean(sr*sr)-mean(sr)*mean(sr)
[1] 3.76

but also

cov(sr,sr)
[1] 4.7

why is this difference between these two approaches? Where I am wrong?

I would like to thank you in advance for your help

Best Regards
Alex



More information about the R-help mailing list