This method facilitates the interpretation of linear mixed-effects models and is a byproduct of the method fxInteractive.glm
for generalized linear models.
# S3 method for lme
fxInteractive (model, predict.lme.level = 0, initial.values = as.list(NULL),
preselect.var = NA, preselect.type = "effect", preselect.groups = NULL,
dev.height = 18, dev.width = 18, dev.width.legend = 8, dev.pointsize = 10,
dev.defined = FALSE, ylim = NA, col = NA, lty = 1, lwd = 1,
main = NA, main.line = 1.5, xlab = NA, ylab = NA,
legend.add = TRUE, legend.space = legend.add, legend.only = FALSE,
legend.pos = "center", legend.cex = 1, legend.width.factor = 1,
rug.ticksize = 0.02, rug.col = "black", vline.actual = TRUE,
pos.hlines = c(0, 0), n.effects = 100,
autosave.plot = FALSE, snapshot.plot = FALSE,
graphics.filename = "LinRegIntPlot", graphics.numbering = !autosave.plot,
graphics.type = "pdf", factor.sep = "|", level.sep = ".",
latex2console = FALSE, xtable.big.mark = ".", xtable.decimal.mark = ",",
xtable.digits = NULL, xtable.display = NULL, xtable.booktabs = FALSE,
panel.title = "Linear Mixed-Effects Model", label.button = "Snapshot",
label.slider.act = "Variable displayed: ", label.box.type = "Type",
label.types = c("effect", "marginal effect"),
label.box.groups = "Groups",
slider.width = 200, slider.height = 60, button.height = 30,
box.type.height = 75, box.group.character.width = 7,
box.group.line.height = 28, dist.obj.width = 20,
dist.obj.height = 10, ...)
No object is returned, please refer to the documentation of fxInteractive
or the vignette for more details.
Level of grouping to be displayed, passed to predict.lme
. Only one level can be displayed, default to 0
.
Initial values for the metric covariates in a named list, default to the means. See section 4 of the vignette and examples below.
Name of continuous variable to be displayed as character or NA
(default) for menu selection.
The type of the initial plot to be displayed. Must be one of the values "effect"
(default) or "marginal"
.
Numeric vector with the index of the groups which are displayed in the initial plot. If NULL
(the default) all groups are displayed.
Height of graphic device in cm, default to 18
.
Width of plot area in graphic device in cm, default to 18
.
Width of legend area in graphic device in cm, default to 8
.
Character pointsize of graphic device, default to 10
.
Graphic device predefined? Default to FALSE
, see section 6.3 of the vignette for usage.
With a numeric vector of length 2 the plot limits in y-direction can be set. If NA (the default) these are determined automatically.
Vector of color specifications to represent different groups. Passed to the line commands and the legend. Actual palette and consecutive sequence if NA
(default).
Vector of line type specifications to represent different groups. Passed to the line commands and the legend, default to solid lines.
Vector of line width specifications to represent different groups. Passed to the line commands and the legend, default to 1
.
Title for the plot, default to NA
.
Height for plot title in lines which is passed to title(), default to 1.5.
Label for the x-axis. Name of the selected covariate, if NA
(the default).
Label for the y-axis. Name of the selected plot type (see argument label.types
), if NA
(the default).
Should a legend be added to the plot? Default to TRUE
.
Should the space for the legend be reserved? Default to the value of legend.add
. Setting legend.add
to FALSE
and legend.space
to TRUE
plots white space instead of the legend. This can be useful when different plots are arranged in a document to ensure exact alignments and sizes, see section 6.2 of the vignette for details.
Should just the legend be plotted? Default to FALSE
. A plot with the legend alone can be useful when different plots are arranged in a document, see section 6.2 of the vignette for details.
Position of the legend as character, see legend
for details. Default to "center"
.
Relative size of legend text. Can be reduced if the model contains many groups. Default to 1
.
Factor by which the width of the legend is increased. Default to 1
. Increasing this can solve the problem that the legend annotations do not fit in the surrounding box when the plots are saved as PDF or EPS files, see section 5 of the vignette for details.
Length of rugplot tickmarks, dafault to 0.02
. Set to 0
or NA
, if no rugplot should be drawn. For many observations the rug considerably slows down the rebuild of the plot.
Color of rugplot tickmarks, default to "black"
.
Add vertical line at actual position of selected metric covariate? Default to TRUE
.
Positions of the horizontal lines for [1] the plot of the effects and [2] the plot of marginal effects. NA
for no lines, default to c(0,0)
.
Number of equally spaced points over the span of the selected metric covariate to calculate the effects for plotting, default to 100
. Increase, if lines are not smooth.
Directly save the initial plot? Default to FALSE
. If set to TRUE
the GUI-panel is immediately closed after initialization.
Save plot when snapshot button is pressed? Default to FALSE
, see section 5 of the vignette for details.
Filename (optionally including a path) as character for graphic file.
If TRUE
(the default) a 3 digits number is automatically appended to the filenname to avoid that existing graphic files are overwritten.
Graphics file type argument, default to "pdf"
. On Windows systems all file types accepted by savePlot
work. Under non Windows systems allowed values are "pdf"
, "eps"
, "png"
, "jpeg"
, "jpg"
, "tiff"
and "bmp"
.
Character separating the factor-factor level combinations in the group names (default to "|"
).
Character separating the factor name and the corresponding factor levels in the group names (default to "."
).
Should the textoutput triggered by the snapshot button be printed as LaTeX-code? Default to FALSE
.
Bigmark character for LaTeX output passed to print.xtable
, default to ","
.
Decimal character for LaTeX output passed to print.xtable
, default to "."
.
Number of digits for LaTeX output passed to xtable
, default to NULL
.
Display style for LaTeX output passed to xtable
, default to NULL
.
Use the LaTeX package booktabs
for horizontal lines in LaTeX tables, default to FALSE
. Passed to print.xtable
.
Title used in the title bar of the GUI-panel of type character
.
Label for the snapshot-button of type character
.
Additional label for the slider of the selected metric covariate of type character
.
Title for the radiogroup box of type character
.
Labels for radiogroup buttons (character
vector of length 2). By default these are also used as corresponding annotations for the y-axis.
Title for the checkbox of type character
.
Width of each slider in points (default to 200
).
Height of each slider in points (default to 60
).
Height of snapshot button in points (default to 30
).
Height of radiobox for type selection in points (default to 90
).
The width of the boxes is basically a this value times the number of characters in points (default to 7
).
The height of the checkbox is this value times the number of groups in points (default to 28
).
Vertical distance between sliders and boxes and vertical margins in points (default to 20
).
Horizontal distance between panel objects in points (default to 10
).
Other graphical parameters passed to par
.
Martin Meermeyer m.meermeyer@gmail.com
The only mandatory argument of the function is a fitted-model object of class lme
(package nlme). For this object the following prerequisites must be met:
The model must contain at least one metric covariate.
The model must be specified with the formula interface and the data frame containing the variables must be passed with the data
argument.
The categorical variables must be factor
s (ordered or unordered).
In this method the additional argument predict.lme.level
is responsible for the level of grouping to be displayed, see the documentation of predict.lme
.
Please refer to the documentation of fxInteractive
or the vignette for more details.
The examples in fxInteractive.glm
and fxInteractive.lm
are more elaborated and show different aspects of usage and customization which are valid for this method, too.
require("nlme")
data("Orthodont")
LMEmod <- lme(distance ~ age + Sex, data = Orthodont, random = ~ age | Subject)
if (FALSE) {
## RStudio users may need to change the graphic device, see details.
options(device = "x11")
## Grouping level 0 is used by default.
fxInteractive(LMEmod, legend.cex=0.6)
## Display grouping level 1
fxInteractive(LMEmod, predict.lme.level=1, legend.cex=0.6)
## For individual specific factors only observable factor combinations are meaningful
# the grouping variable must be the last column
combs.count <- factorCombinations(Orthodont[,c(4,3)])$counts
combs.observed <- combs.count > 0
fxInteractive(LMEmod, predict.lme.level=1, preselect.groups=combs.observed)
}
Run the code above in your browser using DataLab