Learn R Programming

MetricsWeighted (version 0.5.4)

weighted_cor: Weighted Pearson Correlation

Description

Calculates weighted Pearson correlation coefficient between observed and predicted values by the help of stats::cov.wt.

Usage

weighted_cor(actual, predicted, w = NULL, na.rm = FALSE, ...)

Value

A length-one numeric vector.

Arguments

actual

Observed values.

predicted

Predicted values.

w

Optional case weights.

na.rm

Should missing values in observed or predicted be removed? Default is FALSE.

...

Further arguments passed to stats::cov.wt.

See Also

weighted_mean.

Examples

Run this code
weighted_cor(1:10, c(1, 1:9))
weighted_cor(1:10, c(1, 1:9), w = 1:10)

Run the code above in your browser using DataLab