weighted.cor {descriptio} | R Documentation |
Weighted correlation
Description
Computes the weighted correlation between two distributions. This can be Pearson, Spearman or Kendall correlation.
Usage
weighted.cor(x, y, weights = NULL, method = "pearson", na.rm = FALSE)
Arguments
x |
numeric vector |
y |
numeric vector |
weights |
numeric vector of weights. If NULL (default), uniform weights (i.e. all equal to 1) are used. |
method |
a character string indicating which correlation coefficient is to be computed. One of "pearson" (default), "kendall", or "spearman". |
na.rm |
logical, indicating whether NA values should be silently removed before the computation proceeds. Default is FALSE. |
Value
a length-one numeric vector
Author(s)
Nicolas Robette
See Also
Examples
data(Movies)
weighted.cor(Movies$Critics, Movies$BoxOffice, weights = rep(c(.8,1.2), 500))
weighted.cor(Movies$Critics, Movies$BoxOffice, weights = rep(c(.8,1.2), 500), method = "spearman")
[Package descriptio version 1.3 Index]