Pair-based Estimators of Infection and Removal Rates
This Python package is an AI-translated version of the R package github.com/sdtemple/peirrs.
Install
From PyPI (recommended)
pip install peirrs
From source (development)
Install from the local source directory using pip:
pip install -e .
Requires NumPy and SciPy for numerical computations.
Requirements
This package requires Python 3.6+ with the following dependencies:
- NumPy 1.19+
- SciPy 1.5+
I developed the package with versions:
- Python 3.9+
- NumPy 2.0+
- SciPy 1.7+
Usage
Estimate infection and removal rates with partially observed removal and infection times. The following functions are the ones you would likely use, in order of relevance:
Real data analysis
peirrs.estimators.peirr_tau()- EM-based estimationpeirrs.estimators.peirr_bayes()- Bayesian estimation with MCMCpeirrs.estimators.peirr_bootstrap()- Bootstrap resamplingpeirrs.estimators.peirr_imputed()- Imputation-based estimation
Simulation experiments
peirrs.simulate.simulator()- Core simulation wrapper
All functions have docstrings. As a result, you can get help for instance with:
from peirrs.estimators import peirr_tau
help(peirr_tau)
print(peirr_tau.__doc__)
There are also functions with the suffixes _multitype() and _spatial() for estimators with multiple classes and spatial kernels, respectively:
Multitype estimators (in peirrs.multitype.estimators_multitype)
peirr_tau_multitype()- Class-specific EM estimationpeirr_bayes_multitype()- Class-specific Bayesian MCMCpeirr_bootstrap_multitype()- Class-specific bootstrap
Spatial tools (in peirrs.spatial)
peirr_tau_spatial()- Spatial EM estimationpeirr_bayes_spatial()- Spatial Bayesian MCMCsimulate_distance_matrix()- Generate spatial distance matricessimulator_spatial()- Spatial simulation wrapper
The peirr_bootstrap() function does not provide confidence intervals but rather bootstrap samples. You can perform bias correction or interval estimation according to Wikipedia.
Warning !!!
- I used AI chatbots to translate this from an R package.
- Mostly as a personal experiment ...
- PBLA functions are not available.
- Some light units tests are available.
- Except for complete data, the
_bayesfunctions are barely tested.
- Except for complete data, the
- Some spot reading resulted in:
- Manually fixes to the
utils.tau_momentfunction - Manually fixed to the
_bayesfunctions
- Manually fixes to the
- I checked that some simulation study results were similar.
- The results are qualitatively the same.
- But, the estimator computes adds many small float numbers.
- The snowball effect leads to some slight differences between Python and R estimates.
- I checked for sensible results in a small IPython notebook.
Metadata
Release files for peirrs 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| peirrs-1.0.2.tar.gz | 40.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| peirrs-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 85.6 kB
Release files / peirrs-1.0.2.tar.gz
| Download URL | peirrs-1.0.2.tar.gz |
|---|---|
| Size | 40.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a944f0a6ccaf009528ab4fd145ef8c34e7b8662ac689a981454b470625307436
|
|
BLAKE2b-256 checksum How to use checksums |
f3b81b0303b67056151431aedc4fa1c42913b43f70d323738c930553a667a594
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.10
|
Release files / peirrs-1.0.2-py3-none-any.whl
| Download URL | peirrs-1.0.2-py3-none-any.whl |
|---|---|
| Size | 45.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
343c4004edfeb2e77929cf78c727c22fa7b6be0cfddc3ba6e3d7110091a4aeff
|
|
BLAKE2b-256 checksum How to use checksums |
d31802f086566da691f17535fd7b4a3253be16e789bd828d39c15eb9c5955d24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.10
|