dataFrame.columns.stat — r2Pearson()

Description

The r2Pearson() method of the stat object computes the Pearson coefficient of determination between two selected columns.

Signature

dataFrame.columns(...columnNames).stat.r2Pearson()
Scope
columns
Family
stat
Returns
number

Argument

...columnNames ( string[] )
The name of the columns from which to compute the coefficient of determination.

Returns

coef (number)
The coefficient of determination computed from Pearson correlation.

Notes

  • The method requires exactly two selected columns.
  • The coefficient is computed as the square of the Pearson correlation coefficient.
  • The value ranges from 0 to 1.
  • A value close to 0 indicates little shared linear variance.
  • A value close to 1 indicates that the two columns have a strong linear relationship.
  • Unlike the Pearson correlation coefficient, r2Pearson() does not preserve the direction of the relationship.
  • Positive and negative correlations produce the same coefficient of determination.

Example

// evaluate the Pearson coefficient of determination for 2 columns of the dataFrame
var coef = dataFrame.columns('groupA', 'groupB').stat.r2Pearson();

// log the stat details
notebook.log(coef);