plot.prtree: Plot method for PRTree objects

View source: R/prtree_main_methods.R

plot.prtreeR Documentation

Plot method for PRTree objects

Description

Provides visualization of a fitted Probabilistic Regression Tree model. Note that the original response vector y is only required for plots 1-4. Plot 5 (terminal node probabilities) can be generated without y.

Usage

## S3 method for class 'prtree'
plot(x, y = NULL, which = NULL, ncol = NULL, ...)

Arguments

x

An object of class prtree, as returned by pr_tree.

y

Original response vector used to fit the model. Required only for plots 1-4 (Fitted vs Observed, Residuals, Histogram, Q-Q plot). Can be omitted if only plot 5 is requested.

which

Which plots to produce. Options are:

  • 1: Observed vs Fitted - Scatter plot comparing observed responses against fitted values. Requires y.

  • 2: Residuals (index plot) - Residuals plotted against observation index. Useful for detecting patterns or outliers. Requires y.

  • 3: Histogram of residuals - Distribution of residuals with Freedman-Diaconis bin selection. Requires y.

  • 4: Q-Q plot of residuals - Quantile-quantile plot to assess normality of residuals. Requires y.

  • 5: Terminal node probabilities - Boxplot of P(R|X) for each terminal node. Does not require y.

If NULL (default), shows all plots (1-5).

ncol

Integer. Number of columns in the plot layout. If NULL (default), an appropriate number of columns is chosen automatically based on the number of plots.

...

Further arguments passed to ggplot2 (e.g., color, size, alpha).

Value

Invisibly returns the original object.


PRTree documentation built on Nov. 23, 2026, 9:08 a.m.