weighted.cor | R Documentation |
Computes the weighted correlation between two distributions. This can be Pearson, Spearman or Kendall correlation.
weighted.cor(x, y, weights = NULL, method = "pearson", na.rm = FALSE)
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. |
a length-one numeric vector
Nicolas Robette
weighted.sd
, weighted.cor2
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.