Correlation coefficient and non linear association Correlation and Linear Regression

Author:

Lisa Sullivan, PhD

Professor of Biostatistics

Boston University School of Public Health

Says there  may be non-linear association which the correlation  coefficient does not detect. I disagree with this idea. The Karl Pearson correlation coefficient actually computes the degree of relative changes in two variables which may be constant or varying.
Yes, Dr. Sullivan is right. For example, take a perfect quadratic relationship between X and Y. 

Here is some Python code to show nine sample points and calculate their Pearson correlation coefficient. You can skip the code and just look at the results below if you trust me.

import numpy as np
import matplotlib.pyplot as plt
plt.style.use('seaborn')
plt.rcParams["figure.figsize"] = [5, 8]

x = np.arange(-4, 5)
y = x**2  # This is x squared. 

plt.scatter(x, y)

plt.axis('equal')
plt.title('$X = Y^2$', fontsize=20)
plt.xlabel('X', fontsize=14)
plt.ylabel('Y', fontsize=14, rotation=0)
plt.xticks([-4, -2, 0, 2, 4])
plt.yticks([0, 1, 4, 9, 16])

# Calculate the Pearson correlation coefficient:
print('r =', np.corrcoef(x, y)[0, 1])


r = 0.0



Surely there is a relation between X and Y in this example, and yet the Pearson correlation coefficient is zero.