Skip to main content

Simple implementation in Python of the reliability: Omega Total,Omega Hierarchical, Omega Hierarchical Total, Cronbach's Alpha and more.

Project description

DOI

reliabiliPy

Summary

  • Simple implementation in Python of the [reliability](https://en.wikipedia.org/wiki/Reliability_(statistics) measures for surveys: Omega Total, Omega Hierarchical and Omega Hierarchical Asymptotic and Omega Total, using Schmid-Leiman solution.
  • Also Cronbach's Alpha Guttman’s lower bounds of reliability $\lamda_1$ and $\lamda_2$.
  • Explanations and documentation available

See Documentation

Quick Start

If you have the correlations matrix of your dataset.

To install:

pip install reliabiliPy

To start using it:

import pandas as pd
import numpy as np
from reliabilipy import reliability_analysis

correlations_matrix = pd.DataFrame(np.matrix([[1., 0.483, 0.34, 0.18, 0.277, 0.257, -0.074, 0.212, 0.226],
                                              [0.483, 1., 0.624, 0.26, 0.433, 0.301, -0.028, 0.362, 0.236],
                                              [0.34, 0.624, 1., 0.24, 0.376, 0.244, 0.233, 0.577, 0.352],
                                              [0.18, 0.26, 0.24, 1., 0.534, 0.654, 0.165, 0.411, 0.306],
                                              [0.277, 0.433, 0.376, 0.534, 1., 0.609, 0.041, 0.3, 0.239],
                                              [0.257, 0.301, 0.244, 0.654, 0.609, 1., 0.133, 0.399, 0.32],
                                              [-0.074, -0.028, 0.233, 0.165, 0.041, 0.133, 1., 0.346, 0.206],
                                              [0.212, 0.362, 0.577, 0.411, 0.3, 0.399, 0.346, 1., 0.457],
                                              [0.226, 0.236, 0.352, 0.306, 0.239, 0.32, 0.206, 0.457, 1.]]))
reliability_report = reliability_analysis(correlations_matrix=correlations_matrix)
reliability_report.fit()
print('here omega Hierarchical: ', reliability_report.omega_hierarchical)
print('here Omega Hierarchical infinite or asymptotic: ', reliability_report.omega_hierarchical_asymptotic)
print('here Omega Total', reliability_report.omega_total)
print('here Alpha Cronbach total', reliability_report.alpha_cronbach)
print(reliability_report.lambda1)
print(reliability_report.lambda2)
print(reliability_report.report_eigenvalues)
print(reliability_report.report_loadings)

If you want to use the whole dataset you could do it to, adding the inputations method you prefer:

import pandas as pd
import numpy as np
from reliabilipy import reliability_analysis
raw_dataset = pd.DataFrame([{'C1': 2.0, 'C2': 3.0, 'C3': 3.0, 'C4': 4.0, 'C5': 4.0},\
        {'C1': 5.0, 'C2': 4.0, 'C3': 4.0, 'C4': 3.0, 'C5': 4.0},\
        {'C1': 4.0, 'C2': 5.0, 'C3': 4.0, 'C4': 2.0, 'C5': 5.0},\
        {'C1': 4.0, 'C2': 4.0, 'C3': 3.0, 'C4': 5.0, 'C5': 5.0},\
        {'C1': 4.0, 'C2': 4.0, 'C3': 5.0, 'C4': 3.0, 'C5': 2.0},\
        {'C1': 4.0, 'C2': np.nan, 'C3': 3.0, 'C4': 5.0, 'C5': 5.0},\
        {'C1': np.nan, 'C2': 4.0, 'C3': 5.0, 'C4': 3.0, 'C5': 2.0}])
ra = reliability_analysis(raw_dataset=raw_dataset,
                              is_corr_matrix=False,
                              impute='median')
ra.fit()
print('here omega Hierarchical: ', ra.omega_hierarchical)
print('here Omega Hierarchical infinite or asymptotic: ', ra.omega_hierarchical_asymptotic)
print('here Omega Total', ra.omega_total)
print('here Alpha Cronbach total', ra.alpha_cronbach)

Context

It is common to try check the reliability, i.e.: the consistency of a measure, particular in psychometrics and surveys analysis.

R has packages for this kind of analysis available, such us psychby Revelle (2017). python goes behind on this. The closes are factor-analyser and Pingouin. As I write this there is a gap in the market since none of the above libraries currently implement any omega related reliability measure. Although Pingouin implements Cronbach's alpha

Aim

  1. To bring functions to python for psychometrics and survey analysis, as there is a gap. Mostly from the package in R psych.
  2. To make the ideas and math behind those clear and transparent with examples, and documentation.
  3. To allow people to collaborate and ask questions about.

References

Acknowledgement

Cite this package as

  • Rafael Valero Fernández. (2022). reliabiliPy: measures of survey domain reliability in Python with explanations and examples. Cronbach´s Alpha and Omegas. (v0.0.0). Zenodo. https://doi.org/10.5281/zenodo.5830894

or

@software{rafael_valero_fernandez_2022_5830894,
  author       = {Rafael Valero Fernández},
  title        = {{reliabiliPy: measures of survey domain reliability 
                   in Python with explanations and examples.
                   Cronbach´s Alpha and Omegas.}},
  month        = jan,
  year         = 2022,
  publisher    = {Zenodo},
  version      = {v0.0.0},
  doi          = {10.5281/zenodo.5830894},
  url          = {https://doi.org/10.5281/zenodo.5830894}
}

Happy to modify the above as petition and contributions.

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

reliabiliPy-0.0.36.tar.gz (8.4 kB view details)

Uploaded Source

File details

Details for the file reliabiliPy-0.0.36.tar.gz.

File metadata

  • Download URL: reliabiliPy-0.0.36.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.13

File hashes

Hashes for reliabiliPy-0.0.36.tar.gz
Algorithm Hash digest
SHA256 18c8112a620bb8d31f11628db568ba942d71280952787fe2e7eeb9faa7fe31ff
MD5 b37794c684bf399d31f0f0653b9c8e89
BLAKE2b-256 9e3f80926cfead2892625db6079c3a48a6f0107782c90c46e472ed1db08e11da

See more details on using hashes here.

Supported by

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