Learn R Programming

R2MLwiN (version 0.1-7)

trajectories: Plots MCMC chain trajectories

Description

This function draws trajectories of MCMC chains.

Usage

trajectories(chains, Range = c(1, 5000), selected = NULL)

Arguments

chains
A data frame of parameter chains from MLwiN.
Range
An integer vector of length two specifying the first and last iterations of the chains.
selected
A character vector specifying the selected chains to be plotted.

See Also

sixway

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+standlrt)+(2|cons+standlrt)+(1|cons)"
levID=c('school','student')
estoptions= list(EstM=1)
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)

trajectories(mymodel["chains"],Range=c(4501,5000))

Run the code above in your browser using DataLab