R2MLwiN: Running MLwiN from within R

R2MLwiN is an R command interface to the MLwiN multilevel modelling software package, allowing users to fit multilevel models using MLwiN from within the R environment. It is designed to be used with versions of MLwiN from v2.25 onwards, although some features will work with earlier versions.


There is a known bug in the current version of R2MLwiN, which means users cannot successfully re-fit non-Normal models, with missing values, in debugmode (see known bugs page for interim workaround, as well as details of some recently fixed bugs).


Both MLwiN and R are required to use R2MLwiN. MLwiN is free to UK academics. A fully functional 30-day free version of MLwiN is available to all other users.

R2MLwiN is available on CRAN, and so can be installed by typing the following at the R command line:

install.packages("R2MLwiN", repos = "http://cran.r-project.org")

To then load it, type:


Documentation and Examples

As with all packages on CRAN, R2MLwiN comes with a number of help files; to see a list of the documentation available, type the following at the R command line:

help(package = "R2MLwiN")

R2MLwiN also comes with a range of demos; these replicate all the analyses reported in the MLwiN MCMC Manual. To see a list of these, type:

demo(package = "R2MLwiN")

To view the script of a specific demo (in this example the code replicating the analyses in Chapter 3 of the MLwiN MCMC Manual) type:

file.show(system.file("demo", "Chapter03.R", package = "R2MLwiN"))

Finally, to run that demo, enter the following:



Please cite R2MLwiN if you use it in your work. We are happy to list all publications that cite R2MLwiN on this web site. MoreĀ >>


We are very grateful to colleagues at the Centre for Multilevel Modelling and the University of Bristol for their useful comments. This work is funded under the e-STAT node (Grant: RES-149-25-1084) as part of the ESRC Digital Social Research programme.