Utils¶
Utility functions and helper modules.
Statistics¶
Statistical utilities and helper functions.
Statistical utilities and helper functions.
- statqa.utils.stats.calculate_effect_size(data1, data2=None, effect_type='cohen_d')[source]¶
Calculate effect size for statistical tests.
- Parameters:
data1 (Series | ndarray[Any, dtype[floating[Any]]] | float) – First sample or correlation coefficient
data2 (Series | ndarray[Any, dtype[floating[Any]]] | None) – Second sample (for two-sample tests)
effect_type (Literal['cohen_d', 'r_to_d', 'cramers_v', 'eta_squared']) – Type of effect size (‘cohen_d’, ‘r_to_d’, ‘cramers_v’, ‘eta_squared’)
- Returns:
Effect size value
- Raises:
ValueError – If invalid effect_type or incompatible data
NotImplementedError – If effect_type is not yet implemented
- Return type:
- statqa.utils.stats.cohens_d(group1, group2)[source]¶
Calculate Cohen’s d effect size for two groups.
- statqa.utils.stats.cramers_v(contingency_table)[source]¶
Calculate Cramér’s V effect size for categorical associations.
- statqa.utils.stats.correct_multiple_testing(p_values, method='fdr_bh', alpha=0.05)[source]¶
Apply multiple testing correction to p-values.
- Parameters:
p_values (list[float] | ndarray[Any, dtype[floating[Any]]]) – List or array of p-values
method (Literal['bonferroni', 'fdr_bh', 'fdr_by']) – Correction method (‘bonferroni’, ‘fdr_bh’, ‘fdr_by’) - bonferroni: Bonferroni correction (most conservative) - fdr_bh: Benjamini-Hochberg FDR (recommended) - fdr_by: Benjamini-Yekutieli FDR (more conservative)
alpha (float) – Significance level
- Returns:
Tuple of (reject, corrected_p_values) - reject: Boolean array indicating which tests reject null - corrected_p_values: Adjusted p-values
- Raises:
ValueError – If correction method is not supported
- Return type:
tuple[ndarray[Any, dtype[bool]], ndarray[Any, dtype[floating[Any]]]]
- statqa.utils.stats.robust_stats(data)[source]¶
Calculate robust statistics for potentially outlier-heavy data.
- statqa.utils.stats.detect_outliers(data, method='iqr', threshold=1.5)[source]¶
Detect outliers in data.
- Parameters:
data (Series | ndarray[Any, dtype[floating[Any]]]) – Input data
method (Literal['iqr', 'mad', 'zscore']) – Detection method (‘iqr’, ‘mad’, ‘zscore’)
threshold (float) – Threshold for outlier detection - iqr: Multiplier for IQR (default 1.5) - mad: Multiplier for MAD (default 3.0 recommended) - zscore: Z-score threshold (default 3.0)
- Returns:
Boolean array indicating outliers
- Raises:
ValueError – If outlier detection method is not supported
- Return type:
I/O¶
Input/output utilities for loading and saving data.
I/O utilities for loading and saving data.
- statqa.utils.io.load_data(source, file_pattern='(?i)\\.csv$', **kwargs)[source]¶
Load data from various sources.
Logging¶
Logging configuration and utilities.
Simple logging setup for statqa.
Provides minimal logging configuration with debug support via environment variable. No complex logging infrastructure - just simple, useful debugging.