Learn R Programming

R2MLwiN (version 0.1-7)

caterpillarR: Draws caterpillar plots of the residuals at a particular level of a multilevel model.

Description

Uses qqmath in the `lattice' package to draw Quantile-Quantile plots of the residuals at a particular level of a multilevel model against a theoretical distribution.

Usage

## S3 method for class `numeric'
caterpillarR(resi, lev = 2)

Arguments

resi
Either a character string indicating where the residuals are stored or a data.frame object containing the residuals.
lev
A digit name indicating which level of a multilevel model residuals are to be plotted for.

Value

  • A caterpillar plot of the residuals at the requested level of the random part of a multilevel model.

See Also

qqmath

Examples

Run this code
library(R2MLwiN)
## Modify the following paths as appropriate.
## MLwiN folder
mlwin = "C:/Program Files (x86)/MLwiN v2.27/"
## MLwiN sample worksheet folder
wspath=paste(mlwin,"/samples/",sep="")

## Example: Normal
formula="normexam~(0|cons)+(2|cons)+(1|cons)"
levID=c('school','student')
estoptions= list(resi.store=TRUE)
wsfile=paste(wspath,"tutorial.ws",sep="")
inputfile=paste(tempdir(),"/tutorial.dta",sep="")
ws2foreign(wsfile, foreignfile=inputfile, MLwiNPath=mlwin)
library(foreign);indata =read.dta(inputfile)
mymodel=runMLwiN(formula, levID, D="Normal", indata, estoptions,MLwiNPath=mlwin)

## Caterpillar plot
caterpillarR(mymodel["residual"], lev=2)

Run the code above in your browser using DataLab