Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def assoc(X, Y, Zs):
"""Measure for (conditional) association between variables. Use negative
p-value of independence test.
"""
return 1 - chi_square(X, Y, Zs, self.data)[1]
def test_conditional_independence(
self, X, Y, Zs=[], method="chi_square", tol=0.01, **kwargs
):
if method == "chi_square":
param, p_value = chi_square(
X=X, Y=Y, Z=Zs, data=self.data, state_names=self.state_names
)
if p_value >= tol:
return True
else:
return False
elif method == "pearsonr":
param, p_value = pearsonr(X=X, Y=Y, Z=Zs, data=self.data, **kwargs)
if abs(param) <= tol:
return True
else:
return False