Metadata-Version: 2.5
Name: apatools
Version: 0.3.0
Summary: A toolbox for statistical and meta-analysis, and APA-compliant reporting of quantitative results.
Project-URL: Homepage, https://github.com/Ellariel/apatools
Project-URL: Documentation, https://ellariel.github.io/apatools/
Project-URL: Repository, https://github.com/Ellariel/apatools
Project-URL: Issues, https://github.com/Ellariel/apatools/issues
Project-URL: Changelog, https://github.com/Ellariel/apatools/blob/main/CHANGELOG.md
Author-email: Danila Valko <danila.valko@proton.me>
License-Expression: MIT
License-File: LICENSE
Keywords: APA,MLM,RLM,SEM,effect size,meta-analysis,panel data,propensity score matching,regression,reporting,spatial regression,statsmodels
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Requires-Python: >=3.10
Requires-Dist: numpy>=2.0.2
Requires-Dist: scipy>=1.13.1
Provides-Extra: all
Requires-Dist: graphviz>=0.20.3; extra == 'all'
Requires-Dist: libpysal; extra == 'all'
Requires-Dist: linearmodels>=6.0; extra == 'all'
Requires-Dist: matplotlib>=3.8; extra == 'all'
Requires-Dist: networkx>=3.2; extra == 'all'
Requires-Dist: pandas>=2.2.3; extra == 'all'
Requires-Dist: patsy; extra == 'all'
Requires-Dist: psmpy>=0.3.13; extra == 'all'
Requires-Dist: semopy>=2.3.11; extra == 'all'
Requires-Dist: spreg>=1.9.0; extra == 'all'
Requires-Dist: statsmodels>=0.14.4; extra == 'all'
Provides-Extra: docs
Requires-Dist: furo; extra == 'docs'
Requires-Dist: myst-parser>=3; extra == 'docs'
Requires-Dist: sphinx-copybutton; extra == 'docs'
Requires-Dist: sphinx>=7.3; extra == 'docs'
Provides-Extra: graphviz
Requires-Dist: graphviz>=0.20.3; extra == 'graphviz'
Requires-Dist: pandas>=2.2.3; extra == 'graphviz'
Requires-Dist: semopy>=2.3.11; extra == 'graphviz'
Provides-Extra: lib
Requires-Dist: pandas>=2.2.3; extra == 'lib'
Requires-Dist: statsmodels>=0.14.4; extra == 'lib'
Provides-Extra: linearmodels
Requires-Dist: libpysal; extra == 'linearmodels'
Requires-Dist: linearmodels>=6.0; extra == 'linearmodels'
Requires-Dist: pandas>=2.2.3; extra == 'linearmodels'
Requires-Dist: patsy; extra == 'linearmodels'
Requires-Dist: spreg>=1.9.0; extra == 'linearmodels'
Provides-Extra: lm
Requires-Dist: pandas>=2.2.3; extra == 'lm'
Requires-Dist: statsmodels>=0.14.4; extra == 'lm'
Provides-Extra: networkx
Requires-Dist: matplotlib>=3.8; extra == 'networkx'
Requires-Dist: networkx>=3.2; extra == 'networkx'
Requires-Dist: pandas>=2.2.3; extra == 'networkx'
Requires-Dist: semopy>=2.3.11; extra == 'networkx'
Provides-Extra: plm
Requires-Dist: libpysal; extra == 'plm'
Requires-Dist: pandas>=2.2.3; extra == 'plm'
Requires-Dist: patsy; extra == 'plm'
Requires-Dist: spreg>=1.9.0; extra == 'plm'
Provides-Extra: psm
Requires-Dist: pandas>=2.2.3; extra == 'psm'
Requires-Dist: psmpy>=0.3.13; extra == 'psm'
Provides-Extra: sem
Requires-Dist: pandas>=2.2.3; extra == 'sem'
Requires-Dist: semopy>=2.3.11; extra == 'sem'
Provides-Extra: slm
Requires-Dist: libpysal; extra == 'slm'
Requires-Dist: pandas>=2.2.3; extra == 'slm'
Requires-Dist: spreg>=1.9.0; extra == 'slm'
Requires-Dist: statsmodels>=0.14.4; extra == 'slm'
Description-Content-Type: text/markdown

# apatools: a toolbox for statistical analysis and APA-compliant reporting

One convenient interface to the most common tools: apatools wraps statsmodels, spreg, linearmodels, semopy and psmpy
and, optionally, the R packages lavaan, plm, splm and spdep, and returns tidy tables with the statistics a manuscript
needs, together with the specification tests, effect conversions and reliability coefficients that go with them.

**What sets it apart:** no method is just linked to an engine and trusted. Methods are benchmarked against independent
references (mostly R packages, otherwise the definition itself), and the documentation discloses the design decisions
behind every module, its caveats, and where and why the numbers differ from R; the few methods without a benchmark are
marked as such.

## Install

```shell
pip install apatools                # calc and format: numpy and scipy only
pip install "apatools[lm,plm]"      # extras per module; "apatools[all]" installs everything
```

Python 3.10 or newer; the development version: `pip install git+https://github.com/ellariel/apatools.git`.
Importing a module without its extra gives an `ImportError` that names the extra to install.

| extra | module | brings in |
|---|---|---|
| (none) | `calc`, `format` | numpy, scipy |
| `lm` | `lm` | pandas, statsmodels |
| `slm` | `slm` | pandas, statsmodels, spreg, libpysal |
| `plm` | `plm` | pandas, spreg, libpysal, patsy |
| `sem` | `sem` | pandas, semopy |
| `psm` | `psm` | pandas, psmpy |
| `lib` | `lib` | pandas, scipy, statsmodels |
| `linearmodels` | `plm` with the linearmodels backend | the `plm` extra and linearmodels |
| `graphviz` / `networkx` | `sem_plot` diagrams with Graphviz / with networkx and matplotlib | the `sem` extra and the drawing packages |
| `docs` | building the documentation | sphinx, furo, myst-parser |

Three engines run in R (`sem(engine="lavaan")`, `sem_plot(engine="lavaan")`, `plm(backend="splm")`): install R and,
in R, `install.packages(c("lavaan", "semPlot", "plm", "splm", "spdep"))`. `Rscript` is found on the `PATH`, in the usual
install locations, through the environment variable `APATOOLS_RSCRIPT` or the argument `rscript`.

## A first look

```python
from apatools.lm import lm, lm_report, lm_tests
from apatools.plm import plm, plm_report, plm_tests, plm_effects

results, metrics = lm(data, "y", ["x1", "x2"], model=["ols", "rlm"])
print(lm_report(results, metrics))                              # APA table: b, SE, t, p, stars, CI, fit line
print(lm_tests(results, format_pval=True, decimal=3))           # diagnostics that suit each kind of model

results, metrics = plm(panel, "y", ["x1", "x2"], w=w, entity="county", time="year",
                       model=["pooled", "fe", "re", "slm_fe"], effects="twoway")
print(plm_report(results, metrics))
print(plm_tests(results))                                       # Hausman, Mundlak, F and LM tests
print(plm_effects(results))                                     # direct, indirect and total effects
```

## What is in it

| module | does |
|---|---|
| `apatools.calc` | conversions between r, d, t, z, F, p, odds ratios; confidence intervals |
| `apatools.format` | APA formatting of p-values, correlations and stars |
| `apatools.lm` | OLS, RLM, GLM, QuantReg, MixedLM (statsmodels): tables and diagnostic tests |
| `apatools.slm` | OLS, spatial lag and error models (spreg): tables, spatial diagnostics, direct / indirect / total effects |
| `apatools.plm` | pooled, FE, RE panel models, optionally spatial (spreg, linearmodels, R's plm / splm): tables, specification tests, effects |
| `apatools.sem` | structural equation models (semopy, lavaan), reports, path diagrams (Graphviz, networkx, semPlot) |
| `apatools.psm` | propensity score matching (psmpy) and covariate balance |
| `apatools.lib` | bootstrap, Cronbach's alpha, McDonald's omega (robust, bifactor), Fleiss' kappa, Krippendorff's alpha, correlations, HTMT, Gini |

## Documentation

The documentation is at **[ellariel.github.io/apatools](https://ellariel.github.io/apatools/)** (GitHub Pages, built from
the main branch). Its source is in [`docs/`](docs/) (Sphinx; build it locally with `pip install -e ".[all,docs]"` and
`sphinx-build -W -b html docs docs/_build/html`):

* a user-guide page per module, each with the **design choices and caveats** of the module and **where it differs from
  R**;
* the [validation overview](docs/validation.md): what was compared with what, and where apatools intentionally does not
  mirror R;
* the [software](docs/software.md) page (what to cite for each engine), and the literature at the end of each module page;
* the API reference, generated from the docstrings, and the [changelog](CHANGELOG.md).

## Citing

If you use apatools, please cite it (see [`CITATION.cff`](CITATION.cff); GitHub offers the formatted citation under
"Cite this repository"; the package is on [PyPI](https://pypi.org/project/apatools/)) and, as the numbers come from the
engines, also the software that produced them: the [software page](docs/software.md) of the documentation says what to
cite for each engine. Report the version you used (`apatools.__version__`).

## License

MIT, see [LICENSE](LICENSE).
