ordinalcorr: correlation coefficients for ordinal variables
ordinalcorr is a Python package designed to compute correlation coefficients tailored for ordinal-scale data (e.g., Likert items).
It supports polychoric correlation coefficients and other coefficients for ordinal data.
✨ Features
1️⃣ Correlation Coefficients
This package provides several correlation coefficients (e.g. Polyserial and Polychoric)
| Variable X | Variable Y | Method | Function |
|---|---|---|---|
| continuous | ordinal (discretized) | Polyserial correlation | polyserial |
| ordinal (discretized) | ordinal (discretized) | Polychoric correlation | polychoric |
Here is an example:
>>> from ordinalcorr import polychoric
>>> x = [1, 1, 2, 2, 3, 3]
>>> y = [0, 0, 0, 1, 1, 1]
>>> polychoric(x, y)
0.9986287922233864
2️⃣ Heterogeneous Correlation Matrix
A function for computing the heterogeneous correlation matrix—a correlation matrix that includes both continuous and ordinal variables—is also provided.
>>> from ordinalcorr import hetcor
>>> import pandas as pd
>>> import numpy as np
>>> np.random.seed(0)
>>> data = pd.DataFrame({
... "continuous": np.random.normal(size=90),
... "dichotomous": np.repeat([0, 1], 45),
... "polytomous": np.repeat([1, 2, 3], 30),
... })
>>> hetcor(data).round(3)
continuous dichotomous polytomous
continuous 1.000 -0.254 -0.257
dichotomous -0.254 1.000 0.999
polytomous -0.257 0.999 1.000
📦 Installation
ordinalcorr is available at the PyPI
pip install ordinalcorr
Requirements
- Python 3.10 or later
- Dependencies:
- numpy >= 1.23.0
- scipy >= 1.8.0
📒 Documentation
⚖️ License
This project is licensed under the MIT License. See the LICENSE file for details.
Metadata
Release files for ordinalcorr 0.9.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 | Actions |
|---|---|---|---|---|
| ordinalcorr-0.9.0.tar.gz | 770.6 kB | Without provenance | Details for ordinalcorr-0.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ordinalcorr-0.9.0-py3-none-any.whl | Python 3 | none | any | Details for ordinalcorr-0.9.0-py3-none-any.whl |
Total release size: 782.0 kB
Release files / ordinalcorr-0.9.0.tar.gz
| Download URL | ordinalcorr-0.9.0.tar.gz |
|---|---|
| Size | 770.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
47f5645ba37ed3993313129432e1b6cac773b7f0e0bcffbaca3c991a13ebd769
|
|
BLAKE2b-256 checksum How to use checksums |
07bf55b5cce483ae3525d11deff0bf88a90576465cbb272d62707490be963c3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / ordinalcorr-0.9.0-py3-none-any.whl
| Download URL | ordinalcorr-0.9.0-py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b26fc91a1f7f15cb8232f3f7bd7c8ad4bc3ee1d4f3bda8c12564c8e1fdbcc4ba
|
|
BLAKE2b-256 checksum How to use checksums |
1ccbe1930b9d04a6423e0d112cf892bf628db1d18208f2711a5ebbb47425949b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.27 {"installer":{"name":"uv","version":"0.11.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for ordinalcorr 0.9.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.