plot_loglik: Log-likelihood profile plot for the transformation parameter

View source: R/methods.R

plot_loglikR Documentation

Log-likelihood profile plot for the transformation parameter

Description

Fits the model over a fine grid of transformation parameter values and plots the profile log-likelihood for both the Box-Cox and logarithmic transformation models in one panel (layout = "joint", default): the log transformation parameter r to the left and the Box-Cox parameter rho to the right of a dotted line at zero, where the families meet (\rho \to 0 is the log model with r = 1, r \to 0 the Box-Cox model with \rho = 1). layout = "panels" gives two panels side by side. Curves are natural splines through the grid points. For competing risks the plot refers to the event coded 1; for another event, recode the status and call the function again.

Usage

plot_loglik(
  formula,
  data,
  id = "id",
  rho_grid = seq(0.01, 1.2, by = 0.01),
  r_grid = seq(0.01, 1.2, by = 0.01),
  tau = NULL,
  mark_points = TRUE,
  layout = NULL,
  legend = TRUE,
  file = NULL,
  width = NULL,
  height = NULL,
  verbose = TRUE,
  ...
)

Arguments

formula

A formula as passed to wnpmle_fit.

data

A data frame.

id

Name of the subject identifier column.

rho_grid

A numeric vector of rho values for the Box-Cox model (default: seq(0.01, 1.2, by = 0.01)).

r_grid

A numeric vector of r values for the log model (default: seq(0.01, 1.2, by = 0.01)).

tau

Optional truncation time. If NULL (default), uses the maximum observed time in the data.

mark_points

Logical; if TRUE (default), marks reference points at rho=1 (open circle; Ghosh-Lin model, or Fine-Gray model for type = "cmprsk") and r=1 (filled circle, proportional odds model).

layout

"joint" (default: one panel, logarithmic left and Box-Cox right of a dotted line at zero, where the families meet) or "panels" (two panels side by side with a common y-axis).

legend

Logical; add a legend (default TRUE). The curves are shown relative to their optimum (0 = best; -\Delta\mathrm{AIC}/2), with a dotted line at -1, i.e. a difference of 2 in AIC; all transformations have the same number of parameters, so the largest log-likelihood is the smallest AIC. The layout "joint" is that of Figure 2 in Bellach and Kosorok (2026).

file

Optional path to save the plot as a PDF (e.g. "loglik_profile.pdf"). If NULL (default), plots to the current device.

width, height

Size of the PDF in inches; default 3.6 x 2.8 (pointsize 9, as Figure 2 of Bellach and Kosorok, 2026) for layout = "joint", 7 x 4.5 for "panels"; only used when file is given.

verbose

Logical; print progress (default TRUE).

...

Additional arguments passed to wnpmle_fit.

Value

A data frame of class "wnpmle_profile" with columns model, param and loglik, invisibly. Save it (res <- plot_loglik(...)) to redraw the figure with plot.wnpmle_profile without refitting.

Examples


bdata <- bladder_prep()
bdata_clean <- bdata[, c("id", "time", "status", "treat", "num", "size")]
# a coarse grid keeps the example short; use finer grids in practice
plot_loglik(Surv(time, status) ~ treat + num + size,
            data = bdata_clean, id = "id",
            rho_grid = seq(0.2, 1.2, by = 0.2),
            r_grid   = seq(0.2, 1.2, by = 0.2))


wnpmle documentation built on Dec. 1, 2026, 9:06 a.m.