Calculates weighted Pearson correlation coefficient between observed and predicted values by the help of stats::cov.wt
.
weighted_cor(actual, predicted, w = NULL, na.rm = FALSE, ...)
Observed values.
Predicted values.
Optional case weights.
Should missing values in observed
or predicted
be removed? Default is FALSE
.
Further arguments passed to stats::cov.wt
.
A length-one numeric vector.
# NOT RUN {
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)
# }
Run the code above in your browser using DataLab