plot.glmertree | R Documentation |
plot
method for (g)lmertree
objects.
## S3 method for class 'lmertree'
plot(x, which = "all", nodesize_level = 1L,
cluster = NULL, ask = TRUE, type = "extended",
observed = TRUE, fitted = "combined", tp_args = list(),
drop_terminal = TRUE, terminal_panel = NULL, dotplot_args = list(), ...)
## S3 method for class 'glmertree'
plot(x, which = "all", nodesize_level = 1L,
cluster = NULL, ask = TRUE, type = "extended",
observed = TRUE, fitted = "combined", tp_args = list(),
drop_terminal = TRUE, terminal_panel = NULL, dotplot_args = list(), ...)
x |
an object of class |
which |
character; |
nodesize_level |
numeric. At which grouping level should sample size
printed above each terminal node be computed? Defaults to 1, which
is the lowest level of observation. If a value of 2 is specified,
sample size at the cluster level will be printed above each terminal node.
This only works if |
cluster |
vector of cluster ids. Only used if |
ask |
logical. Should user be asked for input, before a new figure is drawn? |
type |
character; |
observed |
logical. Should observed datapoints be plotted in the tree?
Defaults to |
fitted |
character. |
tp_args |
list of arguments to be passed to panel generating function
|
drop_terminal |
logical. Should all terminal nodes be plotted at the bottom of the plot? |
terminal_panel |
an optional panel generating function to be passed to
|
dotplot_args |
Optional list of additional arguments to be passed to
|
... |
Additional arguments to be passed to |
If the node-specific model of the (g)lmertree
object specified by
argument x
is an intercept-only model, observed data distributions
will be plotted in the terminal nodes of the tree (using
node_barplot
(for categorical responses) or
node_boxplot
(for numerical responses). Otherwise,
fitted values will be plotted, in addition to observed datapoints, using a
function taking similar arguments as node_bivplot
.
Exceptions:
If fitted = "marginal"
, fitted values will be plotted by assuming the
mean (continuous predictors) or mode (categorical predictors) for all
predictor variables, except the variable on the x-axis of the current plot.
If which = "growth"
, individual growth curves will be plotted as thin grey
lines in the terminal nodes, while the node-specific fixed effect will be plotted
on top of that as a thicker red curve.
If which = "tree.coef"
), caterpillar plot(s) are created for the local
(node-specific) fixed effects. These depict the estimated fixed-effects
coefficients with 95% confidence intervals, but note that these CIs do not
account for the searching of the tree structure and are therefore likely
too narrow. There is currently no way to adjust CIs for searching of the tree
structure, but the CIs can be useful to obtain an indication of the variability
of the coefficient estimates, not for statistical significance testing.
If which = "ranef"
or "all"
, caterpillar plot(s) for the random
effect(s) created, depicting the predicted random effects with 95% confidence
intervals. See also ranef
for more info. Note that the CIs
do not account for the searching of the tree structure and may be too narrow.
If users want to specify custom panel generating functions, it might be best to
not use the plotting method for (g)lmertrees. Instead, extract the (g)lmtree from
the fitted (g)lmertree object (which is a list containing, amongst others, an element
$tree
). On this tree, most of the customization options from
party-plot
can then be applied.
The code is still under development and might change in future versions.
Fokkema M, Smits N, Zeileis A, Hothorn T, Kelderman H (2018). “Detecting Treatment-Subgroup Interactions in Clustered Data with Generalized Linear Mixed-Effects Model Trees”. Behavior Research Methods, 50(5), 2016-2034. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.3758/s13428-017-0971-x")}
lmertree
, glmertree
,
party-plot
.
## load artificial example data
data("DepressionDemo", package = "glmertree")
## fit linear regression LMM tree for continuous outcome
lt <- lmertree(depression ~ treatment + age | cluster | anxiety + duration,
data = DepressionDemo)
plot(lt)
plot(lt, type = "simple")
plot(lt, which = "tree", fitted = "combined")
plot(lt, which = "tree", fitted = "none")
plot(lt, which = "tree", observed = FALSE)
plot(lt, which = "tree.coef")
plot(lt, which = "ranef")
## fit logistic regression GLMM tree for binary outcome
gt <- glmertree(depression_bin ~ treatment + age | cluster |
anxiety + duration, data = DepressionDemo)
plot(gt)
plot(gt, type = "simple")
plot(gt, which = "tree", fitted = "combined")
plot(gt, which = "tree", fitted = "none")
plot(gt, which = "tree.coef")
plot(gt, which = "ranef")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.