weighted_cor: Weighted Pearson Correlation

View source: R/statistics.R

weighted_corR 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)

MetricsWeighted documentation built on Nov. 16, 2023, 5:09 p.m.