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

**URL:** <https://discourse.julialang.org/t/margins-jl-and-formulacompiler-jl-marginal-effects-for-julia/135038>\
**Category:** Package Announcements\
**Tags:** statistics, econometrics\
**Created:** [January 14, 2026, 2:08am UTC](https://discourse.julialang.org/t/margins-jl-and-formulacompiler-jl-marginal-effects-for-julia/135038 "2026-01-14T02:08:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![emfeltham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/emfeltham/32/48046_2.png) [@emfeltham](https://discourse.julialang.org/u/emfeltham)\
**Post date:** [January 14, 2026, 2:08am UTC](https://discourse.julialang.org/t/margins-jl-and-formulacompiler-jl-marginal-effects-for-julia/135038/1 "2026-01-14T02:08:14Z")

</div>

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 - emfeltham/Margins.jl: Methods for marginal effects, adjusted...](https://github.com/emfeltham/Margins.jl)**
>
> Methods for marginal effects, adjusted predictions, and contrasts for post-estimation with linear models.

> **[GitHub - emfeltham/FormulaCompiler.jl: High‑performance compilation of statistical...](https://github.com/emfeltham/FormulaCompiler.jl)**
>
> 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.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [January 14, 2026, 8:56am UTC](https://discourse.julialang.org/t/margins-jl-and-formulacompiler-jl-marginal-effects-for-julia/135038/2 "2026-01-14T08:56:55Z")

</div>

Nice! How does this compare to [GitHub - beacon-biosignals/Effects.jl: Effects Prediction for Regression Models](https://github.com/beacon-biosignals/Effects.jl)?

---

<div class="post-metadata">

**Author:** ![emfeltham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/emfeltham/32/48046_2.png) [@emfeltham](https://discourse.julialang.org/u/emfeltham)\
**Post date:** [January 14, 2026, 2:24pm UTC](https://discourse.julialang.org/t/margins-jl-and-formulacompiler-jl-marginal-effects-for-julia/135038/3 "2026-01-14T14:24:38Z")

</div>

Thank you! Effects.jl calculates adjusted predictions, and is closer to R’s emmeans (estimated marginal means at reference grids – profile-based estimates), while Margins.jl is a bit more comprehensive, also including the functionality of R’s marginaleffects (or `margins` in Stata), computing both derivatives/contrasts and predictions, with both population-averaged and profile-based evaluation. It is also designed to be very efficient for larger datasets and complex models.
