gemmr.sample_analysis.macros.calc_p_value

gemmr.sample_analysis.macros.calc_p_value(estr, X, Y, permutations=999, fit_params=None, random_state=0)

Calculate permutation-based p-value.

The p-value is calculated based on the attribute “assocs_[0]” of the fitted estimator.

Parameters:
  • estr (sklearn-style estimator) – estimator used to analyze the data, needs to be compatible with analyzers in ccapwr.sample_analysis.analyzers

  • X (np.ndarray (n_samples, n_X_features)) – dataset X

  • Y (np.ndarray (n_samples, n_Y_features)) – dataset Y

  • permutations (int > 1 or np.ndarray (n_permutations, n_samples)) – if int indicates the number of permutations to perform, and all possible permutations are allowed, if == 0 then np.nan is returned; if np.ndarray each row gives one set of permutation indices (i.e. the set of values in each row must be a permutation of [0, n_samples) and the order of columns are assumed to correspond to the order of rows of X and Y), if length of array is 0 then np.nan is returned

  • fit_params (dict) – keyword-arguments for estr.fit

  • random_state (None, int or rng-instance) – random seed

Returns:

p_value – the permutation-based p-value

Return type:

float between 0 and 1