datalorax/equatiomatic
Convert models to LaTeX equations
What it solves
equatiomatic is an R package designed to eliminate the manual effort of writing LaTeX code for statistical models. Instead of manually translating a fitted model's formula into a mathematical equation, users can automatically generate the LaTeX representation of that model.
How it works
The package provides the extract_eq() function, which takes a fitted model object (such as those created by lm(), glm(), or MASS::polr()) and converts it into a LaTeX string. It handles complex scenarios such as shortcut syntax (e.g., mpg ~ .), categorical variables with subscripts for different levels, and the preservation of variable order from the original formula.
Who it’s for
It is primarily for researchers, statisticians, and data scientists using R who need to report their mathematical models in LaTeX-formatted documents (like R Markdown).
Highlights
- Broad Model Support: Supports various models including linear regression (
lm), logistic and probit regression (glm), and ordered logistic/probit regression (MASS::polrandordinal::clm). - Customizable Appearance: Offers options to wrap long equations across multiple lines, control the position of mathematical operators, and toggle between italicized variables and
\operatorname{}wrapping. - Coefficient Integration: Can return actual numeric coefficients instead of generic Greek letters (e.g., $\beta_1$) using the
use_coefs = TRUEargument. - RStudio Integration: Includes a
preview_eq()function for quick visual verification of the equation in RStudio.
Related
- Project
- Project
- Project
- Project
- Project