tvcm-plot {vcrpart} | R Documentation |
plot
method for tvcm
objects.
Description
plot
method and panel functions for tvcm
objects.
Usage
## 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 |
type |
the type of the plot. Available types are
|
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
|
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 |
pop |
a logical whether the viewport tree should be popped before return. |
gp |
graphical parameters. See |
part |
integer or letter. The partition i.e. varying coefficient component to be plotted. |
parm |
character vector ( |
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 |
margins |
a numeric vector |
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 |
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 |
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 ( |
... |
additional arguments passed to
|
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.
Value
The plot.fvcm
method returns NULL
.
Author(s)
Reto Burgin
References
Hastie, T., R. Tibshirani and J. Friedman (2001). The Elements of Statistical Learning (2 ed.). New York, USA: Springer-Verlag.
See Also
Examples
## ------------------------------------------------------------------- #
## 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)