Scale and Harmonize Weighted Numeric Vectors
scaleNumeric.Rd`scaleNumeric()` pre-processes two weighted numeric vectors prior to evaluating their distribution similarity. It applies adaptive scaling based on distribution cardinality and zero-inflation, returning both the scaled vectors and their resulting similarity score.
Value
A list containing three elements:
[[1]]Transformed/scaled version of
x1.[[2]]Transformed/scaled version of
x2.[[3]]Numeric similarity score in \([0, 1]\) calculated via
numerical_similarity.
Details
To make numerical comparisons robust across diverse variables, `scaleNumeric()` uses two distinct transformation paths:
High-cardinality (>100 unique non-NA values): Standardizes vectors using weighted medians and weighted Median Absolute Deviation (MAD). If the MAD is zero, it falls back to weighted standard deviation. Standardized values are rounded and scaled to integer Z-scores to save memory and optimize downstream comparisons. For zero-inflated distributions, the similarity score is evaluated both overall and on non-zero subsets, taking the maximum of the two.
Low-cardinality (\(\le 100\) unique values): Converts unique values across both vectors to unified dense integer ranks using
match.