neuralGAM
objects (epistemic-only)R/autoplot.neuralGAM.R
autoplot.neuralGAM.Rd
Produce effect/diagnostic plots from a fitted neuralGAM
model.
Supported panels:
which = "response"
: fitted response vs. index, with optional
epistemic confidence intervals (CI).
which = "link"
: linear predictor (link scale) vs. index,
with optional CI.
which = "terms"
: single per-term contribution \(g_j(x_j)\) on the link scale,
with optional CI band for the smooth (epistemic).
A fitted neuralGAM
object.
Optional data.frame
/list of covariates. If omitted, training data are used.
One of c("response","link","terms")
. Default "response"
.
One of c("none","confidence")
. Default "confidence"
.
Coverage level for confidence intervals (e.g., 0.95
). Default 0.95
.
Integer. Number of MC-dropout forward passes used when
uncertainty_method %in% c("epistemic","both")
.
Single term name to plot when which = "terms"
.
Logical; if TRUE
(default), add rugs to continuous term plots.
Additional arguments passed to predict.neuralGAM
.
A single ggplot
object.
Uncertainty semantics (epistemic only)
CI: Uncertainty about the fitted mean.
For the response, SEs are mapped via the delta method;
For terms, bands are obtained as \(\hat g_j \pm z \cdot SE(\hat g_j)\) on the link scale.
# \dontrun{
library(neuralGAM)
dat <- sim_neuralGAM_data()
train <- dat$train
test <- dat$test
ngam <- neuralGAM(
y ~ s(x1) + x2 + s(x3),
data = train, family = "gaussian", num_units = 128,
uncertainty_method = "epistemic", forward_passes = 10
)
#> [1] "Initializing neuralGAM..."
#> Hint: To use tensorflow with `py_require()`, call `py_require("tensorflow")` at the start of the R session
#> Error in validate_activation(activation): Invalid activation 'relu'. Use a valid tf.keras activation name or an R function.
## --- Autoplot (epistemic-only) ---
# Per-term effect with CI band
autoplot(ngam, which = "terms", term = "x1", interval = "confidence") +
ggplot2::xlab("x1") + ggplot2::ylab("Partial effect")
#> Error: object 'ngam' not found
# Request a different number of forward passes or CI level:
autoplot(ngam, which = "terms", term = "x1", interval = "confidence",
forward_passes = 15, level = 0.7)
#> Error: object 'ngam' not found
# Response panel
autoplot(ngam, which = "response")
#> Error: object 'ngam' not found
# Link panel with custom title
autoplot(ngam, which = "link") +
ggplot2::ggtitle("Main Title")
#> Error: object 'ngam' not found
# }