|
Biweighted Midcorrelation. This is a median based correlation measure which is more robust against outliers.
-
seq1
:
seq<float>
-
-
seq2
:
seq<float>
-
-
Returns:
float
-
|
|
Calculates the bicor correlation of two samples.
The two samples are built by applying the given function to each element of the sequence.
The function should transform each sequence element into a tuple of paired observations from the two samples.
The correlation will be calculated between the paired observations.
-
f
:
'T -> float * float
-
A function applied to transform each element of the sequence into a tuple of paired observations.
-
seq
:
seq<'T>
-
The input sequence.
-
Returns:
float
-
The kendall correlation coefficient.
// To get the correlation between A and B observations:
let ab = [ {| A = 32.1; B = 1.2 |}
{| A = 3.1; B = 0.4 |}
{| A = 2.932; B = 3.85 |} ]
ab |> Seq.bicorBy (fun x -> x.A, x.B) // evaluates to -0.9303913046
|
|
Calculates the Biweighted Midcorrelation of two samples given as a sequence of paired values.
This is a median based correlation measure which is more robust against outliers.
-
seq
:
seq<float * float>
-
The input sequence.
-
Returns:
float
-
The Biweighted Midcorrelation.
// Consider a sequence of paired x and y values:
// [(x1, y1); (x2, y2); (x3, y3); (x4, y4); ... ]
let xy = [(32.1, 1.2); (3.1, 0.4); (2.932, 3.85)]
// To get the correlation between x and y:
xy |> Seq.bicorOfPairs // evaluates to -0.9303913046
|
|
Kendall Correlation Coefficient
-
setA
:
'b[]
-
-
setB
:
'c[]
-
-
Returns:
float
-
|
|
Calculates the kendall correlation of two samples.
The two samples are built by applying the given function to each element of the sequence.
The function should transform each sequence element into a tuple of paired observations from the two samples.
The correlation will be calculated between the paired observations.
-
f
:
'T -> 'a * 'a
-
A function applied to transform each element of the sequence into a tuple of paired observations.
-
seq
:
seq<'T>
-
The input sequence.
-
Returns:
float
-
The kendall correlation coefficient.
// To get the correlation between A and B observations:
let ab = [ {| A = -0.5; B = -0.3 |}
{| A = -0.4; B = -0.25 |}
{| A = 0.; B = -0.1 |}
{| A = 0.7; B = -0.46 |}
{| A = 0.65; B = 0.103 |}
{| A = 0.9649; B = 0.409 |} ]
ab |> Seq.kendallBy (fun x -> x.A, x.B) // evaluates to 0.4666666667
|
|
Calculates the kendall correlation coefficient of two samples given as a sequence of paired values.
-
seq
:
seq<'T * 'T>
-
The input sequence.
-
Returns:
float
-
The kendall correlation coefficient.
// Consider a sequence of paired x and y values:
// [(x1, y1); (x2, y2); (x3, y3); (x4, y4); ... ]
let xy = [(-0.5, -0.3); (-0.4, -0.25); (0., -0.1); (0.7, -0.46); (0.65, 0.103); (0.9649, 0.409)]
// To get the correlation between x and y:
xy |> Seq.kendallOfPairs // evaluates to 0.4666666667
|
|
Calculates the pearson correlation of two samples. Homoscedasticity must be assumed.
-
seq1
:
seq<^T>
-
-
seq2
:
seq<^T>
-
-
Returns:
float
-
|
|
Calculates the pearson correlation of two samples.
The two samples are built by applying the given function to each element of the sequence.
The function should transform each sequence element into a tuple of paired observations from the two samples.
The correlation will be calculated between the paired observations.
-
f
:
'T -> ^a * ^a
-
A function applied to transform each element of the sequence into a tuple of paired observations.
-
seq
:
seq<'T>
-
The input sequence.
-
Returns:
float
-
The pearson correlation.
// To get the correlation between A and B observations:
let ab = [ {| A = 312.7; B = 315.5 |}
{| A = 104.2; B = 101.3 |}
{| A = 104.; B = 108. |}
{| A = 34.7; B = 32.2 |} ]
ab |> Seq.pearsonBy (fun x -> x.A, x.B) // evaluates to 0.9997053729
|
|
Calculates the pearson correlation of two samples given as a sequence of paired values.
Homoscedasticity must be assumed.
-
seq
:
seq<^T * ^T>
-
The input sequence.
-
Returns:
float
-
The pearson correlation.
// Consider a sequence of paired x and y values:
// [(x1, y1); (x2, y2); (x3, y3); (x4, y4); ... ]
let xy = [(312.7, 315.5); (104.2, 101.3); (104.0, 108.0); (34.7, 32.2)]
// To get the correlation between x and y:
xy |> Seq.pearsonOfPairs // evaluates to 0.9997053729
|
|
weighted pearson correlation (http://sci.tech-archive.net/Archive/sci.stat.math/2006-02/msg00171.html)
-
seq1
:
seq<^T>
-
-
seq2
:
seq<^T>
-
-
weights
:
seq<^T>
-
-
Returns:
float
-
|
|
Calculates the weighted pearson correlation of two samples after
applying the given function to each element of the sequence.
-
f
:
'T -> ^a * ^a * ^a
-
A function applied to transform each element of the sequence into a tuple of triples representing the two samples and the weight. If the two samples are x and y then the elements of the sequence should be triples of x * y * weight
-
seq
:
seq<'T>
-
The input sequence.
-
Returns:
float
-
The weighted pearson correlation.
// To get the correlation between A and B observations weighted by W:
let abw = [ {| A = 1.1; B = 1.2; W = 0.2 |}
{| A = 1.1; B = 0.9; W = 0.3 |}
{| A = 1.2; B = 0.08; W = 0.5 |} ]
abw |> pearsonWeightedBy (fun x -> x.A, x.B, x.W)
// evaluates to -0.9764158959
|
|
Calculates the weighted pearson correlation of two samples.
If the two samples are x and y then the elements of the input sequence should be triples of x * y * weight .
-
seq
:
seq<^T * ^T * ^T>
-
The input sequence.
-
Returns:
float
-
The weighted pearson correlation.
// Consider a sequence of triples with x, y and w values:
// [(x1, y1, w1); (x2, y2, w2); (x3, y3, w3); (x4, y4, w4); ... ]
let xyw = [(1.1, 1.2, 0.2); (1.1, 0.9, 0.3); (1.2, 0.08, 0.5)]
// To get the correlation between x and y weighted by w :
xyw |> Seq.pearsonWeightedOfTriples // evaluates to -0.9764158959
|
|
Spearman Correlation (with ranks)
Items that are tied are each allocated the average of the ranks that
they would have had had they been distinguishable.
Reference: Williams R.B.G. (1986) Spearman’s and Kendall’s Coefficients of Rank Correlation.
Intermediate Statistics for Geographers and Earth Scientists, p453, https://doi.org/10.1007/978-1-349-06813-5_6
-
seq1
:
seq<^T>
-
seq2
:
seq<^T>
-
Returns:
float
-
The spearman correlation.
let x = [5.05;6.75;3.21;2.66]
let y = [1.65;2.64;2.64;6.95]
// To get the correlation between x and y:
Seq.spearman x y // evaluates to -0.632455532
|
|
Calculates the spearman correlation of two samples.
The two samples are built by applying the given function to each element of the sequence.
The function should transform each sequence element into a tuple of paired observations from the two samples.
The correlation will be calculated between the paired observations.
-
f
:
'T -> ^a * ^a
-
A function applied to transform each element of the sequence into a tuple of paired observations.
-
seq
:
seq<'T>
-
The input sequence.
-
Returns:
float
-
The spearman correlation.
// To get the correlation between A and B observations:
let ab = [ {| A = 1.1; B = 1.2 |}
{| A = 1.1; B = 0.9 |}
{| A = 2.0; B = 3.85 |} ]
ab |> Seq.spearmanBy (fun x -> x.A, x.B) // evaluates to 0.5
|
|
Calculates the spearman correlation (with ranks) of two samples given as a sequence of paired values.
-
seq
:
seq<^T * ^T>
-
The input sequence.
-
Returns:
float
-
The spearman correlation.
// Consider a sequence of paired x and y values:
// [(x1, y1); (x2, y2); (x3, y3); (x4, y4); ... ]
let xy = [(1.1, 1.2); (1.1, 0.9); (2.0, 3.85)]
// To get the correlation between x and y:
xy |> Seq.spearmanOfPairs // evaluates to 0.5
|