Learn R Programming

SVEMnet (version 3.2.0)

plot.svem_binomial: Plot Method for SVEM Binomial Models

Description

Diagnostics for svem_binomial fits from SVEMnet(..., family = "binomial"). Produces one of:

  • type = "calibration": Reliability curve (binned average predicted probability vs observed rate), with jittered raw points for context.

  • type = "roc": ROC curve with trapezoidal AUC in the title.

  • type = "pr": Precision–Recall curve with step-wise Average Precision (AP).

Usage

# S3 method for svem_binomial
plot(
  x,
  type = c("calibration", "roc", "pr"),
  bins = 10,
  jitter_width = 0.05,
  ...
)

Value

A ggplot2 object.

Arguments

x

An object of class svem_binomial.

type

One of "calibration", "roc", or "pr" (default "calibration").

bins

Integer number of equal-frequency bins for calibration (default 10).

jitter_width

Vertical jitter amplitude for raw points in calibration (default 0.05).

...

Additional aesthetics passed to ggplot2::geom_line() or ggplot2::geom_point().

Details

For ROC/PR, simple one-class guards are used (returns a diagonal ROC and trivial PR). The function assumes binomial models store x$y_pred on the probability scale.

Examples

Run this code
if (FALSE) {
  ## --- Binomial example: simulate, fit, and plot --------------------------
  set.seed(2025)
  n  <- 600
  x1 <- rnorm(n); x2 <- rnorm(n); x3 <- rnorm(n)
  eta    <- -0.4 + 1.1*x1 - 0.8*x2 + 0.5*x3
  p_true <- plogis(eta)
  y      <- rbinom(n, 1, p_true)
  dat_b  <- data.frame(y, x1, x2, x3)

  fit_b <- SVEMnet(
    y ~ x1 + x2 + x3 + I(x1^2) + (x1 + x2 + x3)^2,
    data          = dat_b,
    family        = "binomial",
    glmnet_alpha  = c(1, 0.5),
    nBoot         = 60,
    objective     = "auto",
    weight_scheme = "SVEM",
    relaxed       = TRUE
  )

  # Calibration / ROC / PR
  plot(fit_b, type = "calibration", bins = 12)
  plot(fit_b, type = "roc")
  plot(fit_b, type = "pr")
}

Run the code above in your browser using DataLab