Function Repository Resource:

# FirstOrderCorrelation

Compute the first order correlation matrix from an original correlation matrix

Contributed by: Seth J. Chandler
 ResourceFunction["FirstOrderCorrelation"][m] computes the first order correlation matrix of a matrix m.

## Details and Options

The matrix must be invertible.
The matrix should be symmetric and positive definite in order for the results to be useful.
Setting the option "ConditionsCheck" to True will warn if the matrix can not be confirmed to be symmetric and positive definite.

## Examples

### Basic Examples (2)

Compute the first order correlation of a rational 3×3 matrix:

 In:= Out= Compute the first order correlation of a symbolic symmetric 2×2 matrix:

 In:= Out= ### Scope (1)

FirstOrderCorrelation works on large matrices: In:= Out= ### Options (2)

#### ConditionsCheck (2)

Unless the "ConditionsCheck" option is set to True, FirstOrderCorrelation will evaluate and provide no warning even if the matrix is not symmetric:

 In:= Out=   Out= Setting "ConditionsCheck" to True also issues a warning if the matrix is not unambiguously positive definite and if it is not unambiguously positive semi-definite:   Out= ### Applications (2)

Find the value of an element in a 3×3 zero-order correlation matrix that will set to 0 the corresponding element in the first order correlation matrix:

 In:= Out= Find the element in a 4×4 zero-order correlation matrix that will set to 0 the corresponding element in the first order correlation matrix:

 In:= Out= ### Properties and Relations (1)

The first order correlation matrix of the first order correlation matrix is the same as the original matrix:

 In:= Out= ### Possible Issues (1)

The function will fail and throw a message if the matrix is singular:  Out= ### Neat Examples (5)

Compare the false positive rates and true positive rates among "minority" and "majority" populations when classifying a population where the first variable is correlated with the second, the first variable is correlated with the third, but, after the first variable is taken into account, the second variable is uncorrelated with the third.

Take a first order correlation matrix and compute the zero-order correlation matrix:

 In:= Out= In:= Out= Use the zero-order correlation matrix as the covariance matrix of a multinormal copula and use that to produce 1000 instances of training data and 1000 instances of test data: Classify uses AutoML to figure out how to best classify the data; ClassifierMeasurements uses the trained classifier and the test data to compute various performance statistics:

 In:= Out= Select picks out minority members from the test data set; the same performance statistics are generated:

 In:= Out= Select picks out majority members from the test data set; the same performance statistics are generated:

 In:= Out= Although there is no intentional "discrimination," and while the accuracy of the classifier is roughly the same for both groups, the false positive rates and true positive rates are higher for the majority than the minority.

Seth J. Chandler

## Version History

• 1.0.0 – 29 March 2021