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

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

4 Likes