format_model_equation: Format earth model as LaTeX equation

View source: R/format_results.R

format_model_equationR Documentation

Format earth model as LaTeX equation

Description

Converts a fitted earth model into a LaTeX-formatted mathematical representation using g-function notation. Basis functions are grouped by degree (constant, first-degree, second-degree, third-degree) and labeled with indices that encode the group, position, and factor variable count.

Usage

format_model_equation(earth_result, digits = 7L, response_idx = NULL)

Arguments

earth_result

An object of class "earthUI_result" as returned by fit_earth().

digits

Integer. Number of significant digits for coefficients and cut points. Default is 7.

response_idx

Integer or NULL. For multivariate models, which response column to generate the equation for (1-based). Default NULL returns all response equations in an earthUI_equation_multi object.

Value

A list containing:

latex

Character string. LaTeX array environment for HTML/MathJax rendering.

latex_inline

Character string. Wrapped in display math delimiters for MathJax/HTML rendering.

latex_pdf

Character string. LaTeX for native PDF output with escaped special characters in text blocks.

latex_word

Character string. LaTeX for Word/docx output.

groups

List of group structures for programmatic access.

Examples

result <- fit_earth(mtcars, "mpg", c("cyl", "disp", "hp", "wt"))
eq <- format_model_equation(result)
cat(eq$latex)

earthUI documentation built on March 26, 2026, 1:07 a.m.