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
>>> 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

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.9.0.tar.gz (770.6 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.9.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ordinalcorr-0.9.0.tar.gz
  • Upload date:
  • Size: 770.6 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for ordinalcorr-0.9.0.tar.gz
Algorithm Hash digest
SHA256 47f5645ba37ed3993313129432e1b6cac773b7f0e0bcffbaca3c991a13ebd769
MD5 b0132d82f5f9b1e9eaa8cfba491d8eb1
BLAKE2b-256 07bf55b5cce483ae3525d11deff0bf88a90576465cbb272d62707490be963c3c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ordinalcorr-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for ordinalcorr-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b26fc91a1f7f15cb8232f3f7bd7c8ad4bc3ee1d4f3bda8c12564c8e1fdbcc4ba
MD5 d3752759bc0c2ae5736be40250d321f5
BLAKE2b-256 1ccbe1930b9d04a6423e0d112cf892bf628db1d18208f2711a5ebbb47425949b

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