wt.corr: Weighted correlation

Description Usage Arguments Value Source Examples

View source: R/wt_corr.R

Description

This function computes weighted Pearson correlation between two vectors with weights given. The output is between -1 and 1 with 1 being highly positively correlated, -1 being highly negatively correlated, and 0 being no correlation

Usage

1
wt.corr(x, y, w)

Arguments

x

a vector

y

a vector with same length of x

w

a vector with same length of x and y

Value

a numerical value of weighted Pearson correlation

Source

https://en.wikipedia.org/wiki/Pearson_correlation_coefficient#Weighted_correlation_coefficient

Examples

1
2
wt.corr(c(1, 2, -9, 4, 5), c(2:6), c(0.5, 1, 2, 0.5, 2))
wt.corr(rnorm(5), rnorm(5), runif(5, 0, 1))

gitter-lab/LPWC documentation built on May 7, 2020, 2:02 p.m.