plot_g_function: Plot g-function contribution

View source: R/plot_results.R

plot_g_functionR Documentation

Plot g-function contribution

Description

Creates a contribution plot for a specific g-function group. For degree-1 groups (single variable), produces a 2D scatter + piecewise-linear plot with slope labels and knot markers. For degree-2 groups (two variables), produces a 3D surface plot using plotly if available, or a filled contour plot.

Usage

plot_g_function(earth_result, group_index, response_idx = NULL)

Arguments

earth_result

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

group_index

Integer. Index of the g-function group (1-based, from list_g_functions()).

response_idx

Integer or NULL. For multivariate models, which response column to plot (1-based). Default NULL uses the first response.

Value

A ggplot2::ggplot object for d <= 1, or a plotly widget for d >= 2 (when plotly is installed). Falls back to ggplot2 contour if plotly is not available.

Examples


result <- fit_earth(mtcars, "mpg", c("cyl", "disp", "hp", "wt"))
plot_g_function(result, 1)


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