- Free software: GNU General Public License v3
- Documentation: https://latentcor-py.readthedocs.io.
latentcor is an Python package for estimation of latent correlations with mixed data types (continuous, binary, truncated, and ternary) under the latent Gaussian copula model. For references on the estimation framework, see
- Fan, J., Liu, H., Ning, Y., and Zou, H. (2017), “High Dimensional Semiparametric Latent Graphical Model for Mixed Data.” JRSS B. Continuous/binary types.
- Quan X., Booth J.G. and Wells M.T. “Rank-based approach for estimating correlations in mixed ordinal data.” arXiv. Ternary type.
- Yoon G., Carroll R.J. and Gaynanova I. (2020). “Sparse semiparametric canonical correlation analysis for data of mixed types.” Biometrika. Truncated type for zero-inflated data.
- Yoon G., Müller C.L. and Gaynanova I. (2021). “Fast computation of latent correlations.”. Approximation method of computation, see math framework for details.
No Python software package is currently available that allows accurate and fast correlation estimation from mixed variable data in a unifying manner.
The Python package latentcor
, introduced here, thus represents the first stand-alone Python package for computation of latent correlation that
takes into account all variable types (continuous/binary/ordinal/zero-inflated), comes with an optimized memory footprint, and is computationally efficient,
essentially making latent correlation estimation almost as fast as rank-based correlation estimation.
The easiest way to install latentcor
is using pip
.
pip install latentcor
Let's import gen_data
, get_tps
and latentcor
from latentcor
.
from latentcor import gen_data, get_tps, latentcor
First, we will generate a pair of variables with different types using a sample size n=100
which will serve as example data. Here first variable will be ternary, and second variable will be continuous.
simdata = gen_data(n = 100, tps = ["ter", "con"]) print(simdata['X'][ : 6, : ])
Then we can estimate the latent correlation matrix based on these 2 variables using latentcor
function.
estimate = latentcor(simdata['X'], tps = ["ter", "con"]) print(estimate['R'])
- Contributions and suggestions to the software are always welcome. Please consult our contribution guidelines prior to submitting a pull request.
- Report issues or problems with the software using github’s issue tracker.
- The easiest way to replicate development environment of latentcor is using pip:
pip install -r requirements_dev.txt
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.