if (FALSE) {
library(R2MLwiN)
# NOTE: if MLwiN not saved where R2MLwiN defaults to:
# options(MLwiN_path = 'path/to/MLwiN vX.XX/')
# If using R2MLwiN via WINE, the path may look like:
# options(MLwiN_path = '/home/USERNAME/.wine/drive_c/Program Files (x86)/MLwiN vX.XX/')
# Example using tutorial dataset
data(tutorial, package = 'R2MLwiN')
(mymodel <- runMLwiN(normexam ~ 1 + (1 | school) + (1 | student),
estoptions = list(resi.store = TRUE),
data = tutorial))
# For each school, calculate the CIs...
residuals <- mymodel@residual$lev_2_resi_est_Intercept
residualsCI <- 1.96 * sqrt(mymodel@residual$lev_2_resi_var_Intercept)
residualsRank <- rank(residuals)
rankno <- order(residualsRank)
caterpillar(y = residuals[rankno], x = 1:65, qtlow = (residuals - residualsCI)[rankno],
qtup = (residuals + residualsCI)[rankno], xlab = 'Rank', ylab = 'Intercept')
}
Run the code above in your browser using DataLab