plot.gamtree: Plotting method for GAM trees

View source: R/gamtree.R

plot.gamtreeR Documentation

Plotting method for GAM trees

Description

Takes a fitted GAM tree and plots the smooth functions fitted in each of the terminal nodes of the tree.

Usage

## S3 method for class 'gamtree'
plot(
  x,
  which = "both",
  ylim = "firstnode",
  treeplot_ctrl = list(),
  gamplot_ctrl = list(),
  ...
)

Arguments

x

object of class gamtree.

which

character. The default ("both") plots the tree structure, followed by the model fitted in the terminal nodes. Alternatively, "tree" will plot the tree structure, and "terms" will plot the smooth (and parametric) terms from the terminal-node-specific and global model. Note that the fitted curves in the tree do not convey a conditional function of the predictor on the $x$-axis (as plotted when "terms" is specified). They are a function of the predictor on the $x$-axis, as well as all other predictors in the model and could thus be referred to as 'marginal' fitted curves.

ylim

"firstplot" (default), NULL, or a numeric vector of length 2. Only used for plotting the terminal-node models (not the tree). Specifies how the limits of the y-axes of the terminal node plots should be chosen. The default ("firstnode") uses the observations in the first node to determine the limits of the y-axes for all plots. Alternatively, NULL will determine the limits of the y-axes separately for each plot. Alternatively, a numeric vector of length two may be specified, specifying the lower and upper limits of the y-axes.

treeplot_ctrl

list of (named) arguments to be passed to plot.party.

gamplot_ctrl

list of (named) arguments to be passed to plot.gam. Note that not all arguments of plot.gam are supported. .

...

further arguments, currently not used.

Warning

The plotted terms by default also represent confidence bands. These should be taken with a big grain of salt, because they do NOT account for the searching of the tree structure; they assume the tree structure was known in advance. They should be interpreted as overly optimistic and with caution.

Examples

gt <- gamtree(Pn ~ s(PAR, k = 5L) | Species, data = eco, 
               cluster = Specimen) 
plot(gt, which = "tree") # default is which = 'both'
plot(gt, which = "terms")

marjoleinF/gamtree documentation built on July 3, 2024, 9:18 a.m.