- Latest updates
- Short video introduction
- Helpfile examples
- Installing and updating mrrobust
- Code testing
- How to cite the mrrobust package
- January 2020:
mreggernow additionally returns
- Certification scripts: added
master.doand renamed and edited a few scripts.
mrcommand. Commands may now be run as either
mr egger ...or as previously
- Best of IJE 2019! https://academic.oup.com/ije/pages/the_best_of_ije
mrrationow additionally return the
r(table)matrix (the information from the coefficient table).
- Added an example showing how you can save and export your estimates using
r(table), see here.
- December 2019:
Q_GXto ereturn and display output when
gxse()option specified to
I^2_GXoutput to use first order weights in
mreggeroutput. This matches the output from the
mr_egger()function in the
MendelianRandomizationR package. Use the
unwi2gxoption to report the unweighted statistics.
- July 2019:
- Checked that examples on website still run.
- December 2018:
- November 2018:
- September 2018:
- IJE paper published online https://doi.org/10.1093/ije/dyy195.
- August 2018:
- May 2018:
- Click here for code and output from the examples in the helpfiles.
- This page is now rendered on GitHub Pages https://remlapmot.github.io/mrrobust/.
- April 2018:
mreggernow has option
radialwhich implements the radial formulation of the MR-Egger model, and of the IVW model when used with option
Short video introduction
Once the package is installed, there is a summary helpfile which can be viewed in Stata with:
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 http://www.mrbase.org (Hemani et al. 2016).
The package contains the following commands:
mrdepsinstalls dependencies for the package.
mrratioimplements the standard instrumental variable ratio (Wald) estimate with a choice of standard errors/confidence intervals.
mrratioon all the selected genotypes in your dataset.
mreggerimplements the IVW and MR-Egger regression approaches introduced in Bowden et al. 2015.
mreggersimeximplements the simulation extrapolation algorithm for the MR-Egger model.
mreggerplotimplements a scatter plot with fitted line (either from IVW, MR-Egger, or weighted median estimators) and confidence interval.
mrmedianobsimplement the unweighted, weighted, and penalized weighted median IV estimators robust to 50% invalid instruments in Bowden et al. 2016.
mrmodalimplements the zero modal estimator of Hartwig et al. 2017.
mrmodalplotplot of density used in modal estimator.
mrforestimplements a forest plot of genotype specific IV estimates and estimates from models (e.g. IVW and MR-Egger).
mrfunnelfunnel plot of genotype specific IV estimates.
mracts as a primary command, e.g. so the other commands can be run as
mr egger ...as well as
Installing and updating mrrobust
To install mrrobust in Stata versions 13 and later you have two choices.
net install mrrobust, from(https://raw.github.com/remlapmot/mrrobust/master/) replace mrdeps
In this code
mrdeps installs the dependencies. These are
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
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
net install github, from("https://haghish.github.io/github/") 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
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:
- click the green “Clone or download” button at the top of the GitHub repository here and download as a zip archive.
- On your computer, extract the zip archive and move the extracted files to your
adopathin Stata shows you the folders where the Stata programs, ado-files, are saved. Save the mrrobust files in the folder marked PERSONAL. If the folder Stata is pointing to does not exist simply make it, e.g. using Windows Explorer.
The installation commands for the other dependencies should work. However, if you want to install them manually:
morematapackage is available as a zip file here http://fmwww.bc.edu/repec/bocode/m/moremata.zip.
addplotpackage is available here http://fmwww.bc.edu/repec/bocode/a/addplot.zip.
heterogicommand is available here https://ideas.repec.org/c/boc/bocode/s449201.html.
kdenspackage is available here http://fmwww.bc.edu/repec/bocode/k/kdens.zip.
metancommand is available here https://ideas.repec.org/c/boc/bocode/s456798.html.
grc1legado-file is here http://www.stata.com/users/vwiggins/grc1leg/grc1leg.ado and the helpfile is here http://www.stata.com/users/vwiggins/grc1leg/grc1leg.hlp
Extract the zip archives and save all files on your
To uninstall a manual installation simply delete the files that you placed on your adopath.
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 firstname.lastname@example.org, 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. https://doi.org/10.1093/ije/dyy195
Thank you to all our users who have cited mrrobust. We made The Best of IJE 2019! https://academic.oup.com/ije/pages/the_best_of_ije
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.
- Bowden J, Davey Smith G, Burgess S. Mendelian randomization with invalid instruments: effect estimation and bias detection through Egger regression. International Journal of Epidemiology, 2015, 44, 2, 512-525. http://dx.doi.org/10.1093/ije/dyv080
- Bowden J, Davey Smith G, Haycock PC, Burgess S. Consistent estimation in Mendelian randomization with some invalid instruments using a weighted median estimator. Genetic Epidemiology, published online 7 April 2016. http://dx.doi.org/10.1002/gepi.21965
- Hartwig FP, Davey Smith G, Bowden J. Robust inference in two-sample Mendelian randomisation via the zero modal pleiotropy assumption. bioRxiv. http://dx.doi.org/10.1101/126102
- Hemani G et al. MR-Base: a platform for systematic causal inference across the phenome using billions of genetic associations. bioRxiv, 2016. https://doi.org/10.1101/078972
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, and Steve Burgess.