Skip to main content

A unified statistics interface for running and displaying simple stats, using SciPy and statsmodels.

Project description

unistat

A unified statistics interface for simple running and displaying of statistics, as commonly used in medicine and biostatistics. unistat is built on top of SciPy and statsmodels, and aims to integrate coding and displaying results of or each individual test, so that it's faster to run tests, and display results for easy reporting.

Features

  • Regression Analysis:
    • Univariate and multivariable linear, logistic, and log-binomial regression
    • Integrated display of:
      • VIF
      • Regression coefficients (linear regression),
      • ORs (logit)
      • risk ratios (log-binomial regression)
    • Easy printing methods for quick copy-pasting of coefficients & CIs
  • Contingency Tables:
    • Multiclass and 2x2 table support, with displays for absolute & percent counts
    • Integrated display of $\chi^2$ & odds ratios
    • For 2x2 tables, displays Fisher's exact test with indicator for which to use
      • Will likely replace include Boschloo's exact test in the near future
  • Correlation:
    • Pearson and Spearman correlation for continuous variables.
  • 2-Sample Tests:
    • Parametric (t-test) and nonparametric (Mann-Whitney U) comparisons
  • Resampling methods:
    • Bootstrap confidence intervals for means & medians
    • Permutation hypothesis tests for means, medians, t-tests, and Mann-Whitney U-tests

Installation

Install StatsPy using pip (assuming it's published to PyPI):

pip install unistat

Ensure dependencies are installed:

  • Python 3.10+
  • pandas
  • numpy
  • scipy
  • statsmodels

Usage

Below are brief examples of functionality of some unistat modules. For comprehensive documentation, see our ReadTheDocs page.

Boostrapped 95% CI for Difference of Means

import pandas as pd
from unistat.resampling import TwoSeriesBootstrap

# Observed data
test = pd.Series([1, 2, 3, 4, 5], name='test group')
control = pd.Series([2, 3, 4, 5, 6], name='control group')

# Bootstrap test for difference of means
bootstrap = TwoSeriesBootstrap(test, control, test_type='means', n_resamples=1000)
print(bootstrap.results)

Output:

          test Ha   control
n     5.000000  =  5.000000
mean  3.000000  =  4.000000
std   1.581139  =  1.581139
min   1.000000  =  2.000000
max   5.000000  =  6.000000
            Bootstrapped Hypothesis Test
                * Test Stat: Difference of Means
                * Test Group: test group
                * Control Group: control group
            
        Observed Test Stat: -1.0000
        Mean of Bootstrap Dist.: -0.9962
        SEM of Bootstrap Dist.: 0.8993
        BCa 95% CI: -2.8000 to 0.8000
        No hypothesis testing performed.

Documentation

Detailed usage, including API references and examples, is available at our ReadTheDocs page (placeholder).

Experimental Features

  • log-binomial regression (LogBinStats)
    • Buggy implementation, and more research into functionality required
  • Bootstrapped p-values
    • Results given are not wrong, but there are more robust means to calculate a bootstrapped hypothesis test, particularly in cases of heteroskedastic groups
    • Bootstrapped CIs are reliable
    • Permuted p-values are reliable

Experimental features are prone to unannounced changes. Features may also contain statistical errors or faux pas, buggy implementation, or be otherwise unreliable. If these features are used, it is highly recommended that results are verified using more reliable means (e.g. verify a bootstrapped p-value with a permutation or asymptotic p-value to ensure the results are at least ballpark correct), particularly if results are intended for publication or other critical applications.

Contributing

Contributions welcome. Please submit issues or pull requests on GitHub. Follow NumPy style guidelines, as also followed by SciPy and statsmodels.

License

unistat is licensed under the MIT License. See the LICENSE file for details.

Author

unistat is created and maintained by David C. Limón, 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

unistat-0.2.2.tar.gz (32.0 kB view details)

Uploaded Source

Built Distribution

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

unistat-0.2.2-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

Details for the file unistat-0.2.2.tar.gz.

File metadata

  • Download URL: unistat-0.2.2.tar.gz
  • Upload date:
  • Size: 32.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for unistat-0.2.2.tar.gz
Algorithm Hash digest
SHA256 4bb85ebfffd36c9a13b2f2c282e74e02cd04f49a014436be03f3f3c6b6bf168c
MD5 dc985e2b85a1e259c5928d8b3a541081
BLAKE2b-256 5eba17eef1454e30476aa87f0e46da3b4ce85e76e2ea4e0d9a498e92c717f5ec

See more details on using hashes here.

File details

Details for the file unistat-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: unistat-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 29.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for unistat-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 08433f561936bf912e2b898b70b19269e3ed891795145fa7d55fc506dcb7be06
MD5 3f83701d47191e5892fc5bf311ee07f7
BLAKE2b-256 9b5be30164412dc7273cf285ca4caf4affeedc022ba9199ed63913318b71f361

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