mrrobust: Stata package for two-sample Mendelian randomization analyses

Latest updates

To obtain the latest update please see instructions below.

Short video introduction

Click here for a short video demonstrating the use of the package.

Helpfile examples

Click here for some of the code and output from the examples in the helpfiles.

Once the package is installed, there is a summary helpfile which can be viewed in Stata with:

help mrrobust

This has links to the helpfile for each command, which has an example near the bottom. In these examples you can click on the code to run it.


The mrrobust package is a collection of commands for performing two-sample Mendelian randomization analyses using summary data of genotype-phenotype and genotype-outcome associations.

Such data can be obtained from repositories such as MR-Base (Hemani et al. 2016).

The package contains the following commands:

Installing and updating mrrobust

To install mrrobust in Stata versions 13 and later you have two choices.

1. Use net install

net install mrrobust, from("") replace

In this code mrdeps installs the dependencies. These are addplot, kdens, and moremata packages (all by Ben Jann), the heterogi command (Orsini et al.), the metan command (Harris et al.), and the grc1leg command (Wiggins).

If you have previously installed the package and the net install command above fails with an error message that there are two copies of the package installed simply run adoupdate.

To check if there is an update available to any of your user-written Stata packages run adoupdate. To update mrrobust run:

adoupdate mrrobust, update

To uninstall mrrobust, issue in Stata:

ado uninstall mrrobust

If this fails with an error message mentioning that you have “multiple citations/instances of the package installed” simply issue adoupdate mrrobust which should leave you with the most recent version of the package you previously installed. You can then run ado uninstall mrrobust.

2. Use the github package

net install github, from("")
gitget mrrobust

This automatically installs the dependencies.

To update the package issue:

github update mrrobust

To uninstall mrrobust issue:

github uninstall mrrobust

Installation for Stata version 12 and earlier versions (and perhaps Stata version 13)

The net install syntax for installing mrrobust does not work under Stata version 12 and earlier because this webpage has an address starting with https rather than http. In such cases you need to do a manual installation.

To download and install mrrobust manually:

The installation commands for the other dependencies should work. However, if you need to install them manually their zip archives are available at the following links (extract the files from the downloaded zip archives and place them in your PERSONAL directory on your adopath):

Code testing

As far as I know, and unlike R which has the testthat package, there is no recognised standard for writing unit tests for Stata commands. However, StataCorp refer to such do-files as cscripts (certification scripts). If you are interested I publish my cscripts (and their log files of output) in the cscripts directory in the GitHub repository.


Tom Palmer, Wesley Spiller, Neil Davies

How to cite the mrrobust package

Spiller W, Davies NM, Palmer TM. Software Application Profile: mrrobust - A tool for performing two-sample summary Mendelian randomization analyses. International Journal of Epidemiology, 2019, 48, 3, 684-690.

Thank you to all our users who have cited mrrobust. We made The Best of IJE 2019!


If you would like to extend the code or add new commands I am open to receiving pull requests on GitHub or send me an email to



Thanks for helpful feedback and suggestions to (in no particular order): Jasmine Khouja, Michael Holmes, Caroline Dale, Amy Taylor, Rebecca Richmond, Judith Brand, Yanchun Bao, Kawthar Al-Dabhani, Michalis Katsoulis, Ghazaleh Fatemifar, Lai-Te Chen, Sean Harrison, Emma Anderson, Cassianne Robinson-Cohen, Alisa Kjaergaard, and Steve Burgess.