Skip to main content

Simple statistical assumption checks for ANOVA, linear regression, and logistic regression.

Project description

assumpcheck

assumpcheck is a small Python package for checking core assumptions for:

  • ANOVA
  • Linear regression
  • Logistic regression

The package is designed to stay simple:

  • concise terminal output by default
  • plots only when they matter
  • mitigation suggestions when something fails
  • optional structured output for programmatic use

Installation

pip install "git+https://github.com/Josiah-DeValois/assumpcheck.git"

Once the package is published on PyPI, the installation target will become:

pip install assumpcheck

The package currently depends on:

  • numpy
  • pandas
  • scipy
  • statsmodels
  • matplotlib

Public API

from assumpcheck import (
    check_anova,
    check_linear_regression,
    check_logistic_regression,
)

ANOVA

report = check_anova(y=y, groups=groups)

Linear regression

report = check_linear_regression(model=fitted_ols_model)

Logistic regression

report = check_logistic_regression(model=fitted_logit_model)

Quickstart

import numpy as np
import pandas as pd

from assumpcheck import check_linear_regression

rng = np.random.default_rng(27)
X = pd.DataFrame(
    {
        "x1": rng.normal(size=35),
        "x2": rng.normal(size=35),
    }
)
y = 1.0 + 1.8 * X["x1"] - 0.6 * X["x2"] + rng.normal(scale=0.35, size=35)

report = check_linear_regression(
    X=X,
    y=y,
    design_independent=True,
    plots_on_fail=False,
)

Typical output looks like:

LINEAR REGRESSION ASSUMPTION CHECKS
[PASS] Linearity
[PASS] Independence
[PASS] Normality of residuals
[PASS] Homoscedasticity
[PASS] Multicollinearity
[WARN] Extreme influential points

Summary: 5 pass, 1 warn

Example output

ANOVA ASSUMPTION CHECKS
[INFO] Independence
[PASS] Normality of residuals
[PASS] Equal variance across groups
[FAIL] Extreme outliers

Summary: 2 pass, 1 fail, 1 info

Details:
- Extreme outliers [FAIL]
  Metric: Max |standardized residual| = 3.420; flagged points > 3: 1
  Threshold: Values above 2 deserve review and values above 3 are concerning.
  Interpretation: At least one observation has a standardized residual above the common concern threshold.
  Possible mitigation:
    - Verify data entry for flagged cases.
    - Check whether the observation is legitimate but unusual.
    - Consider a transformation, robust method, or nonparametric alternative if outliers remain influential.

Options

All three public functions support these core options:

  • alpha=0.05
  • show_all=False
  • plots_on_fail=True
  • verbose=False
  • return_dict=False
  • design_independent=None

Additional model-specific option:

  • check_linear_regression(..., ordered=False)

Output behavior

Default behavior:

  • prints a concise summary
  • shows plots for failed or warning-level checks if plots_on_fail=True
  • returns an AssumptionReport object

Optional behavior:

  • verbose=True prints detail for every check
  • show_all=True prints all details and shows all available plots
  • return_dict=True returns a serializable dictionary

Independence handling

By default, independence is treated as a design question:

  • design_independent=None gives an INFO result
  • design_independent=True gives a PASS unless an ordered linear model also shows autocorrelation warnings
  • design_independent=False gives a FAIL

Current checks

ANOVA

  • Independence
  • Normality of residuals
  • Equal variance across groups
  • Extreme outliers

Linear regression

  • Linearity
  • Independence
  • Normality of residuals
  • Homoscedasticity
  • Multicollinearity
  • Extreme influential points

Logistic regression

  • Linearity in the log-odds
  • Independence
  • Multicollinearity
  • Extreme influential points
  • Adequate sample / no separation
  • Model fit summary via ROC / AUC

Notes on the MVP

  • The package prioritizes statsmodels models first.
  • Thresholds are intentionally presented as heuristics.
  • Logistic ROC / AUC is treated as a fit diagnostic, not a strict assumption.
  • Some diagnostics need access to original data or design metadata to be fully informative.
  • The current influence heuristics are intentionally conservative, so clean linear or logistic examples may still emit a WARN.

Examples

  • Script: examples/basic_usage.py
  • Notebook: examples/assumpcheck_examples.ipynb

To rebuild the executed notebook and example plot assets:

python examples/build_workflow_artifacts.py

Tests

Run the test suite with:

python -m pytest -q

Release Process

For the first public release to TestPyPI and PyPI using GitHub Trusted Publishing, see RELEASING.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

assumpcheck-0.1.0.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

assumpcheck-0.1.0-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file assumpcheck-0.1.0.tar.gz.

File metadata

  • Download URL: assumpcheck-0.1.0.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.10

File hashes

Hashes for assumpcheck-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9e8fff464ef30219f413950ec944fb672e86a6af19720521fda7f377924bc3a7
MD5 ebf23f83f0e5acc377aa16dd7c168740
BLAKE2b-256 8f760bf5aa796baebe9ce0378e85a91416d8827d892e6e11f6bb1b23f2fd5aa3

See more details on using hashes here.

File details

Details for the file assumpcheck-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: assumpcheck-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.10

File hashes

Hashes for assumpcheck-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c079b663307434e6c6ad15ba598c1670e4b3aa46e62246f7857d7e1ac2bb2f6
MD5 af6a4acccc4979303422f95a7d6a0326
BLAKE2b-256 97f4e7c82c661d4e5cab6dfac9d14d343e43c1992882ffd7eb60ec86ba6aff1d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page