powered by
This function is to compute an unbiased sample weighted covariance. The function uses only pairwise complete observations.
weighted.cov(x, y, w = NULL)
An input vector to compute a covariance, cov(x,y)
A weight vector
Returns an unbiased sample weighted covariance
# NOT RUN { # 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)) # }
Run the code above in your browser using DataLab