gam_ctr_plot {BioPred} | R Documentation |
GAM Contrast Plot
Description
Computes and plots the contrasts between treatment and control group based on a GAM for exploring the relationship be-tween treatment benefit and biomarker.
Usage
gam_ctr_plot(
yvar,
censorvar = NULL,
xvar,
xvars.adj = NULL,
sxvars.adj = NULL,
trtvar = NULL,
type,
data,
k,
title = "Group Contrast",
ybreaks = NULL,
xbreaks = NULL,
rugcol.var = NULL,
link.scale = TRUE,
prt.sum = TRUE,
prt.chk = FALSE,
outlier.rm = FALSE
)
Arguments
yvar |
Response variable name. |
censorvar |
Censoring variable name (0-censored, 1-event). Required if type is "s" (survival). |
xvar |
Biomarker name. |
xvars.adj |
Potential confounding variables to adjust for using linear terms. |
sxvars.adj |
Potential confounding variables to adjust for using curves. |
trtvar |
Treatment variable that the contrast will build upon (treatment-control). |
type |
Type of response variable. Options are "c" for continuous, "s" for survival, and "b" for binary response. |
data |
The dataset containing the variables. |
k |
Upper limit on the degrees of freedom associated with an s smooth.When this k is too large, program will report error saying |
title |
Title of the plot. |
ybreaks |
Breaks on the y-axis. |
xbreaks |
Breaks on the x-axis. |
rugcol.var |
Variable name that defines the color of the rug. |
link.scale |
Whether to show the plot (y-axis) in the scale of the link function (linear predictor). |
prt.sum |
Whether to print summary or not. |
prt.chk |
Whether to print model diagnosis. |
outlier.rm |
Whether to remove outliers based on 1.5IQR. |
Value
A list containing the p-value table, summarized p-value table, s-value table, summarized s-value table, and the plot.
Examples
# Load a sample dataset
data <- data.frame(
response = rnorm(100),
biomarker = rnorm(100, mean = 50, sd = 10),
censor = sample(c(0, 1), 100, replace = TRUE),
treatment = sample(c(0, 1), 100, replace = TRUE),
age = rnorm(100, mean = 60, sd = 10),
group = sample(c("Group A", "Group B"), 100, replace = TRUE)
)
# Generate a GAM contrast plot for a continuous response variable
gam_ctr_plot(
yvar = "response",
xvar = "biomarker",
trtvar = "treatment",
type = "c",
data = data,
xvars.adj = "age",
k = 5,
title = "GAM Contrast Plot for Treatment vs. Control"
)
# Generate a GAM contrast plot for survival analysis
gam_ctr_plot(
yvar = "response",
censorvar = "censor",
xvar = "biomarker",
trtvar = "treatment",
type = "s",
data = data,
k = 5,
title = "GAM Contrast Plot for Survival Data"
)
# Generate a GAM contrast plot for a binary response variable
data$binary_response <- as.numeric(data$response > 0)
gam_ctr_plot(
yvar = "binary_response",
xvar = "biomarker",
trtvar = "treatment",
type = "b",
data = data,
k = 5,
title = "GAM Contrast Plot for Binary Outcome"
)