weighted_cor {MetricsWeighted}R Documentation

Weighted Pearson Correlation

Description

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

Usage

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

Arguments

actual

Observed values.

predicted

Predicted values.

w

Optional case weights.

na.rm

Should observations with missing values in actual or predicted be removed? Default is FALSE.

...

Further arguments passed to stats::cov.wt().

Value

A length-one numeric vector.

Examples

weighted_cor(1:10, c(1, 1:9))
weighted_cor(1:10, c(1, 1:9), w = 1:10)

[Package MetricsWeighted version 1.0.3 Index]