plot.boostmtree: Plot fitted trajectories and diagnostic summaries for a...

View source: R/plot.boostmtree.R

plot.boostmtreeR Documentation

Plot fitted trajectories and diagnostic summaries for a boostmtree object

Description

Display fitted trajectories, error paths, and related diagnostics for objects produced by boostmtree() or compatible prediction methods.

Usage

## S3 method for class 'boostmtree'
plot(
  x,
  use.rmse = TRUE,
  output = c("plot", "data", "pdf"),
  file = NULL,
  width = 10,
  height = 10,
  verbose = TRUE,
  ...
)

Arguments

x

An object of class c("boostmtree", "grow", ...) or c("boostmtree", "predict", ...).

use.rmse

Logical; if TRUE, error paths are shown on the standardized RMSE scale. If FALSE, the returned or plotted error path is converted to mean squared error.

output

How the result should be returned. The default, "plot", draws directly on the active graphics device. Use "data" to return the plot data without drawing, or "pdf" to write the plot to a PDF file.

file

File path used when output = "pdf". Ignored otherwise.

width

Width of the PDF device in inches when output = "pdf".

height

Height of the PDF device in inches when output = "pdf".

verbose

Logical; when TRUE and output = "pdf", print the location of the written PDF file.

...

Currently ignored. Included for S3 compatibility.

Details

The plot method is intended to give a quick visual summary of a fitted boostmtree object.

For a grow object, the panels typically show some combination of:

  • fitted trajectories over time,

  • residual trajectories,

  • observed-versus-fitted summaries,

  • the cross-validation error path when cv.flag = TRUE, and

  • the iteration paths for the nuisance parameters rho, phi, and lambda.

For a prediction object, the same plotting framework is used when stored test errors or variable-importance summaries are available.

Unlike the original implementation, the default behavior is now to draw on the active graphics device. A PDF file is created only when output = "pdf" is requested explicitly.

When output = "data", the method returns the numerical information used to make the plot. This is useful if you want to inspect the fitted curves or construct your own custom graphics.

Value

If output = "data", a list of plot-data objects is returned, one element per boosted subproblem. Each element can contain components such as time.by.subject, fitted.by.subject, observed.by.subject, error.path, rho.path, phi.path, lambda.path, and m.opt. Otherwise the same list is returned invisibly after plotting or writing the PDF file.

References

Pande A., Li L., Rajeswaran J., Ehrlinger J., Kogalur U.B., Blackstone E.H., Ishwaran H. (2017). Boosted multivariate trees for longitudinal data. Machine Learning, 106(2):277–305.

Pande A., Ishwaran H., Blackstone E.H., Rajeswaran J., and Gillanov M. (2022). Application of gradient boosting in evaluating surgical ablation for atrial fibrillation. SN Computer Science, 3:466.

Pande A., Ishwaran H., and Blackstone E.H. (2022). Boosting for multivariate longitudinal responses. SN Computer Science, 3:186.

See Also

boostmtree, print.boostmtree, simLong

Examples

## Fit a small model and draw the default summary plot.
set.seed(23)
sim.obj <- simLong(n = 15, n.time = 4, family = "continuous")
dta <- sim.obj$data.list

fit <- boostmtree(
  x = dta$features,
  tm = dta$time,
  id = dta$id,
  y = dta$y,
  family = "continuous",
  M = 8,
  verbose = FALSE
)

plot(fit)

## Return the plot data instead of drawing.
plot.data <- plot(fit, output = "data")
names(plot.data[[1]])


## Write the plot to a PDF only when requested explicitly.
out.file <- tempfile(fileext = ".pdf")
plot(fit, output = "pdf", file = out.file, verbose = FALSE)


boostmtree documentation built on April 10, 2026, 9:10 a.m.