Skip to content

correlations

Correlations between variables.

Correlation matrices are square polars.DataFrames: one column per variable, rows in the same order as the columns.

  • pearson and spearman: every pair in one lazy select, each on the rows where both values are present (pandas' pairwise-complete semantics).
  • kendall: scipy's tau-b on the materialised numeric columns.
  • cramers: Cramér's V (bias corrected) from lazy cross-tabulations.
  • auto: Spearman between numeric variables, Cramér's V when a categorical variable is involved (numeric variables are first cut into correlations.auto.n_bins equal-width bins).

phi_k from the pandas version is not available: the phik package requires pandas.

Classes

Functions:

cramers_corrected_stat(table, correction=True)

Cramér's V with the bias correction of Bergsma (2013).

Args: table: contingency table of two variables. correction: Yates' continuity correction of the chi-squared statistic.

calculate_correlation(config, df, correlation_name, summary)

One correlation matrix, or None when it is empty or fails.

Args: config: report settings. df: the typed frame (columns cast to their inferred types). correlation_name: auto, pearson, spearman, kendall or cramers. summary: the description of every column.

perform_check_correlation(correlation_matrix, threshold)

The variables highly correlated with each variable.

Args: correlation_matrix: a square correlation matrix. threshold: the absolute correlation above which variables are flagged.