Calculates the Pearson correlation coefficient between two numeric vectors, with optional case weights. Uses the standard correlation formula for unweighted data and weighted covariance for weighted data.
Arguments
- .x
A numeric vector containing the first variable.
- .y
A numeric vector containing the second variable. Must have the same length as
.x.- .weights
An optional numeric vector of case weights. If provided, must have the same length as
.xand.y. All weights must be non-negative.- na.rm
A logical value indicating whether to remove missing values before computation. If
FALSE(default), missing values result inNAoutput.
Value
A numeric value representing the correlation coefficient between -1 and 1.
Returns NA if either variable has zero variance.
See also
check_balance() for computing multiple balance metrics at once
Other balance functions:
bal_ess(),
bal_ks(),
bal_model_auc(),
bal_model_roc_curve(),
bal_qq(),
bal_smd(),
bal_vr(),
check_balance(),
check_ess(),
check_model_auc(),
check_model_roc_curve(),
check_qq(),
plot_balance()
