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.0.tar.gz (121.3 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.0-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ordinalcorr-0.7.0.tar.gz
  • Upload date:
  • Size: 121.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for ordinalcorr-0.7.0.tar.gz
Algorithm Hash digest
SHA256 dff7e79c30aaa10c7472b939d276228a1a04d95039518c35e32f79354ad13a7d
MD5 7934160ab67e276e8c2b503ee3fb8399
BLAKE2b-256 8d581811d3706a1ab37e5443eb04aff48c329eae0941ae9fb8ebe1950d2ea393

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ordinalcorr-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for ordinalcorr-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18bd2d9343730c8832f63baeb03f7b48b1d4a0da271766129a9272421f95fab5
MD5 29272a27534251f7cfd86e83754819d2
BLAKE2b-256 62c08db7d8885cd9f90adaa7cae72ae4c8b5fb930044f2082a492dd055cf894b

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