Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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

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.

Value

A length-one numeric vector.

See Also

Examples

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

MetricsWeighted

Weighted Metrics, Scoring Functions and Performance Measures for Machine Learning

v0.5.2
GPL (>= 2)
Authors
Michael Mayer [aut, cre, cph], Christian Lorentzen [ctb, rev]
Initial release
2021-04-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.