AShrink
AShrink provides empirical Bayes shrinkage for noisy effect estimates, count rates, binomial probabilities, effect estimates measured across several conditions, and regression from outcomes and predictors, including Gaussian random intercepts. It learns finite-mixture weights from the data and returns posterior summaries.
The adaptive-shrinkage method follows Stephens (2017). The R packages ashr and mashr are numerical references for matched methods. Count models use conjugate mixtures with a specified common mode. AShrink is an independent implementation; the original authors have not endorsed it.
Install from source
python -m pip install 'git+https://github.com/nilson01/ashrink.git'
From a local checkout, use python -m pip install ..
NumPy and SciPy are runtime dependencies. Plotting and pandas tables use the
plot and table extras. No R runtime is required.
First example
from ashrink import fit
result = fit(
[-1.4, -0.6, -0.1, 0.0, 0.2, 0.7, 1.8, 2.2],
[0.7, 0.4, 0.5, 0.3, 0.5, 0.4, 0.8, 0.7],
scales=[0.2, 0.6, 1.5],
)
print(result.format_summary())
intervals = result.interval(level=0.95)
The inputs are effect estimates and their standard errors. scales gives
fixed normal-prior component standard deviations; the fit estimates their
mixture weights. Returned intervals are posterior credible intervals,
conditional on those fitted weights. The first three posterior means are
[-0.764278, -0.306851, -0.032956].
(a) Input estimates and posterior means. (b) Equal-tailed 95% credible intervals, conditional on the fitted prior. These are fixed illustrative inputs; the plotted values are available as CSV.
Methods
| Analysis | Function | Prior components |
|---|---|---|
| Gaussian or Student-t effect estimates | fit |
Normal, symmetric uniform or asymmetric uniform |
| Counts with exposure times | fit_poisson |
Gamma components sharing a specified mode |
| Successes out of trials | fit_binomial |
Beta components sharing a specified mode |
| Effects across conditions | fit_multivariate |
Multivariate normals with supplied covariance patterns |
| Continuous outcomes and predictors | fit_regression |
Normal-mixture coefficient priors; variational inference |
| Binary outcomes or successes/trials and predictors | fit_logistic_regression |
Normal-mixture coefficient priors; logistic bound |
| Counts and predictors | fit_poisson_regression |
Normal-mixture coefficient priors; Poisson variational inference |
| Grouped continuous outcomes | fit_mixed_regression |
Shrunk fixed effects and Gaussian random intercepts |
Each method provides posterior estimates, credible intervals, null/sign
probabilities, tables and saved results. Plots use the plot extra.
See the reference manual (PDF),
API guide, worked examples,
regression
and numerical limits.
Reference checks record the installed-R cases and
independent analytic checks. Installed-wheel tests pass on macOS and Linux with
Python 3.10 and 3.14, and on Windows Server 2025 with Python 3.13. See the
tested environments
for versions and CI evidence.
Citation
Cite the original statistical method used in an analysis and record the AShrink version or commit. See NOTICE.md for attribution and licenses.
Metadata
Release files for ashrink 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ashrink-0.1.0.tar.gz | 624.3 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ashrink-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 699.5 kB
Release files / ashrink-0.1.0.tar.gz
| Download URL | ashrink-0.1.0.tar.gz |
|---|---|
| Size | 624.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
87b5e08f7b8952c41d61b0713d0add6b10cde302ec34a2d77dcf5b234b366a53
|
|
BLAKE2b-256 checksum How to use checksums |
23f8c748fddc047c371dfb46abdf39de3d22bf7d0f5a7f6509cc0167217eff02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logRelease files / ashrink-0.1.0-py3-none-any.whl
| Download URL | ashrink-0.1.0-py3-none-any.whl |
|---|---|
| Size | 75.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d1300591239bb3606a0ce1dbde4fb623cc2d82576321c488b2bf737dc586f3f3
|
|
BLAKE2b-256 checksum How to use checksums |
ef58b6ddabe947e64d56fa600d6f80474e10c80ccbf7db82ac1d47b13b72ce73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logSecurity for ashrink 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for ashrink-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.