I want to test a sample correlation $r$ for significance ($n=16$), using p-values, in Python. As I have understood from this question, I can achieve that by using Fisher's z-transform.
Is there a Python module, which allows easy use of Fisher's z-transform?
I have not been able to find the functionality in SciPy or Statsmodels. So far, I have had to write my own messy temporary function:
import numpy as np
from scipy.stats import zprob
def z_transform(r, n):
z = np.log((1 + r) / (1 - r)) * (np.sqrt(n - 3) / 2)
p = zprob(-z)
return p
Best Answer
The Fisher transform equals the inverse hyperbolic tangent/arctanh, which is implemented for example in numpy. The inverse Fisher transform/tanh can be dealt with similarly.
Moreover, numpy's function for Pearson's correlation also gives a p value.