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()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
0to1. - A value close to
0indicates little shared linear variance. - A value close to
1indicates 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);