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.8.0.tar.gz (771.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.8.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ordinalcorr-0.8.0.tar.gz
  • Upload date:
  • Size: 771.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.8.0.tar.gz
Algorithm Hash digest
SHA256 481986c9c113e6c0f470a978cbd2664e090f0a8a2cd9e610b6b321653dc807fd
MD5 226ba18b9b929197b68ef54af998b1fa
BLAKE2b-256 c6f179bc97966440c82347a214a773b2f55cfc48c1006099e683c4cd1dff1a22

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ordinalcorr-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 10.9 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.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c6bd874cd10a453baa284bf92584c27c130c717d18594dce2c51b9e864f902c
MD5 4266a7dd6b95f6b295ea84e134f4956d
BLAKE2b-256 d0b96aa5814efa9cd5e6f3d83c1b854b8d92afd24e1b8f08c302e72cde2a55de

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