Dear R list, I have one very elementary question regrading correlation between two variables. 

x = c(44,46,46,47,45,43,45,44)
y = c(44,43,41,41,46,48,44,43)

> cov(x, y)
[1] -2.428571

However, if I try to calculate the covariance using the formula as


covariance = sum((x-mean(x))*(y-mean(y)))/8       # no of of paired obs. = 8

or     

covariance = sum(x*y)/8-(mean(x)*mean(y))

gives

covariance = 2.125

I am not able to figure out where I am going wrong w.r.t. the covariance formula. Kindly guide.

Regards

Vincy












	[[alternative HTML version deleted]]

