FormulaCompiler.jl and Margins.jl: Efficient Marginal Effects in Julia
Eric Feltham

TL;DR
This paper introduces two Julia packages, Margins.jl and FormulaCompiler.jl, that significantly improve the efficiency and scalability of marginal effects analysis in statistical models, outperforming existing R implementations.
Contribution
The paper presents novel Julia packages that enable fast, memory-efficient marginal effects analysis at scale, filling a gap in computational tools for statistical interpretation.
Findings
622x speedup over R's marginaleffects
460x memory reduction compared to R
Successful analysis of 500,000 observations where R fails
Abstract
Marginal effects analysis is fundamental to interpreting statistical models, yet existing implementations face computational constraints that limit analysis at scale. We introduce two Julia packages that address this gap. Margins.jl provides a clean two-function API organizing analysis around a 2-by-2 framework: evaluation context (population vs profile) by analytical target (effects vs predictions). The package supports interaction analysis through second differences, elasticity measures, categorical mixtures for representative profiles, and robust standard errors. FormulaCompiler.jl provides the computational foundation, transforming statistical formulas into zero-allocation, type-specialized evaluators that enable O(p) per-row computation independent of dataset size. Together, these packages achieve 622x average speedup and 460x memory reduction compared to R's marginaleffects…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsData Analysis with R · Scientific Computing and Data Management · Species Distribution and Climate Change
