This function visualizes the joint effect of several variables in a generalized linear model (GLM) by plotting the predicted response over a range of values for the primary predictor variable, while holding other predictors at their median or mode values. It allows specifying a group for focused analysis.
visglm(
demogmdl,
qmdl,
x,
y,
group = NULL,
titlestring = "",
varstoadd = NULL,
groupvar = "group",
predictorsigns = NULL,
jdf_simulation = FALSE,
xrange = NULL,
verbose = FALSE
)
Data frame containing the variables used in the GLM.
Fitted GLM object from which predictions will be generated.
Character vector specifying the names of the predictor variables, with the first being the primary.
The name of the response variable.
The name of the group variable or specific group to be analyzed.
Title of the plot indicating the focus of the visualization.
optional additional variables to add into the model; otherwise just extract from the equation
Optional; the name of the variable in demogmdl
that defines group membership. Default is 'group'.
Optional; a named numeric vector indicating the direction of the effect of each predictor.
boolean
explicitly set xrange
Logical; if TRUE, additional processing information will be printed to the console.
Generates a plot visualizing the predicted response and confidence intervals across the range of the primary predictor.
# Assuming `data` is your dataset, `fit` is a fitted GLM,
# and you're interested in predictors `x1` and `x2`:
# visglm(data, fit, c("x1", "x2"), "y", "control",
# "Visualization for Control Group")
#