Learn R Programming

R2MLwiN (version 0.1-2)

predLines1: Draws predicted lines using model estimates

Description

This function draws predicted lines against an explanatory variable for selected groups at a higher level.

Usage

predLines1(indata, FP, resi, xname, lev = 2, levID, selected = NULL, Legend=T)

Arguments

indata
A data.frame object containing the data modelled.
FP
A vector of the fixed part estimates.
resi
The name of the file where the estimates of residuals are saved.
xname
A name of an explanatory variable.
lev
A digit indicating the level (of the multilevel model) at which to plot.
levID
A character (vector) specifying the level ID(s).
selected
A vector representing a group of selected members at a level. If selected=NULL, then all members at the level are included.
Legend
A logical value indicating whether a legend is to be added.

See Also

predLines2

Examples

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


## Example: Normal
formula="normexam~(0|cons+standlrt)+(2|cons+standlrt)+(1|cons)"
levID=c('school','student')
estoptions= list(EstM=0,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)

resi=mymodel["residual"]
FP=mymodel["FP"]
predLines1(indata,FP,resi=resi,xname="standlrt", lev=2, levID, selected=c(30,44,53,59))

Run the code above in your browser using DataLab