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
)

Arguments

demogmdl

Data frame containing the variables used in the GLM.

qmdl

Fitted GLM object from which predictions will be generated.

x

Character vector specifying the names of the predictor variables, with the first being the primary.

y

The name of the response variable.

group

The name of the group variable or specific group to be analyzed.

titlestring

Title of the plot indicating the focus of the visualization.

varstoadd

optional additional variables to add into the model; otherwise just extract from the equation

groupvar

Optional; the name of the variable in demogmdl that defines group membership. Default is 'group'.

predictorsigns

Optional; a named numeric vector indicating the direction of the effect of each predictor.

jdf_simulation

boolean

xrange

explicitly set xrange

verbose

Logical; if TRUE, additional processing information will be printed to the console.

Value

Generates a plot visualizing the predicted response and confidence intervals across the range of the primary predictor.

Examples

# 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")
#