Discrete CI Tests module

causalai.models.common.CI_tests.discrete_ci_tests

class causalai.models.common.CI_tests.discrete_ci_tests.DiscreteCI_tests(method='pearson')

Performs CI test for discrete variables using the specified method. The null hypothesis for the test is X is independent of Y given Z.

__init__(method='pearson')
Parameters:

method (str) --

Options:

  • "pearson": "Chi-squared test"

  • "log-likelihood": "G-test or log-likelihood"

  • "freeman-tukey": "Freeman-Tukey Statistic"

  • "mod-log-likelihood": "Modified Log-likelihood"

  • "neyman": "Neyman's statistic"

run_test(x: ndarray, y: ndarray, z: ndarray | None = None) Tuple[float, float]

compute the test statistics and pvalues

Parameters:
  • data_x (ndarray) -- input data for x

  • data_y (ndarray) -- input data for y

  • data_z (ndarray) -- input data for z

Returns:

Returns a tuple of 2 floats-- test statistic and the corresponding pvalue

Return type:

tuple of floats

class causalai.models.common.CI_tests.discrete_ci_tests.DiscreteCI_tests(method='pearson')

Bases: object

Performs CI test for discrete variables using the specified method. The null hypothesis for the test is X is independent of Y given Z.

run_test(x: ndarray, y: ndarray, z: ndarray | None = None) Tuple[float, float]

compute the test statistics and pvalues

Parameters:
  • data_x (ndarray) -- input data for x

  • data_y (ndarray) -- input data for y

  • data_z (ndarray) -- input data for z

Returns:

Returns a tuple of 2 floats-- test statistic and the corresponding pvalue

Return type:

tuple of floats