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.

R2MLwiN is available from CRAN (see installation instructions below), although to use it you will also need to obtain and install MLwiN (see the MLwiN webpage for details of how to do so).


27 June 2017: The latest version of R2MLwiN (0.8-4) has been released on CRAN.

This includes the following new features (and also note bug fixes):

08 Sep 2016: The R2MLwiN paper is now available

If you wish to cite the article (available here), please do so as:

07 Sep 2016: The latest version of R2MLwiN (0.8-3) has been released on CRAN.

This includes the following new features (and also note bug fixes):

(For older news items, see the news archive).


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.

As R2MLwiN depends on a number of third party packages we suggest that before installing the package you run the command:

update.packages(repos = "http://cran.r-project.org")

to ensure that any you already have installed are up to date.

You can then install the package from CRAN with the following command:

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

Alternatively a less tested development version, which will contain the most recent changes and bug fixes, can be installed with the following commands:


install_github("rforge/r2mlwin", subdir="R2MLwiN")

To then load it, type:


Documentation and Examples

Journal article

An article describing R2MLwiN is available here. If you wish to cite the article, please do so as:

Help files

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")

The main command for calling MLwiN from R is called runMLwiN, and details of the syntax and options for this can be found with:

help(runMLwiN, package="R2MLwiN")


R2MLwiN also comes with a range of demos; these replicate all the analyses reported in the (IGLS) User's Guide to MLwiN and 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", "MCMCGuide03.R", package = "R2MLwiN"))

Finally, to run that demo, enter the following:


These demos and their outputs can also be viewed on the Examples page.


Please cite R2MLwiN as follows:

We are happy to list all publications that cite R2MLwiN on this web site. More >>


We gave a presentation on R2MLwiN at the 10th International Multilevel Conference in Utrecht (9th-10th April 2015). There's a pdf file below (converted from a Powerpoint file, with animations split courtesy of PPspliT):

Slides (PDF, 4.0mb)

User forum

Please use the R2MLwiN user forum to post any questions or feedback you have regarding R2MLwiN.


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.