node_pmterminal: Panel-Generator for Visualization of pmtrees

Description Usage Arguments Examples

View source: R/plot-pmtree.R

Description

The plot method for party and constparty objects are rather flexible and can be extended by panel functions. The pre-defined panel-generating function of class grapcon_generator for pmtrees is documented here.

Usage

1
2
3
4
5
6
7
8
9
node_pmterminal(
  obj,
  coeftable = TRUE,
  digits = 2,
  confint = TRUE,
  plotfun,
  nid = function(node) paste0(nam[id_node(node)], ", n = ", node$info$nobs),
  ...
)

Arguments

obj

an object of class party.

coeftable

logical or function. If logical: should a table with coefficients be added to the plot (TRUE/FALSE)? If function: A function comparable to coeftable.survreg.

digits

integer, used for formating numbers.

confint

Should a confidence interval be computed.

plotfun

Plotting function to be used. Needs to be of format function(mod, data) where mod is the model object. See examples for more details.

nid

function to retrieve info on what is plottet as node ids.

...

arguments passed on to plotfun.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
if(require("survival")) {
## compute survreg model
mod_surv <- survreg(Surv(futime, fustat) ~ factor(rx), ovarian,
  dist = 'weibull')
survreg_plot(mod_surv)

## partition model and plot
tr_surv <- pmtree(mod_surv)
plot(tr_surv, terminal_panel = node_pmterminal(tr_surv, plotfun = survreg_plot,
                                               confint = TRUE))
}

if(require("survival") & require("TH.data")) {
  ## Load data
  data(GBSG2, package = "TH.data")

  ## Weibull model
  bmod <- survreg(Surv(time, cens) ~ horTh, data = GBSG2, model = TRUE)

  ## Coefficient table
  grid.newpage()
  coeftable.survreg(bmod)

  ## partitioned model
  tr <- pmtree(bmod)

  ## plot with specific coeftable
  plot(tr, terminal_panel = node_pmterminal(tr, plotfun = survreg_plot,
    confint = TRUE, coeftable = coeftable.survreg))
}

model4you documentation built on Jan. 8, 2021, 3:02 p.m.