  Detecting dependence between two random variables is a fundamental problem.
Although the Pearson correlation is effective for capturing linear dependency,
it can be entirely powerless for detecting nonlinear and/or heteroscedastic
patterns. We introduce a new measure, G-squared, to test whether two univariate
random variables are independent and to measure the strength of their
relationship. The G-squared is almost identical to the square of the Pearson
correlation coefficient, R-squared, for linear relationships with constant
error variance, and has the intuitive meaning of the piecewise R-squared
between the variables. It is particularly effective in handling nonlinearity
and heteroscedastic errors. We propose two estimators of G-squared and show
their consistency. Simulations demonstrate that G-squared estimates are among
the most powerful test statistics compared with several state-of-the-art
methods.
