Function partial
Computes the partial correlation between vec1, vec2 given conditions. conditions can be either a tuple of ranges, a range of ranges, or (for a single condition) a single range.
double partial(alias cor, T, U, V...)
(
T vec1,
U vec2,
V conditionsIn
)
if (isInputRange!T && isInputRange!U && allSatisfy!(isInputRange, V));
cor is the correlation metric to use. It can be either pearsonCor, spearmanCor, kendallCor, or any custom correlation metric you can come up with.
Examples
uint[] stock1Price = [8, 6, 7, 5, 3, 0, 9];
uint[] stock2Price = [3, 1, 4, 1, 5, 9, 2];
uint[] economicHealth = [2, 7, 1, 8, 2, 8, 1];
uint[] consumerFear = [1, 2, 3, 4, 5, 6, 7];
// See whether the prices of stock 1 and stock 2 are correlated even
// after adjusting for the overall condition of the economy and consumer
// fear.
double partialCor =
partial!pearsonCor(stock1Price, stock2Price, economicHealth, consumerFear);