mem.plotresid: Plot residuals of a mixed-effects model along with trend...

Description Usage Arguments Details Author(s) See Also Examples

View source: R/memtools.R

Description

This function plots stylized residuals of a mixed-effects model. It is possible to obtain fitted values versus errors (XbZu vs e), or original values versus errors (y vs e) in order to obtain different views to the errors in connection to the observations.

Usage

1
mem.plotresid(fit, linear = T, type = "XbZu", main, xlab, ylab)

Arguments

fit

A fitted mixed-effects model generated either through the lme4 or the nlme package.

linear

Should linear trend lines be drawn to the residual plot

type

Type of residual plot; should fitted values (value "XbZu") or original observations (value "y") be plotted against "e" errors

main

Main title

xlab

x-axis label

ylab

y-axis label

Details

Notice that the typical residual plot is fitted values (type="XbZu") versus errors ("e").

Author(s)

Teemu Daniel Laajala <teelaa@utu.fi>

See Also

mem.getcomp, mem.plotran

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
data(vcaplong)

exdat <- vcaplong[vcaplong[,"Group"] %in% c("Vehicle", "ARN"),]

library(lme4)
f0 <- lmer(log2PSA ~ 1 + DrugWeek + (1 + DrugWeek|ID), data = exdat)
f1 <- lmer(log2PSA ~ 1 + DrugWeek + DrugWeek:ARN + (1 + DrugWeek|ID), data = exdat)
f2 <- lmer(log2PSA ~ 1 + DrugWeek + DrugWeek:ARN + (1|ID) + (0 + DrugWeek|ID), data = exdat)
f3 <- lmer(log2PSA ~ 1 + DrugWeek + DrugWeek:ARN + (1|Submatch) + (0 + DrugWeek|ID), data = exdat)

par(mfrow=c(2,2))
mem.plotresid(f0)
mem.plotresid(f1)
mem.plotresid(f2)
mem.plotresid(f3)

hamlet documentation built on May 1, 2019, 8:40 p.m.