Name | pingouin JSON |
Version |
0.5.5
JSON |
| download |
home_page | None |
Summary | Pingouin: statistical package for Python |
upload_time | 2024-09-04 10:42:51 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | GPL-3.0 |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
.. -*- mode: rst -*-
|
.. image:: https://badge.fury.io/py/pingouin.svg
:target: https://badge.fury.io/py/pingouin
.. image:: https://img.shields.io/conda/vn/conda-forge/pingouin.svg
:target: https://anaconda.org/conda-forge/pingouin
.. image:: https://img.shields.io/github/license/raphaelvallat/pingouin.svg
:target: https://github.com/raphaelvallat/pingouin/blob/master/LICENSE
.. image:: https://github.com/raphaelvallat/pingouin/actions/workflows/python_tests.yml/badge.svg
:target: https://github.com/raphaelvallat/pingouin/actions
.. image:: https://codecov.io/gh/raphaelvallat/pingouin/branch/master/graph/badge.svg
:target: https://codecov.io/gh/raphaelvallat/pingouin
.. image:: https://pepy.tech/badge/pingouin/month
:target: https://pepy.tech/badge/pingouin/month
.. image:: http://joss.theoj.org/papers/d2254e6d8e8478da192148e4cfbe4244/status.svg
:target: http://joss.theoj.org/papers/d2254e6d8e8478da192148e4cfbe4244
----------------
.. image:: https://pingouin-stats.org/build/html/_images/logo_pingouin.png
:align: center
**Pingouin** is an open-source statistical package written in Python 3 and based mostly on Pandas and NumPy. Some of its main features are listed below. For a full list of available functions, please refer to the `API documentation <https://pingouin-stats.org/build/html/api.html#>`_.
1. ANOVAs: N-ways, repeated measures, mixed, ancova
2. Pairwise post-hocs tests (parametric and non-parametric) and pairwise correlations
3. Robust, partial, distance and repeated measures correlations
4. Linear/logistic regression and mediation analysis
5. Bayes Factors
6. Multivariate tests
7. Reliability and consistency
8. Effect sizes and power analysis
9. Parametric/bootstrapped confidence intervals around an effect size or a correlation coefficient
10. Circular statistics
11. Chi-squared tests
12. Plotting: Bland-Altman plot, Q-Q plot, paired plot, robust correlation...
Pingouin is designed for users who want **simple yet exhaustive statistical functions**.
For example, the :code:`ttest_ind` function of SciPy returns only the T-value and the p-value. By contrast,
the :code:`ttest` function of Pingouin returns the T-value, the p-value, the degrees of freedom, the effect size (Cohen's d), the 95% confidence intervals of the difference in means, the statistical power and the Bayes Factor (BF10) of the test.
Documentation
=============
- `Link to documentation <https://pingouin-stats.org/index.html>`_
Chat
====
If you have questions, please ask them in `GitHub Discussions <https://github.com/raphaelvallat/pingouin/discussions>`_.
Installation
============
Dependencies
------------
The main dependencies of Pingouin are :
* `NumPy <https://numpy.org/>`_
* `SciPy <https://www.scipy.org/>`_
* `Pandas <https://pandas.pydata.org/>`_
* `Pandas-flavor <https://github.com/Zsailer/pandas_flavor>`_
* `Statsmodels <https://www.statsmodels.org/>`_
* `Matplotlib <https://matplotlib.org/>`_
* `Seaborn <https://seaborn.pydata.org/>`_
In addition, some functions require :
* `Scikit-learn <https://scikit-learn.org/>`_
* `Mpmath <http://mpmath.org/>`_
Pingouin is a Python 3 package and is currently tested for Python 3.8-3.11.
User installation
-----------------
Pingouin can be easily installed using pip
.. code-block:: shell
pip install pingouin
or conda
.. code-block:: shell
conda install -c conda-forge pingouin
New releases are frequent so always make sure that you have the latest version:
.. code-block:: shell
pip install --upgrade pingouin
Development
-----------
To build and install from source, clone this repository or download the source archive and decompress the files
.. code-block:: shell
cd pingouin
python -m build # optional, build a wheel and sdist
pip install . # install the package
pip install --editable . # or editable install
pytest # test the package
Quick start
============
Click on the link below and navigate to the notebooks/ folder to run a collection of interactive Jupyter notebooks showing the main functionalities of Pingouin. No need to install Pingouin beforehand, the notebooks run in a Binder environment.
.. image:: https://mybinder.org/badge.svg
:target: https://mybinder.org/v2/gh/raphaelvallat/pingouin/develop
10 minutes to Pingouin
----------------------
1. T-test
#########
.. code-block:: python
import numpy as np
import pingouin as pg
np.random.seed(123)
mean, cov, n = [4, 5], [(1, .6), (.6, 1)], 30
x, y = np.random.multivariate_normal(mean, cov, n).T
# T-test
pg.ttest(x, y)
.. table:: Output
:widths: auto
====== ===== ============= ======= ============= ========= ====== =======
T dof alternative p-val CI95% cohen-d BF10 power
====== ===== ============= ======= ============= ========= ====== =======
-3.401 58 two-sided 0.001 [-1.68 -0.43] 0.878 26.155 0.917
====== ===== ============= ======= ============= ========= ====== =======
------------
2. Pearson's correlation
########################
.. code-block:: python
pg.corr(x, y)
.. table:: Output
:widths: auto
=== ===== =========== ======= ====== =======
n r CI95% p-val BF10 power
=== ===== =========== ======= ====== =======
30 0.595 [0.3 0.79] 0.001 69.723 0.950
=== ===== =========== ======= ====== =======
------------
3. Robust correlation
#####################
.. code-block:: python
# Introduce an outlier
x[5] = 18
# Use the robust biweight midcorrelation
pg.corr(x, y, method="bicor")
.. table:: Output
:widths: auto
=== ===== =========== ======= =======
n r CI95% p-val power
=== ===== =========== ======= =======
30 0.576 [0.27 0.78] 0.001 0.933
=== ===== =========== ======= =======
------------
4. Test the normality of the data
#################################
The `pingouin.normality` function works with lists, arrays, or pandas DataFrame in wide or long-format.
.. code-block:: python
print(pg.normality(x)) # Univariate normality
print(pg.multivariate_normality(np.column_stack((x, y)))) # Multivariate normality
.. table:: Output
:widths: auto
===== ====== ========
W pval normal
===== ====== ========
0.615 0.000 False
===== ====== ========
.. parsed-literal::
(False, 0.00018)
------------
5. One-way ANOVA using a pandas DataFrame
#########################################
.. code-block:: python
# Read an example dataset
df = pg.read_dataset('mixed_anova')
# Run the ANOVA
aov = pg.anova(data=df, dv='Scores', between='Group', detailed=True)
print(aov)
.. table:: Output
:widths: auto
======== ======= ==== ===== ======= ======= =======
Source SS DF MS F p-unc np2
======== ======= ==== ===== ======= ======= =======
Group 5.460 1 5.460 5.244 0.023 0.029
Within 185.343 178 1.041 nan nan nan
======== ======= ==== ===== ======= ======= =======
------------
6. Repeated measures ANOVA
##########################
.. code-block:: python
pg.rm_anova(data=df, dv='Scores', within='Time', subject='Subject', detailed=True)
.. table:: Output
:widths: auto
======== ======= ==== ===== ======= ======= ======= =======
Source SS DF MS F p-unc ng2 eps
======== ======= ==== ===== ======= ======= ======= =======
Time 7.628 2 3.814 3.913 0.023 0.04 0.999
Error 115.027 118 0.975 nan nan nan nan
======== ======= ==== ===== ======= ======= ======= =======
------------
7. Post-hoc tests corrected for multiple-comparisons
####################################################
.. code-block:: python
# FDR-corrected post hocs with Hedges'g effect size
posthoc = pg.pairwise_tests(data=df, dv='Scores', within='Time', subject='Subject',
parametric=True, padjust='fdr_bh', effsize='hedges')
# Pretty printing of table
pg.print_table(posthoc, floatfmt='.3f')
.. table:: Output
:widths: auto
========== ======= ======= ======== ============ ====== ====== ============= ======= ======== ========== ====== ========
Contrast A B Paired Parametric T dof alternative p-unc p-corr p-adjust BF10 hedges
========== ======= ======= ======== ============ ====== ====== ============= ======= ======== ========== ====== ========
Time August January True True -1.740 59.000 two-sided 0.087 0.131 fdr_bh 0.582 -0.328
Time August June True True -2.743 59.000 two-sided 0.008 0.024 fdr_bh 4.232 -0.483
Time January June True True -1.024 59.000 two-sided 0.310 0.310 fdr_bh 0.232 -0.170
========== ======= ======= ======== ============ ====== ====== ============= ======= ======== ========== ====== ========
------------
8. Two-way mixed ANOVA
######################
.. code-block:: python
# Compute the two-way mixed ANOVA
aov = pg.mixed_anova(data=df, dv='Scores', between='Group', within='Time',
subject='Subject', correction=False, effsize="np2")
pg.print_table(aov)
.. table:: Output
:widths: auto
=========== ===== ===== ===== ===== ===== ======= ===== =======
Source SS DF1 DF2 MS F p-unc np2 eps
=========== ===== ===== ===== ===== ===== ======= ===== =======
Group 5.460 1 58 5.460 5.052 0.028 0.080 nan
Time 7.628 2 116 3.814 4.027 0.020 0.065 0.999
Interaction 5.167 2 116 2.584 2.728 0.070 0.045 nan
=========== ===== ===== ===== ===== ===== ======= ===== =======
------------
9. Pairwise correlations between columns of a dataframe
#######################################################
.. code-block:: python
import pandas as pd
np.random.seed(123)
z = np.random.normal(5, 1, 30)
data = pd.DataFrame({'X': x, 'Y': y, 'Z': z})
pg.pairwise_corr(data, columns=['X', 'Y', 'Z'], method='pearson')
.. table:: Output
:widths: auto
=== === ======== ============= === ===== ============= ======= ====== =======
X Y method alternative n r CI95% p-unc BF10 power
=== === ======== ============= === ===== ============= ======= ====== =======
X Y pearson two-sided 30 0.366 [0.01 0.64] 0.047 1.500 0.525
X Z pearson two-sided 30 0.251 [-0.12 0.56] 0.181 0.534 0.272
Y Z pearson two-sided 30 0.020 [-0.34 0.38] 0.916 0.228 0.051
=== === ======== ============= === ===== ============= ======= ====== =======
------------
10. Pairwise T-test between columns of a dataframe
###################################################
.. code-block:: python
data.ptests(paired=True, stars=False)
.. table:: Pairwise T-tests, with T-values on the lower triangle and p-values on the upper triangle
:widths: auto
==== ====== ====== =====
.. X Y Z
==== ====== ====== =====
X - 0.226 0.165
Y -1.238 - 0.658
Z -1.424 -0.447 -
==== ====== ====== =====
------------
11. Multiple linear regression
##############################
.. code-block:: python
pg.linear_regression(data[['X', 'Z']], data['Y'])
.. table:: Linear regression summary
:widths: auto
========= ====== ===== ====== ====== ===== ======== ========== ===========
names coef se T pval r2 adj_r2 CI[2.5%] CI[97.5%]
========= ====== ===== ====== ====== ===== ======== ========== ===========
Intercept 4.650 0.841 5.530 0.000 0.139 0.076 2.925 6.376
X 0.143 0.068 2.089 0.046 0.139 0.076 0.003 0.283
Z -0.069 0.167 -0.416 0.681 0.139 0.076 -0.412 0.273
========= ====== ===== ====== ====== ===== ======== ========== ===========
------------
12. Mediation analysis
######################
.. code-block:: python
pg.mediation_analysis(data=data, x='X', m='Z', y='Y', seed=42, n_boot=1000)
.. table:: Mediation summary
:widths: auto
======== ====== ===== ====== ========== =========== =====
path coef se pval CI[2.5%] CI[97.5%] sig
======== ====== ===== ====== ========== =========== =====
Z ~ X 0.103 0.075 0.181 -0.051 0.256 No
Y ~ Z 0.018 0.171 0.916 -0.332 0.369 No
Total 0.136 0.065 0.047 0.002 0.269 Yes
Direct 0.143 0.068 0.046 0.003 0.283 Yes
Indirect -0.007 0.025 0.898 -0.069 0.029 No
======== ====== ===== ====== ========== =========== =====
------------
13. Contingency analysis
########################
.. code-block:: python
data = pg.read_dataset('chi2_independence')
expected, observed, stats = pg.chi2_independence(data, x='sex', y='target')
stats
.. table:: Chi-squared tests summary
:widths: auto
================== ======== ====== ===== ===== ======== =======
test lambda chi2 dof p cramer power
================== ======== ====== ===== ===== ======== =======
pearson 1.000 22.717 1.000 0.000 0.274 0.997
cressie-read 0.667 22.931 1.000 0.000 0.275 0.998
log-likelihood 0.000 23.557 1.000 0.000 0.279 0.998
freeman-tukey -0.500 24.220 1.000 0.000 0.283 0.998
mod-log-likelihood -1.000 25.071 1.000 0.000 0.288 0.999
neyman -2.000 27.458 1.000 0.000 0.301 0.999
================== ======== ====== ===== ===== ======== =======
Integration with Pandas
-----------------------
Several functions of Pingouin can be used directly as pandas DataFrame methods. Try for yourself with the code below:
.. code-block:: python
import pingouin as pg
# Example 1 | ANOVA
df = pg.read_dataset('mixed_anova')
df.anova(dv='Scores', between='Group', detailed=True)
# Example 2 | Pairwise correlations
data = pg.read_dataset('mediation')
data.pairwise_corr(columns=['X', 'M', 'Y'], covar=['Mbin'])
# Example 3 | Partial correlation matrix
data.pcorr()
The functions that are currently supported as pandas method are:
* `pingouin.anova <https://pingouin-stats.org/generated/pingouin.anova.html#pingouin.anova>`_
* `pingouin.ancova <https://pingouin-stats.org/generated/pingouin.ancova.html#pingouin.ancova>`_
* `pingouin.rm_anova <https://pingouin-stats.org/generated/pingouin.rm_anova.html#pingouin.rm_anova>`_
* `pingouin.mixed_anova <https://pingouin-stats.org/generated/pingouin.mixed_anova.html#pingouin.mixed_anova>`_
* `pingouin.welch_anova <https://pingouin-stats.org/generated/pingouin.welch_anova.html#pingouin.welch_anova>`_
* `pingouin.pairwise_tests <https://pingouin-stats.org/generated/pingouin.pairwise_tests.html#pingouin.pairwise_tests>`_
* `pingouin.pairwise_tukey <https://pingouin-stats.org/generated/pingouin.pairwise_tukey.html#pingouin.pairwise_tukey>`_
* `pingouin.pairwise_corr <https://pingouin-stats.org/generated/pingouin.pairwise_corr.html#pingouin.pairwise_corr>`_
* `pingouin.partial_corr <https://pingouin-stats.org/generated/pingouin.partial_corr.html#pingouin.partial_corr>`_
* `pingouin.pcorr <https://pingouin-stats.org/generated/pingouin.pcorr.html#pingouin.pcorr>`_
* `pingouin.rcorr <https://pingouin-stats.org/generated/pingouin.rcorr.html#pingouin.rcorr>`_
* `pingouin.ptests <https://pingouin-stats.org/generated/pingouin.ptests.html#pingouin.ptests>`_
* `pingouin.mediation_analysis <https://pingouin-stats.org/generated/pingouin.mediation_analysis.html#pingouin.mediation_analysis>`_
Development
===========
Pingouin was created and is maintained by `Raphael Vallat <https://raphaelvallat.github.io>`_, a postdoctoral researcher at UC Berkeley, mostly during his spare time. Contributions are more than welcome so feel free to contact me, open an issue or submit a pull request!
To see the code or report a bug, please visit the `GitHub repository <https://github.com/raphaelvallat/pingouin>`_.
This program is provided with NO WARRANTY OF ANY KIND. Pingouin is still under heavy development and there are likely hidden bugs. Always double check the results with another statistical software.
**Contributors**
- Nicolas Legrand
- `Richard Höchenberger <http://hoechenberger.net/>`_
- `Arthur Paulino <https://github.com/arthurpaulino>`_
- `Eelke Spaak <https://eelkespaak.nl/>`_
- `Johannes Elfner <https://www.linkedin.com/in/johannes-elfner/>`_
- `Stefan Appelhoff <https://stefanappelhoff.com>`_
How to cite Pingouin?
=====================
If you want to cite Pingouin, please use the publication in JOSS:
* Vallat, R. (2018). Pingouin: statistics in Python. *Journal of Open Source Software*, 3(31), 1026, `https://doi.org/10.21105/joss.01026 <https://doi.org/10.21105/joss.01026>`_
Acknowledgement
===============
Several functions of Pingouin were inspired from R or Matlab toolboxes, including:
- `effsize package (R) <https://cran.r-project.org/web/packages/effsize/effsize.pdf>`_
- `ezANOVA package (R) <https://cran.r-project.org/web/packages/ez/ez.pdf>`_
- `pwr package (R) <https://cran.r-project.org/web/packages/pwr/pwr.pdf>`_
- `circular statistics (Matlab) <https://www.mathworks.com/matlabcentral/fileexchange/10676-circular-statistics-toolbox-directional-statistics>`_
- `robust correlations (Matlab) <https://sourceforge.net/projects/robustcorrtool/>`_
- `repeated-measure correlation (R) <https://cran.r-project.org/web/packages/rmcorr/index.html>`_
- `real-statistics.com <https://www.real-statistics.com/>`_
Raw data
{
"_id": null,
"home_page": null,
"name": "pingouin",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "Raphael Vallat <raphaelvallat9@gmail.com>",
"keywords": null,
"author": null,
"author_email": "Raphael Vallat <raphaelvallat9@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/0e/3d/14a779790bac2d03a0d8f82c1857fc83c0ef8b1b77542b884808e55ee839/pingouin-0.5.5.tar.gz",
"platform": null,
"description": ".. -*- mode: rst -*-\n\n|\n\n.. image:: https://badge.fury.io/py/pingouin.svg\n :target: https://badge.fury.io/py/pingouin\n\n.. image:: https://img.shields.io/conda/vn/conda-forge/pingouin.svg\n :target: https://anaconda.org/conda-forge/pingouin\n\n.. image:: https://img.shields.io/github/license/raphaelvallat/pingouin.svg\n :target: https://github.com/raphaelvallat/pingouin/blob/master/LICENSE\n\n.. image:: https://github.com/raphaelvallat/pingouin/actions/workflows/python_tests.yml/badge.svg\n :target: https://github.com/raphaelvallat/pingouin/actions\n\n.. image:: https://codecov.io/gh/raphaelvallat/pingouin/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/raphaelvallat/pingouin\n\n.. image:: https://pepy.tech/badge/pingouin/month\n :target: https://pepy.tech/badge/pingouin/month\n\n.. image:: http://joss.theoj.org/papers/d2254e6d8e8478da192148e4cfbe4244/status.svg\n :target: http://joss.theoj.org/papers/d2254e6d8e8478da192148e4cfbe4244\n\n\n----------------\n\n.. image:: https://pingouin-stats.org/build/html/_images/logo_pingouin.png\n :align: center\n\n**Pingouin** is an open-source statistical package written in Python 3 and based mostly on Pandas and NumPy. Some of its main features are listed below. For a full list of available functions, please refer to the `API documentation <https://pingouin-stats.org/build/html/api.html#>`_.\n\n1. ANOVAs: N-ways, repeated measures, mixed, ancova\n\n2. Pairwise post-hocs tests (parametric and non-parametric) and pairwise correlations\n\n3. Robust, partial, distance and repeated measures correlations\n\n4. Linear/logistic regression and mediation analysis\n\n5. Bayes Factors\n\n6. Multivariate tests\n\n7. Reliability and consistency\n\n8. Effect sizes and power analysis\n\n9. Parametric/bootstrapped confidence intervals around an effect size or a correlation coefficient\n\n10. Circular statistics\n\n11. Chi-squared tests\n\n12. Plotting: Bland-Altman plot, Q-Q plot, paired plot, robust correlation...\n\nPingouin is designed for users who want **simple yet exhaustive statistical functions**.\n\nFor example, the :code:`ttest_ind` function of SciPy returns only the T-value and the p-value. By contrast,\nthe :code:`ttest` function of Pingouin returns the T-value, the p-value, the degrees of freedom, the effect size (Cohen's d), the 95% confidence intervals of the difference in means, the statistical power and the Bayes Factor (BF10) of the test.\n\nDocumentation\n=============\n\n- `Link to documentation <https://pingouin-stats.org/index.html>`_\n\nChat\n====\n\nIf you have questions, please ask them in `GitHub Discussions <https://github.com/raphaelvallat/pingouin/discussions>`_.\n\nInstallation\n============\n\nDependencies\n------------\n\nThe main dependencies of Pingouin are :\n\n* `NumPy <https://numpy.org/>`_\n* `SciPy <https://www.scipy.org/>`_\n* `Pandas <https://pandas.pydata.org/>`_\n* `Pandas-flavor <https://github.com/Zsailer/pandas_flavor>`_\n* `Statsmodels <https://www.statsmodels.org/>`_\n* `Matplotlib <https://matplotlib.org/>`_\n* `Seaborn <https://seaborn.pydata.org/>`_\n\nIn addition, some functions require :\n\n* `Scikit-learn <https://scikit-learn.org/>`_\n* `Mpmath <http://mpmath.org/>`_\n\nPingouin is a Python 3 package and is currently tested for Python 3.8-3.11.\n\nUser installation\n-----------------\n\nPingouin can be easily installed using pip\n\n.. code-block:: shell\n\n pip install pingouin\n\nor conda\n\n.. code-block:: shell\n\n conda install -c conda-forge pingouin\n\nNew releases are frequent so always make sure that you have the latest version:\n\n.. code-block:: shell\n\n pip install --upgrade pingouin\n\nDevelopment\n-----------\n\nTo build and install from source, clone this repository or download the source archive and decompress the files\n\n.. code-block:: shell\n\n cd pingouin\n python -m build # optional, build a wheel and sdist\n pip install . # install the package\n pip install --editable . # or editable install\n pytest # test the package\n\nQuick start\n============\n\nClick on the link below and navigate to the notebooks/ folder to run a collection of interactive Jupyter notebooks showing the main functionalities of Pingouin. No need to install Pingouin beforehand, the notebooks run in a Binder environment.\n\n.. image:: https://mybinder.org/badge.svg\n :target: https://mybinder.org/v2/gh/raphaelvallat/pingouin/develop\n\n10 minutes to Pingouin\n----------------------\n\n1. T-test\n#########\n\n.. code-block:: python\n\n import numpy as np\n import pingouin as pg\n\n np.random.seed(123)\n mean, cov, n = [4, 5], [(1, .6), (.6, 1)], 30\n x, y = np.random.multivariate_normal(mean, cov, n).T\n\n # T-test\n pg.ttest(x, y)\n\n.. table:: Output\n :widths: auto\n\n ====== ===== ============= ======= ============= ========= ====== =======\n T dof alternative p-val CI95% cohen-d BF10 power\n ====== ===== ============= ======= ============= ========= ====== =======\n -3.401 58 two-sided 0.001 [-1.68 -0.43] 0.878 26.155 0.917\n ====== ===== ============= ======= ============= ========= ====== =======\n\n------------\n\n2. Pearson's correlation\n########################\n\n.. code-block:: python\n\n pg.corr(x, y)\n\n.. table:: Output\n :widths: auto\n\n === ===== =========== ======= ====== =======\n n r CI95% p-val BF10 power\n === ===== =========== ======= ====== =======\n 30 0.595 [0.3 0.79] 0.001 69.723 0.950\n === ===== =========== ======= ====== =======\n\n------------\n\n3. Robust correlation\n#####################\n\n.. code-block:: python\n\n # Introduce an outlier\n x[5] = 18\n # Use the robust biweight midcorrelation\n pg.corr(x, y, method=\"bicor\")\n\n.. table:: Output\n :widths: auto\n\n === ===== =========== ======= =======\n n r CI95% p-val power\n === ===== =========== ======= =======\n 30 0.576 [0.27 0.78] 0.001 0.933\n === ===== =========== ======= =======\n\n------------\n\n4. Test the normality of the data\n#################################\n\nThe `pingouin.normality` function works with lists, arrays, or pandas DataFrame in wide or long-format.\n\n.. code-block:: python\n\n print(pg.normality(x)) # Univariate normality\n print(pg.multivariate_normality(np.column_stack((x, y)))) # Multivariate normality\n\n.. table:: Output\n :widths: auto\n\n ===== ====== ========\n W pval normal\n ===== ====== ========\n 0.615 0.000 False\n ===== ====== ========\n\n.. parsed-literal::\n\n (False, 0.00018)\n\n------------\n\n5. One-way ANOVA using a pandas DataFrame\n#########################################\n\n.. code-block:: python\n\n # Read an example dataset\n df = pg.read_dataset('mixed_anova')\n\n # Run the ANOVA\n aov = pg.anova(data=df, dv='Scores', between='Group', detailed=True)\n print(aov)\n\n.. table:: Output\n :widths: auto\n\n ======== ======= ==== ===== ======= ======= =======\n Source SS DF MS F p-unc np2\n ======== ======= ==== ===== ======= ======= =======\n Group 5.460 1 5.460 5.244 0.023 0.029\n Within 185.343 178 1.041 nan nan nan\n ======== ======= ==== ===== ======= ======= =======\n\n------------\n\n6. Repeated measures ANOVA\n##########################\n\n.. code-block:: python\n\n pg.rm_anova(data=df, dv='Scores', within='Time', subject='Subject', detailed=True)\n\n.. table:: Output\n :widths: auto\n\n ======== ======= ==== ===== ======= ======= ======= =======\n Source SS DF MS F p-unc ng2 eps\n ======== ======= ==== ===== ======= ======= ======= =======\n Time 7.628 2 3.814 3.913 0.023 0.04 0.999\n Error 115.027 118 0.975 nan nan nan nan\n ======== ======= ==== ===== ======= ======= ======= =======\n\n------------\n\n7. Post-hoc tests corrected for multiple-comparisons\n####################################################\n\n.. code-block:: python\n\n # FDR-corrected post hocs with Hedges'g effect size\n posthoc = pg.pairwise_tests(data=df, dv='Scores', within='Time', subject='Subject',\n parametric=True, padjust='fdr_bh', effsize='hedges')\n\n # Pretty printing of table\n pg.print_table(posthoc, floatfmt='.3f')\n\n.. table:: Output\n :widths: auto\n\n ========== ======= ======= ======== ============ ====== ====== ============= ======= ======== ========== ====== ========\n Contrast A B Paired Parametric T dof alternative p-unc p-corr p-adjust BF10 hedges\n ========== ======= ======= ======== ============ ====== ====== ============= ======= ======== ========== ====== ========\n Time August January True True -1.740 59.000 two-sided 0.087 0.131 fdr_bh 0.582 -0.328\n Time August June True True -2.743 59.000 two-sided 0.008 0.024 fdr_bh 4.232 -0.483\n Time January June True True -1.024 59.000 two-sided 0.310 0.310 fdr_bh 0.232 -0.170\n ========== ======= ======= ======== ============ ====== ====== ============= ======= ======== ========== ====== ========\n\n------------\n\n8. Two-way mixed ANOVA\n######################\n\n.. code-block:: python\n\n # Compute the two-way mixed ANOVA\n aov = pg.mixed_anova(data=df, dv='Scores', between='Group', within='Time',\n subject='Subject', correction=False, effsize=\"np2\")\n pg.print_table(aov)\n\n.. table:: Output\n :widths: auto\n\n =========== ===== ===== ===== ===== ===== ======= ===== =======\n Source SS DF1 DF2 MS F p-unc np2 eps\n =========== ===== ===== ===== ===== ===== ======= ===== =======\n Group 5.460 1 58 5.460 5.052 0.028 0.080 nan\n Time 7.628 2 116 3.814 4.027 0.020 0.065 0.999\n Interaction 5.167 2 116 2.584 2.728 0.070 0.045 nan\n =========== ===== ===== ===== ===== ===== ======= ===== =======\n\n------------\n\n9. Pairwise correlations between columns of a dataframe\n#######################################################\n\n.. code-block:: python\n\n import pandas as pd\n np.random.seed(123)\n z = np.random.normal(5, 1, 30)\n data = pd.DataFrame({'X': x, 'Y': y, 'Z': z})\n pg.pairwise_corr(data, columns=['X', 'Y', 'Z'], method='pearson')\n\n.. table:: Output\n :widths: auto\n\n === === ======== ============= === ===== ============= ======= ====== =======\n X Y method alternative n r CI95% p-unc BF10 power\n === === ======== ============= === ===== ============= ======= ====== =======\n X Y pearson two-sided 30 0.366 [0.01 0.64] 0.047 1.500 0.525\n X Z pearson two-sided 30 0.251 [-0.12 0.56] 0.181 0.534 0.272\n Y Z pearson two-sided 30 0.020 [-0.34 0.38] 0.916 0.228 0.051\n === === ======== ============= === ===== ============= ======= ====== =======\n\n------------\n\n10. Pairwise T-test between columns of a dataframe\n###################################################\n\n.. code-block:: python\n\n data.ptests(paired=True, stars=False)\n\n.. table:: Pairwise T-tests, with T-values on the lower triangle and p-values on the upper triangle\n :widths: auto\n\n ==== ====== ====== =====\n .. X Y Z\n ==== ====== ====== =====\n X - 0.226 0.165\n Y -1.238 - 0.658\n Z -1.424 -0.447 -\n ==== ====== ====== =====\n\n------------\n\n11. Multiple linear regression\n##############################\n\n.. code-block:: python\n\n pg.linear_regression(data[['X', 'Z']], data['Y'])\n\n.. table:: Linear regression summary\n :widths: auto\n\n ========= ====== ===== ====== ====== ===== ======== ========== ===========\n names coef se T pval r2 adj_r2 CI[2.5%] CI[97.5%]\n ========= ====== ===== ====== ====== ===== ======== ========== ===========\n Intercept 4.650 0.841 5.530 0.000 0.139 0.076 2.925 6.376\n X 0.143 0.068 2.089 0.046 0.139 0.076 0.003 0.283\n Z -0.069 0.167 -0.416 0.681 0.139 0.076 -0.412 0.273\n ========= ====== ===== ====== ====== ===== ======== ========== ===========\n\n------------\n\n12. Mediation analysis\n######################\n\n.. code-block:: python\n\n pg.mediation_analysis(data=data, x='X', m='Z', y='Y', seed=42, n_boot=1000)\n\n.. table:: Mediation summary\n :widths: auto\n\n ======== ====== ===== ====== ========== =========== =====\n path coef se pval CI[2.5%] CI[97.5%] sig\n ======== ====== ===== ====== ========== =========== =====\n Z ~ X 0.103 0.075 0.181 -0.051 0.256 No\n Y ~ Z 0.018 0.171 0.916 -0.332 0.369 No\n Total 0.136 0.065 0.047 0.002 0.269 Yes\n Direct 0.143 0.068 0.046 0.003 0.283 Yes\n Indirect -0.007 0.025 0.898 -0.069 0.029 No\n ======== ====== ===== ====== ========== =========== =====\n\n------------\n\n13. Contingency analysis\n########################\n\n.. code-block:: python\n\n data = pg.read_dataset('chi2_independence')\n expected, observed, stats = pg.chi2_independence(data, x='sex', y='target')\n stats\n\n.. table:: Chi-squared tests summary\n :widths: auto\n\n ================== ======== ====== ===== ===== ======== =======\n test lambda chi2 dof p cramer power\n ================== ======== ====== ===== ===== ======== =======\n pearson 1.000 22.717 1.000 0.000 0.274 0.997\n cressie-read 0.667 22.931 1.000 0.000 0.275 0.998\n log-likelihood 0.000 23.557 1.000 0.000 0.279 0.998\n freeman-tukey -0.500 24.220 1.000 0.000 0.283 0.998\n mod-log-likelihood -1.000 25.071 1.000 0.000 0.288 0.999\n neyman -2.000 27.458 1.000 0.000 0.301 0.999\n ================== ======== ====== ===== ===== ======== =======\n\nIntegration with Pandas\n-----------------------\n\nSeveral functions of Pingouin can be used directly as pandas DataFrame methods. Try for yourself with the code below:\n\n.. code-block:: python\n\n import pingouin as pg\n\n # Example 1 | ANOVA\n df = pg.read_dataset('mixed_anova')\n df.anova(dv='Scores', between='Group', detailed=True)\n\n # Example 2 | Pairwise correlations\n data = pg.read_dataset('mediation')\n data.pairwise_corr(columns=['X', 'M', 'Y'], covar=['Mbin'])\n\n # Example 3 | Partial correlation matrix\n data.pcorr()\n\nThe functions that are currently supported as pandas method are:\n\n* `pingouin.anova <https://pingouin-stats.org/generated/pingouin.anova.html#pingouin.anova>`_\n* `pingouin.ancova <https://pingouin-stats.org/generated/pingouin.ancova.html#pingouin.ancova>`_\n* `pingouin.rm_anova <https://pingouin-stats.org/generated/pingouin.rm_anova.html#pingouin.rm_anova>`_\n* `pingouin.mixed_anova <https://pingouin-stats.org/generated/pingouin.mixed_anova.html#pingouin.mixed_anova>`_\n* `pingouin.welch_anova <https://pingouin-stats.org/generated/pingouin.welch_anova.html#pingouin.welch_anova>`_\n* `pingouin.pairwise_tests <https://pingouin-stats.org/generated/pingouin.pairwise_tests.html#pingouin.pairwise_tests>`_\n* `pingouin.pairwise_tukey <https://pingouin-stats.org/generated/pingouin.pairwise_tukey.html#pingouin.pairwise_tukey>`_\n* `pingouin.pairwise_corr <https://pingouin-stats.org/generated/pingouin.pairwise_corr.html#pingouin.pairwise_corr>`_\n* `pingouin.partial_corr <https://pingouin-stats.org/generated/pingouin.partial_corr.html#pingouin.partial_corr>`_\n* `pingouin.pcorr <https://pingouin-stats.org/generated/pingouin.pcorr.html#pingouin.pcorr>`_\n* `pingouin.rcorr <https://pingouin-stats.org/generated/pingouin.rcorr.html#pingouin.rcorr>`_\n* `pingouin.ptests <https://pingouin-stats.org/generated/pingouin.ptests.html#pingouin.ptests>`_\n* `pingouin.mediation_analysis <https://pingouin-stats.org/generated/pingouin.mediation_analysis.html#pingouin.mediation_analysis>`_\n\nDevelopment\n===========\n\nPingouin was created and is maintained by `Raphael Vallat <https://raphaelvallat.github.io>`_, a postdoctoral researcher at UC Berkeley, mostly during his spare time. Contributions are more than welcome so feel free to contact me, open an issue or submit a pull request!\n\nTo see the code or report a bug, please visit the `GitHub repository <https://github.com/raphaelvallat/pingouin>`_.\n\nThis program is provided with NO WARRANTY OF ANY KIND. Pingouin is still under heavy development and there are likely hidden bugs. Always double check the results with another statistical software.\n\n**Contributors**\n\n- Nicolas Legrand\n- `Richard H\u00f6chenberger <http://hoechenberger.net/>`_\n- `Arthur Paulino <https://github.com/arthurpaulino>`_\n- `Eelke Spaak <https://eelkespaak.nl/>`_\n- `Johannes Elfner <https://www.linkedin.com/in/johannes-elfner/>`_\n- `Stefan Appelhoff <https://stefanappelhoff.com>`_\n\nHow to cite Pingouin?\n=====================\n\nIf you want to cite Pingouin, please use the publication in JOSS:\n\n* Vallat, R. (2018). Pingouin: statistics in Python. *Journal of Open Source Software*, 3(31), 1026, `https://doi.org/10.21105/joss.01026 <https://doi.org/10.21105/joss.01026>`_\n\nAcknowledgement\n===============\n\nSeveral functions of Pingouin were inspired from R or Matlab toolboxes, including:\n\n- `effsize package (R) <https://cran.r-project.org/web/packages/effsize/effsize.pdf>`_\n- `ezANOVA package (R) <https://cran.r-project.org/web/packages/ez/ez.pdf>`_\n- `pwr package (R) <https://cran.r-project.org/web/packages/pwr/pwr.pdf>`_\n- `circular statistics (Matlab) <https://www.mathworks.com/matlabcentral/fileexchange/10676-circular-statistics-toolbox-directional-statistics>`_\n- `robust correlations (Matlab) <https://sourceforge.net/projects/robustcorrtool/>`_\n- `repeated-measure correlation (R) <https://cran.r-project.org/web/packages/rmcorr/index.html>`_\n- `real-statistics.com <https://www.real-statistics.com/>`_\n",
"bugtrack_url": null,
"license": "GPL-3.0",
"summary": "Pingouin: statistical package for Python",
"version": "0.5.5",
"project_urls": {
"Downloads": "https://github.com/raphaelvallat/pingouin/",
"Homepage": "https://pingouin-stats.org/index.html"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "eb566d3607f3a78aee1de8e5466f5171722c8e344266a12dc44ccb73d024b3b3",
"md5": "25413075c6a128674514b722c2b5f5ce",
"sha256": "3156afe44ee5541131200848ee905937930757b615aca8eed8438ad4d4e20ef1"
},
"downloads": -1,
"filename": "pingouin-0.5.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "25413075c6a128674514b722c2b5f5ce",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 204367,
"upload_time": "2024-09-04T10:42:50",
"upload_time_iso_8601": "2024-09-04T10:42:50.053270Z",
"url": "https://files.pythonhosted.org/packages/eb/56/6d3607f3a78aee1de8e5466f5171722c8e344266a12dc44ccb73d024b3b3/pingouin-0.5.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0e3d14a779790bac2d03a0d8f82c1857fc83c0ef8b1b77542b884808e55ee839",
"md5": "34b89d8789e2f40735d2e36a15ae41c1",
"sha256": "2aac834128e99a4df8cffd8151c21adc7c42fe493e389c6fc2581b84e436ddd9"
},
"downloads": -1,
"filename": "pingouin-0.5.5.tar.gz",
"has_sig": false,
"md5_digest": "34b89d8789e2f40735d2e36a15ae41c1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 232233,
"upload_time": "2024-09-04T10:42:51",
"upload_time_iso_8601": "2024-09-04T10:42:51.542430Z",
"url": "https://files.pythonhosted.org/packages/0e/3d/14a779790bac2d03a0d8f82c1857fc83c0ef8b1b77542b884808e55ee839/pingouin-0.5.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-04 10:42:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "raphaelvallat",
"github_project": "pingouin",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pingouin"
}