plot_smooth_term: Plot non-linear functions for BHAM objects

View source: R/plot_smooth_term.R

plot_smooth_termR Documentation

Plot non-linear functions for BHAM objects

Description

Plot non-linear functions for BHAM objects

Usage

plot_smooth_term(mdl, term, smooth, min, max, plot = TRUE)

Arguments

mdl

a model fitted using bgam, banlasso or bacoxph

plot

a logic variable, indicating if ggplots are produced

terms

a vector of characters containing the variable names

Examples

library(glmnet); data("QuickStartExample")  # Load example data
x <- QuickStartExample$x; colnames(x) <- paste0("X", 1:ncol(x))
y <- QuickStartExample$y

dat <- data.frame(x, y)

spl_df <- data.frame(
   Var = colnames(x),
   Func = "s",
  Args ="bs='cr', k=7"
)

train_sm_dat <- construct_smooth_data(spl_df, dat)
train_smooth <- train_sm_dat$Smooth
train_smooth_data <- train_sm_dat$data
mdl <-bamlasso(x = train_smooth_data, y = y, family = "gaussian",
               group = make_group(names(train_smooth_data)))
plot_smooth_term(mdl, "X3", train_smooth, min = min(x[,"X3"])-0.1, max = max(x[,"X3"]) + 0.1)


boyiguo1/BHAM documentation built on Jan. 29, 2024, 10:37 a.m.