tvcm-plot: 'plot' method for 'tvcm' objects.

Description Usage Arguments Details Author(s) References See Also Examples

Description

plot method and panel functions for tvcm objects.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## S3 method for class 'tvcm'
plot(x, type = c("default", "coef", 
        "simple", "partdep", "cv"),
     main, part = NULL, drop_terminal = TRUE,
     tnex, newpage = TRUE, ask = NULL,
     pop = TRUE, gp = gpar(), ...)

panel_partdep(object, parm = NULL,
              var = NULL, ask = NULL,
              prob = NULL, neval = 50, add = FALSE,
              etalab = c("int", "char", "eta"), ...)

panel_coef(object, parm = NULL, 
           id = TRUE, nobs = TRUE,
           exp = FALSE,
           plot_gp = list(),
           margins, yadj = 0.1,
           mean = FALSE, mean_gp = list(),
           conf.int = FALSE, conf.int_gp = list(),
           abbreviate = TRUE, etalab = c("int", "char", "eta"), ...)

Arguments

x, object

An object of class tvcm.

type

the type of the plot. Available types are "default", "simple", "coef", "partdep" and "cv".

main

character. A main title for the plot.

drop_terminal

a logical indicating whether all terminal nodes should be plotted at the bottom. See also plot.party.

tnex

a numeric value giving the terminal node extension in relation to the inner nodes. By default the value is computed adaptively to the tree size.

newpage

a logical indicating whether grid.newpage() should be called.

pop

a logical whether the viewport tree should be popped before return.

gp

graphical parameters. See gpar.

part

integer or letter. The partition i.e. varying coefficient component to be plotted.

parm

character vector (panel_partdep and panel_coef) or list of character vectors (panel_coef) with names of model coefficients corresponding to the chosen component. Indicates which coefficients should be visualized. If parm is a list, a separate panel is allocated for each list component.

var

character vector. Indicates the partitioning variables to be visualized.

ask

logical. Whether an input should be asked before printing the next panel.

prob

a probability between 0 and 1. Gives the size of the random subsample over which the coefficients are averaged. May be smaller than 1 if the sample is large.

neval

the maximal number of distinct values of the variable to be evaluated.

add

logical. Whether the panel is to be added into an active plot.

id

logical. Whether the node id should be displayed.

nobs

logical. Whether the number of observations in each node should be displayed.

exp

logical. Whether the labels in the y-axes should be the exponential of coefficients.

plot_gp

a list of graphical parameters for the panels. Includes components xlim, ylim, pch, ylab, type (the type of symbols, e.g. "b"), label (characters for ticks at the x axis), height, width, gp (a list produced by gpar). If parm is a list, plot_gp may be a nested list specifying the graphical parameters for each list component of parm. See examples.

margins

a numeric vector c(bottom, left, top, right) specifying the space on the margins for each panel. By default the values are computed adaptively to the tree size.

yadj

a numeric scalar larger than zero that increases the margin above the panel. May be useful if the edge labels are covered by the coefficient panels.

mean

logical. Whether the average coefficients over the population should be visualized.

mean_gp

list with graphical parameters for plotting the mean coefficients. Includes a component gp = gpar(...) and a component pch. See examples.

conf.int

logical. Whether confidence intervals should be visualized. These are indicative values only. They do not account for the uncertainty of model selection procedure.

conf.int_gp

a list of graphical parameters for the confidence intervals applied to arrow. Includes angle, length, ends and type. See examples.

abbreviate

logical scalar. Whether labels of coefficients should be abbreviated.

etalab

character. Whether category-specific effects should be labeled by integers of categories (default), the labels of the categories ("char") or the index of the predictor ("eta").

...

additional arguments passed to panel_partdep or panel_coef or other methods.

Details

The plot functions allow the diagnosis of fitted tvcm objects. type = "default", type = "coef" and type = "simple" show the tree structure and coefficients in each node. type = "partdep" plots partial dependency plots, see Hastie et al. (2001), section 10.13.2. Finally, type = "cv" shows, if available, the results from cross-validation.

The functions panel_partdep and panel_coef are exported to show the additional arguments that can be passed to ... of a plot call.

Notice that user-defined plots can be generated by the use of the plot.party function, see partykit.

Author(s)

Reto Buergin

References

Hastie, T., R. Tibshirani and J. Friedman (2001). The Elements of Statistical Learning (2 ed.). New York, USA: Springer-Verlag.

See Also

tvcm, tvcm-methods

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
31
32
33
34
35
36
## ------------------------------------------------------------------- #
## Dummy example:
##
## Plotting the types "coef" and "partdep" for a 'tvcm' object fitted 
## on the artificial data 'vcrpart_2'.
## ------------------------------------------------------------------- # 

data(vcrpart_2)

## fit the model
model <- tvcglm(y ~ vc(z1, z2, by = x1, intercept = TRUE) + x2,
                data = vcrpart_2, family = gaussian(),
                control = tvcm_control(maxwidth = 3, minbucket = 5L))

## plot type "coef"
plot(model, "coef")

## add various (stupid) plot parameters
plot(model, "coef",
     plot_gp = list(type = "p", pch = 2, ylim = c(-4, 4),
       label = c("par1", "par2"), gp = gpar(col = "blue")),
     conf.int_gp = list(angle = 45, length = unit(2, "mm"),
       ends = "last", type = "closed"),
     mean_gp = list(pch = 16,
       gp = gpar(fontsize = 16, cex = 2, col = "red")))

## separate plots with separate plot parameters
plot(model, "coef", parm = list("(Intercept)", "x1"), tnex = 2,
     plot_gp = list(list(gp = gpar(col = "red")),
                    list(gp = gpar(col = "blue"))),
     mean_gp = list(list(gp = gpar(col = "green")),
                    list(gp = gpar(col = "yellow"))))

## plot type "partdep"
par(mfrow = c(1, 2))
plot(model, "partdep", var = "z1", ask = FALSE)

vcrpart documentation built on Feb. 16, 2018, 1:03 a.m.