latentcor: Fast Computation of Latent Correlations for Mixed Data

Mingze Huang, Grace Yoon, Christian M uuml ller, Irina GaynanovaOpenalex Unknown 2021 · DOI · OpenAlex

Abstract

The first stand-alone R 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 estimation is based on latent copula Gaussian models. For continuous/binary types, see Fan et al. (2017). For ternary type, see Quan et al. (2018). For truncated type or zero-inflated type, see Yoon et al. (2020). For approximation method of computation, see Yoon et al. (2021). The latter method uses multi-linear interpolation originally implemented in the R package chebpol.

Introduction

Modern data analysis frequently involves "mixed" datasets containing a variety of variable types, such as continuous gene expression levels, binary mutation markers, and zero-inflated counts. Standard correlation measures, such as Pearson’s $r$, often prove inadequate as they assume linearity and normality. While rank-based measures like Kendall’s $\tau$ are more robust, they do not directly represent the underlying latent relationships between variables. Latent correlation, which assumes observed discrete or truncated variables are manifestations of underlying Gaussian variables, is considered the gold standard for mixed data. However, traditional numerical optimization methods for calculating these correlations are computationally prohibitive for high-dimensional data.

Methodology

The latentcor package addresses these challenges by implementing methods based on latent copula Gaussian models. The core task is to invert a bridge function $F$ such that $F(r) = E[\hat{\tau}]$, where $r$ is the latent correlation and $\hat{\tau}$ is the observed Kendall’s $\tau$.

The package offers two primary computational paths:

  • The "Original" Method: Uses numerical optimization to solve the bridge function for each pair of variables. While highly accurate, its $O(p^2)$ complexity makes it slow for large datasets.
  • The "Approx" Method: This is the package's primary innovation. It utilizes multilinear interpolation, pre-calculating bridge functions on a grid. This approach allows for estimation speeds nearly as fast as standard rank-based correlations, enabling the analysis of high-dimensional mixed datasets.

Practical Features and Implementation

To facilitate ease of use, latentcor includes several utility functions designed to streamline the workflow for complex datasets.

The get_types function automatically determines variable types in a data matrix.

As shown in the figure above, the get_types function can automatically determine the type of each variable (continuous, binary, ternary, or truncated) within a data matrix. Additionally, the package handles matrix regularization. Because pairwise latent correlations may not naturally result in a positive definite matrix, latentcor employs nearPD projection and shrinkage to ensure the output is suitable for downstream applications like Principal Component Analysis (PCA) or graphical modeling.

Performance and Evaluation

The primary advantage of the latentcor package is the significant reduction in computation time provided by the approximation method. To allow users to verify these gains, the package includes a simulation engine (gen_data()) and an evaluation suite.

Evaluation metrics provided by the package to compare estimation methods.

The evaluation function provides a comprehensive set of metrics, as listed in the figure above, including mean, median, and maximum absolute errors, as well as computation times for both the original and approximation methods. Users can also adjust a ratio parameter to control the boundary for interpolation, allowing for a customizable balance between speed and precision.

Conclusion

The latentcor package provides a high-performance, memory-efficient solution for computing latent correlations in mixed datasets. By leveraging multilinear interpolation, it makes sophisticated latent Gaussian copula modeling as computationally accessible as simple rank-based correlations, opening new possibilities for high-dimensional data analysis in fields such as genomics and economics.

Summary updated

Abstract

The first stand-alone R 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 estimation is based on latent copula Gaussian models. For continuous/binary types, see Fan, J., Liu, H., Ning, Y., and Zou, H. (2017). For ternary type, see Quan X., Booth J.G. and Wells M.T. (2018) &lt;<a href="https://doi.org/10.48550%2FarXiv.1809.06255" target="_top">doi:10.48550/arXiv.1809.06255</a>&gt;. For truncated type or zero-inflated type, see Yoon G., Carroll R.J. and Gaynanova I. (2020) &lt;<a href="https://doi.org/10.1093%2Fbiomet%2Fasaa007" target="_top">doi:10.1093/biomet/asaa007</a>&gt;. For approximation method of computation, see Yoon G., Müller C.L. and Gaynanova I. (2021) &lt;<a href="https://doi.org/10.1080%2F10618600.2021.1882468" target="_top">doi:10.1080/10618600.2021.1882468</a>&gt;. The latter method uses multi-linear interpolation originally implemented in the R package &lt;<a href="https://cran.r-project.org/package=chebpol" target="_top">https://cran.r-project.org/package=chebpol</a>&gt;.
BibTeX
@inproceedings{huang2021latentcor,
  author = {Mingze Huang and Grace Yoon and Christian M uuml ller and Irina Gaynanova},
  title = {{latentcor: Fast Computation of Latent Correlations for Mixed Data}},
  booktitle = {Openalex Unknown},
  year = {2021},
  doi = {10.32614/cran.package.latentcor},
}
Figure