Compute pairwise distance matrix
Arguments
- left_mat
Numeric matrix of left units (rows = units, cols = variables).
- right_mat
Numeric matrix of right units (rows = units, cols = variables).
- distance
Character string specifying distance metric, or a function.
- sigma
Optional covariance matrix for Mahalanobis distance. If
NULL(default), the pooled within-group covariance is estimated fromleft_matandright_mat: \(\Sigma = ((n_L-1)\,S_L + (n_R-1)\,S_R) / (n_L+n_R-2)\). This matches the convention used byoptmatch::match_on()for treated/control Mahalanobis matching. If either group has fewer than two rows, falls back to the overall-sample covariance of the two groups stacked together.