Package {hyper.gam}


Type: Package
Title: Generalized Additive Models with Hyper Column
Version: 0.3.0
Date: 2026-05-17
Description: An interactive HTML widget of the perspective plot for generalized additive models. An alternative solution of the function mgcv::vis.gam().
Encoding: UTF-8
License: GPL-2
Language: en-US
URL: https://github.com/tingtingzhan/hyper.gam, https://tingtingzhan-btaf430.netlify.app
Depends: R (≥ 4.6)
Imports: cli, mgcv, plotly
Suggests: htmlwidgets
Config/roxygen2/version: 8.0.0
Config/roxygen2/markdown: TRUE
NeedsCompilation: no
Packaged: 2026-05-17 11:34:42 UTC; tingtingzhan
Author: Tingting Zhan ORCID iD [aut, cre], Erjia Cui ORCID iD [ctb] (up to v0.2.3)
Maintainer: Tingting Zhan <tingtingzhan@gmail.com>
Repository: CRAN
Date/Publication: 2026-05-17 22:50:16 UTC

hyper.gam: Generalized Additive Models with Hyper Column

Description

An interactive HTML widget of the perspective plot for generalized additive models. An alternative solution of the function mgcv::vis.gam().

Author(s)

Maintainer: Tingting Zhan tingtingzhan@gmail.com (ORCID)

Authors:

Other contributors:

See Also

Useful links:


Alternative of vis.gam

Description

An interactive htmlwidgets of the perspective plot for gam model(s) using the package plotly.

Usage

widget_gam(
  ...,
  formula,
  newdata = data,
  proj_xy = TRUE,
  proj_xz = TRUE,
  n = 501L,
  newid = seq_len(min(3L, nrow(newdata))),
  ylim = range(X[is.finite(X)], newX[is.finite(newX)]),
  surface_col = c("white", "lightgreen")
)

Arguments

...

one or more gam models based on a same data set.

formula

one-sided formula

newdata

(for future expansion)

proj_xy

logical scalar, whether to show the projection to the (x,y)-plain, default value is TRUE

proj_xz

logical scalar, whether to show the projection to the (x,z)-plain, default value is TRUE

n

integer scalar, fineness of visualization, default value is 501L. See parameter n.grid of the function vis.gam.

newid

integer scalar or vector, row indices of newdata to be visualized. Default 1:2, i.e., the first two test subjects. Use newid = NULL to disable the visualization of newdata.

ylim

length-2 double vector, range on q-axis. Default is the range of X and X^{\text{new}} combined.

surface_col

length-2 character vector, color of the integrand surface(s), for lowest and highest surface values

Value

The function widget_gam() returns a pretty htmlwidgets created by R package plotly.

Note

The maintainer is not aware of any functionality of projection of arbitrary curves in package plotly. Currently, the projections are hard coded.

Examples

library(mgcv)
# ?gam
set.seed(2)
dat = gamSim(1, n = 400, dist = 'normal', scale = 2)
gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = dat)