Learn R Programming

MetricsWeighted (version 1.0.4)

weighted_cor: 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, ...)

Value

A length-one numeric vector.

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().

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