weighted.cov {factormodel} | R Documentation |
This function is to compute an unbiased sample weighted covariance. The function uses only pairwise complete observations.
weighted.cov(x, y, w = NULL)
x |
An input vector to compute a covariance, cov(x,y) |
y |
An input vector to compute a covariance, cov(x,y) |
w |
A weight vector |
Returns an unbiased sample weighted covariance
Yujung Hwang, yujungghwang@gmail.com
# If you do not specify weights,
# it returns the usual unweighted sample covariance
weighted.cov(x=c(1,3,5),y=c(2,3,1))
weighted.cov(x=c(1,3,5),y=c(2,3,1),w=c(0.1,0.5,0.4))