pywhy_stats.independence_test#

independence_test(X, Y, condition_on=None, method=Methods.AUTO, **kwargs)[source]#

Perform a (conditional) independence test to determine whether X and Y are independent.

The test may be conditioned on an optional set of variables. This is, test whether X _||_ Y | condition_on, where the null hypothesis is that X and Y are independent.

Parameters:
Xarray_like, shape (n_samples, n_features_x)

Data matrix for X.

Yarray_like, shape (n_samples, n_features_y)

Data matrix for Y.

condition_onarray_like or None, shape (n_samples, n_features_z), optional

Data matrix for the conditioning variables. If None is given, an unconditional test is performed.

methodMethods, optional

Independence test method from the pywhy_stats.Methods enum. Default is Methods.AUTO, which will automatically select an appropriate method.

**kwargsdict or None, optional

Additional keyword arguments to be passed to the specific test method

Returns:
resultPValueResult

An instance of the PValueResult data class, containing the p-value, test statistic, and any additional information related to the independence test.

See also

pywhy_stats.independence.fisherz

Fisher’s Z test for independence

pywhy_stats.independence.kci

Kernel Conditional Independence test