dataFrame.columns.stat — phi()
Description
The phi() method of the stat object computes the Phi coefficient between two selected binary columns.
Signature
dataFrame.columns(...columnNames).stat.phi()Argument
...columnNames( string[] )- The name of the columns from which to compute the Phi coefficient.
Returns
coef(number)- The computed Phi coefficient.
Notes
- The method requires exactly two selected binary columns.
- The Phi coefficient measures the association between two binary variables.
- The coefficient ranges from
-1to1. - Positive values indicate a positive association.
- Negative values indicate a negative association.
- A value close to
0indicates little or no association. - The Phi coefficient is equivalent to the Pearson correlation coefficient computed on two binary variables.
- The method is based on the
2 × 2contingency table of the selected columns.
Example
// evaluate the Phi coefficient for 2 columns of the dataFrame
var coef = dataFrame.columns('groupA', 'groupB').stat.phi();
// log the stat details
notebook.log(coef);