Margins.jl and FormulaCompiler.jl: Marginal effects for Julia

emfeltham
Wed, 14 Jan 2026 02:08:14 +0000
Package Announcements

Marginal effects analysis is fundamental to interpreting statistical models, yet existing implementations face computational constraints that limit analysis at scale. I introduce two Julia packages that address this gap. Margins.jl provides a clean two-function API organizing analysis around a framework centered on the evaluation context (population vs profile) and the 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 type-specialized evaluators. Together, these packages perform well compared to R’s marginaleffects package, and provide the first comprehensive and efficient marginal effects implementation for Julia’s statistical ecosystem.

See the packages at

github.com

GitHub - emfeltham/Margins.jl: Methods for marginal effects, adjusted...

Methods for marginal effects, adjusted predictions, and contrasts for post-estimation with linear models.

github.com

GitHub - emfeltham/FormulaCompiler.jl: High‑performance compilation of statistical...

High‑performance compilation of statistical formulas to zero‑allocation evaluators with FD/AD derivative support, serving as a stable computational foundation for post-estimation analysis and simulation with formula-based linear models in Julia.

3 posts - 2 participants