print.coat {coat} | R Documentation |
Methods for Conditional Method Agreement Trees (COAT)
Description
Extracting information from or visualization of conditional method agreement trees. Visualizations use trees with Bland-Altman plots in terminal nodes, drawn either via grid graphics directly or via ggplot2.
Usage
## S3 method for class 'coat'
print(
x,
digits = 2L,
header = TRUE,
footer = TRUE,
title = "Conditional method agreement tree (COAT)",
...
)
## S3 method for class 'coat'
coef(object, node = NULL, drop = TRUE, ...)
## S3 method for class 'coat'
plot(x, terminal_panel = node_baplot, tnex = 2, drop_terminal = TRUE, ...)
node_baplot(
obj,
level = 0.95,
digits = 2,
pch = 1,
cex = 0.5,
col = 1,
linecol = 4,
lty = c(1, 2),
bg = "white",
confint = FALSE,
B = 500,
cilevel = 0.95,
cicol = "lightgray",
xscale = NULL,
yscale = NULL,
ylines = 3,
id = TRUE,
mainlab = NULL,
gp = gpar()
)
## S3 method for class 'coat'
autoplot(
object,
digits = 2,
xlim.max = NULL,
level = 0.95,
label.align = 0.95,
...
)
Arguments
x , object , obj |
a |
digits |
numeric. Number of digits used for rounding the displayed coefficients or limits of agreement. |
header , footer |
logical. Should a header/footer be printed for the tree? |
title |
character with the title for the tree. |
... |
further arguments passed to methods. |
node |
integer. ID of the node for which the Bland-Altman parameters (coefficients) should be extracted. |
drop |
logical. Should the matrix attribute be dropped if the parameters from only a single node are extracted? |
terminal_panel |
a panel function or panel-generating function passed to
|
tnex |
numeric specification of the terminal node extension relative to the inner nodes (default is twice the size). |
drop_terminal |
logical. Should all terminal nodes be "dropped" to the bottom row? |
level |
numeric level for the limits of agreement. |
pch , cex , col , linecol , lty , bg |
graphical parameters for the scatter plot and limits of agreement in the Bland-Altman plot (scatter plot character, character extension, plot color, line color, line types, and background color). |
confint |
logical. Should nonparametric bootstrap percentile confidence intervals be plotted? |
B |
numeric. Number of bootstrap samples to be used if |
cilevel |
numeric. Level of the confidence intervals if |
cicol |
color specification for the confidence intervals if |
xscale , yscale |
numeric specification of scale of x-axis and y-axis, respectively. By default the range of all scatter plots and limits of agreement across all nodes are used. |
ylines |
numeric. Number of lines for spaces in y-direction. |
id |
logical. Should node IDs be plotted? |
mainlab |
character or function. An optional title for the plots. Either
a character or a |
gp |
grid graphical parameters. |
xlim.max |
numeric. Optional value to define the upper limit of the x-axis. |
label.align |
numeric. Specification between 0 and 1 for the alignment of labels
relative to the plot width or |
Details
Various methods are provided for trees fitted by coat
,
in particular print
, plot
(via grid/partykit),
autoplot
(via ggplot2/ggparty),
coef
. The plot
method draws Bland-Altman plots in the terminal panels by default,
using the function node_baplot
. The autoplot
draws very similar plots by
customizing the geom_node_plot
"from scratch".
In addition to these dedicated coat
methods, further methods are inherited
from ctree
or mob
, respectively,
depending on which type
of coat
was fitted.
Value
The print()
method returns the printed object invisibly.
The coef()
method returns the vector (for a single node) or matrix (for multiple nodes) of estimated parameters (bias and standard deviation).
The plot()
method returns NULL
.
The node_baplot()
panel-generating function returns a function that can be plugged into the plot()
method.
The autoplot()
method returns a ggplot
object.
Examples
## package and data (reshaped to wide format)
library("coat")
data("scint", package = "MethComp")
scint_wide <- reshape(scint, v.names = "y", timevar = "meth", idvar = "item", direction = "wide")
## conditional method agreement tree
tr <- coat(y.DTPA + y.DMSA ~ age + sex, data = scint_wide)
## illustration of methods (including some customization)
## printing
print(tr)
print(tr, header = FALSE, footer = FALSE)
## extracting Bland-Altman parameters
coef(tr)
coef(tr, node = 1)
## visualization (via grid with node_baplot)
plot(tr)
plot(tr, ip_args = list(id = FALSE),
tp_args = list(col = "slategray", id = FALSE, digits = 3, pch = 19))
## visualization (via ggplot2 with ggparty)
library("ggplot2")
autoplot(tr)
autoplot(tr, digits = 3) + ggtitle("Conditional method agreement tree") +
theme(plot.title = element_text(hjust = 0.5))