fastfrechet: An R package for fast implementation of Fréchet regression with distributional responses

Alexander Coulter, Rebecca Lee, Irina GaynanovaThe Journal of Open Source Software 2025

Abstract

Distribution-as-response regression problems are gaining wider attention, especially within biomedical settings where observation-rich patient-specific datasets are available, such as feature densities in CT scans, actigraphy, and continuous glucose monitoring. To accommodate the complex structure of such problems, Fréchet regression allows for non-Euclidean responses, including distributional responses. This framework was further extended for variable selection, and recently, a fast variable selection algorithm was developed for univariate distributional responses equipped with the 2-Wasserstein metric. We present fastfrechet, an R package providing a highly scalable implementation of these methods. fastfrechet makes distribution-based Fréchet regression with resampling-supplemented variable selection readily available for large-scale datasets like the UK Biobank.

Introduction

In modern biomedicine, researchers frequently encounter "observation-rich" data where the outcome of interest is not a single scalar value, but a whole probability distribution. Examples include the daily density of glucose levels or the distribution of physical activity intensities over a week. Standard regression models are ill-equipped for these non-Euclidean responses.

Fréchet regression was developed to fill this gap. However, until now, practical applications have been limited by significant computational bottlenecks. Previous implementations were often too slow for large datasets, failed to respect physical boundaries (such as predicting negative values for positive-only data), and lacked user-friendly tools for complex variable selection. The fastfrechet package addresses these issues, offering a performance boost of up to 20,000x over previous methods.

Algorithmic Innovations

The fastfrechet package specializes in Fréchet regression within the 2-Wasserstein space, a popular framework for comparing distributions. Its efficiency stems from several key innovations:

  • Dual Active-Set Solver: Instead of relying on generic optimization, the package uses a customized dual active-set algorithm. This ensures that predicted distributions strictly respect user-defined support constraints (e.g., a mandatory lower bound of zero) while remaining computationally lean.
  • Second-Order Geodesic Descent: For variable selection, the package implements a specialized descent algorithm that leverages the geometry of the Wasserstein space.
  • Warm Starts and Momentum: The solver reuses the "active set" from previous iterations to jumpstart calculations and utilizes an impulse parameter for momentum-based descent, significantly reducing the number of iterations required.
  • Resampling Tools: Built-in support for cross-validation and stability selection allows for robust statistical inference, which was previously computationally prohibitive for distributional data.

Performance Benchmarks

The most striking feature of fastfrechet is its speed. In head-to-head comparisons against existing tools, the package demonstrated massive scalability improvements. For instance, a variable selection task that takes nearly 500 seconds using the original implementation by Tucker et al. (2023) can be completed in less than 0.02 seconds with fastfrechet.

Performance comparison showing median run times and accuracy ratios between the original Tucker et al. (2023) implementation and the fastfrechet R package.

As shown in the figure above, fastfrechet achieves a speedup of over 20,000x while maintaining high numerical accuracy. This level of efficiency transforms the type of science possible; researchers can now perform stability selection—running a model hundreds of times on different data subsets—on massive cohorts like the UK Biobank in minutes rather than days.

Real-World Impact and Accuracy

Beyond speed, fastfrechet improves the physical validity of predictions. Many general-purpose solvers allow predicted distributions to include impossible values, such as negative glucose levels. By incorporating constraints directly into the dual active-set solver, fastfrechet ensures that predictions remain within realistic bounds.

The package is already proving its worth in large-scale biomedical studies, including the HYPNOS CGM cohort and UK Biobank actigraphy data. Tasks that previously required "CPU-days" of processing time are now feasible on standard hardware in a fraction of the time.

Conclusion and Future Work

fastfrechet provides a critical tool for the analysis of distributional data in the 2-Wasserstein space. While currently optimized for univariate responses, the package sets a new standard for speed and constraint satisfaction in Fréchet regression. Future developments may include extending these fast solvers to multivariate distributions and integrating automated hyperparameter tuning for even greater ease of use.

Summary updated

BibTeX
@article{coulter2025fastfrechet,
  author = {Alexander Coulter and Rebecca Lee and Irina Gaynanova},
  title = {{fastfrechet: An R package for fast implementation of Fréchet regression with distributional responses}},
  journal = {The Journal of Open Source Software},
  year = {2025},
  doi = {10.21105/joss.07925},
}
Figure