Plot partial effects of a (generalized) linear mixed-effects model fit with
lmer
(compatible with package lme4
version > 1.0).
plotLMER.fnc(model, xlabel = NA, xlabs = NA, ylabel = NA,
ylimit = NA, ilabel = NA, fun = NA, pred = NA, control = NA,
ranefs = NA, n = 100, intr = NA,lockYlim = TRUE, addlines = FALSE,
withList = FALSE, cexsize = 0.5, linecolor = 1,
addToExistingPlot = FALSE, verbose = TRUE, ...)
a mer
model object
label for X-axis (if other than the variable name in the original model formula)
character vector with labels for X-axes in multipanel plot (if
other than the variable names in the original model formula); if used,
xlabel
should not be specified
label for Y-axis (if other than the variable name of the dependent variable in the original model formula)
range for vertical axis; if not specified, this range will be chosen such that all data points across all subplots, including HPD intervals, will be accommodated
label for the interaction shown in the lower right-hand margin of the plot, overriding the original variable name in the model formula
a function to be applied for transforming the dependent variable,
if NA
, no transformation is applied; for models with family = "binomial"
,
fun is set to plogis
by default; this can be disabled by setting
fun=function(x)return(x)
.
character string with name of predictor; if specified, a single plot will produced for the partial effect of this specific predictor
a two-element list list(predictor, val)
specifying a predictor
the value of which has to be set to val
in the partial effect plot(s); the predictor name should be exactly as specified in names(model@fixef)
. It is up to the user to make sure that name and value make sense, the code here hands full 'control' to the user.
a four-element list Group, Level, Predictor
, specifying a random-effect Group (e.g. Subject
), a level (e.g., S10
) and a value (e.g., LogFrequency
) for which partial effects have to be calibrated.
integer denoting number of points for the plot, chosen at equally spaced intervals across the empirical range of the predictor variable
a list specifying an interaction to be graphed; obligatory arguments are (1) the name of the interaction variable, followed by (2) a vector of values for that variable, followed by (3) the position for interaction labels ('"beg"', '"mid"', or '"end"', or 'NA' if no labels are desired), optionally followed by (4) a list with as first element a vector of colors and as second element a vector of line types. The number of elements in both vectors should match the number of values specified under (2) for the interaction predictor.
logical specifying whether all subplots should have the same
range of values for the vertical axis; if TRUE
, this range will be
chosen to accomodate all fitted values including HDP intervals for all
predictors across all plots
if TRUE, adds line(s) between levels of same factor(s)
logical, if TRUE
, a list will be output with all data
frames for the subplots
character expansion size (cex) for additional information in the plot for interactions
color of lines in the plot, by default set to 1 (black)
default FALSE, if set to TRUE, plot will be added to previous plot, but only if pred is specified
if TRUE (default), effect sizes and default transformations are reported
further graphical parameters to be passed down; warning: col
,
pch
, lty
and cex
will often generate an error as they are
internally already fully specified for specialized subplots
A plot is produced on the graphical device.
When no predictor is specified, a series of plots is produced for the partial effects of each predictor. The graphs are shown for the reference level for factors and are adjusted for the median value for the other numerical predicors in the model. Interactions are not shown. The user should set up the appropriate number of subplots on the graphics device before running plotLMER.fnc().
Instead of showing all predictors jointly, plotLMER.fnc() can also be used to
plot the partial effect of a specific predictor. When a specific predictor
is specified (with pred = ...
), a single plot is produced for that
predictor. In this case, the intr
argument can be used to specify a
single second predictor that enters into an interaction with the selected
main predictor.
Polynomials have to be fitted with poly(..., degree, raw=TRUE)
and
restricted cubic splines with rcs()
from the rms
package.
Note that any MCMC capabilities available in the languageR
version of this function are not available in this version.
# NOT RUN {
# see example in LMERConvenienceFunctions help page.
# }
Run the code above in your browser using DataCamp Workspace