Package: latentcor
Free software:GNU General Public License v3Documentation:https://latentcor-py.readthedocs.io.Introductionlatentcoris 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, seeFan, J., Liu, H., Ning, Y., and Zou, H. (2017), “High Dimensional Semiparametric Latent Graphical Model for Mixed Data.”JRSS B.Continuous/binarytypes.Quan X., Booth J.G. and Wells M.T. “Rank-based approach for estimating correlations in mixed ordinal data.”arXiv.Ternarytype.Yoon G., Carroll R.J. and Gaynanova I. (2020). “Sparse semiparametric canonical correlation analysis for data of mixed types.”Biometrika.Truncatedtype for zero-inflated data.Yoon G., Müller C.L. and Gaynanova I. (2021). “Fast computation of latent correlations.”.Approximation method of computation, seemath frameworkfor details.Statement of needNo Python software package is currently available that allows accurate and fast correlation estimation from mixed variable data in a unifying manner.
The Python packagelatentcor, 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.InstallationThe easiest way to installlatentcoris usingpip.pip install latentcorExampleLet’s importgen_data,get_tpsandlatentcorfromlatentcor.from latentcor import gen_data, get_tps, latentcorFirst, we will generate a pair of variables with different types using a sample sizen=100which 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 usinglatentcorfunction.estimate = latentcor(simdata['X'], tps = ["ter", "con"])
print(estimate['R'])Community GuidelinesContributions and suggestions to the software are always welcome. Please consult ourcontribution guidelinesprior to submitting a pull request.Report issues or problems with the software using github’sissue tracker.The easiest way to replicate development environment oflatentcoris usingpip:pip install -r requirements_dev.txtCreditsThis package was created withCookiecutterand theaudreyr/cookiecutter-pypackageproject template.History0.1.0 (2021-12-28)First version.0.1.1 (2022-01-06)Fix some typos.0.1.2 (2022-01-06)Fix some bug onuse_nearPDargument in functionlatentcor.0.1.3 (2022-01-07)Fix syntax errors forjupyter-executein README.txt.0.1.4 (2022-05-23)Fix error for continuous estimation.0.2.0 (2022-08-16)Increase maximum iteration for positive definiteness adjustment.Make function outputs as dictionary.0.2.1 (2022-08-22)Make output latent correlation matrix as pandas.DataFrame.Polish output heatmap.0.2.2 (2022-08-22)Update README file.0.2.3 (2022-08-22)Correct update history.0.2.4 (2022-09-07)Correct incompatible versions.0.2.5 (2023-11-05)Regenerate interpolants for approximation method and fix version compatibility for Python 3.7.