Skip to main content

correlation coefficients for ordinal-scaled variables

Project description

ordinalcorr: correlation coefficients for ordinal variables

PyPI - Python Version PyPI version License

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
>>> data = pd.DataFrame({
...     "continuous": [0.1, 0.1, 0.2, 0.2, 0.3, 0.3],
...     "dichotomous": [0, 0, 0, 1, 1, 1],
...     "polytomous": [1, 1, 3, 3, 2, 2],
... })
>>> hetcor(data)
             continuous  dichotomous  polytomous
continuous     1.000000     0.989335    0.514870
dichotomous    0.989335     1.000000    0.549231
polytomous     0.514870     0.549231    1.000000

📦 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

ordinalcorr documentation

⚖️ License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ordinalcorr-0.7.1.tar.gz (773.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ordinalcorr-0.7.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file ordinalcorr-0.7.1.tar.gz.

File metadata

  • Download URL: ordinalcorr-0.7.1.tar.gz
  • Upload date:
  • Size: 773.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

File hashes

Hashes for ordinalcorr-0.7.1.tar.gz
Algorithm Hash digest
SHA256 e01992b9e5f101cff2bac6fcfdb606f69effd1e294b09271e4cbc310c6cb8232
MD5 28ca403727ae82718f9dcca2adfbcf63
BLAKE2b-256 86f577b8b507daa54309b4981c32e59f2d105a041841f56769da3aeb11f1d321

See more details on using hashes here.

File details

Details for the file ordinalcorr-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: ordinalcorr-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

File hashes

Hashes for ordinalcorr-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 829cc7e21b3853d481ff938b585d7f1759eadcb404e8061a5541e92a2989f7a0
MD5 8c0d48259f5a2ed2cdeb7b40e4a261ac
BLAKE2b-256 67e8f441dcc380ee7dca05763772b59b380cb934a121d9dcc2b4d03a969ae30f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page