Mrrobust
Stata package for two-sample Mendelian randomization analyses using summary data
Install / Use
/learn @remlapmot/MrrobustREADME
mrrobust: Stata package for two-sample Mendelian randomization analyses
- Latest updates
- Short video introduction
- Helpfile examples
- Overview
- Installing and updating mrrobust
- Unit tests
- Authors
- How to cite the mrrobust package
- References
- Collaboration
- Acknowledgements
Latest updates
To obtain the latest update please see the instructions below.
- September 2025:
- Reran certification scripts on StataNow 19.5
- May 2025:
- Reran certification scripts (a.k.a. tests) on StataNow 18.5
- July 2024:
- Updated website to mention OpenGWAS instead of MR-Base
- In Stata 18 on a
graph twowayplot the default legend position appears to have changed from the 6 o'clock to the 3 o'clock position. Amendments have been made tomreggerplot,mrfunnel, andmrmodalplotto use the 6 o'clock position as the default again.
- January 2024:
- Reran certification scripts under Stata 18.0
- August 2023:
- Added a record of the Stata version in the certification scripts
- April 2023:
- Improved the alt text descriptions for the images in the README and package website, and also centred the images
- Remade the mrrobust website using Quarto
- Updated the Sanderson et al., bioRxiv, 2020, doi reference to its published version Sanderson et al., Statistics in Medicine, 2021, doi
- Reran certification scripts under latest Stata 17.0
- February 2023:
- Updated R Markdown example to use the CRAN version of the Statamarkdown package
- September 2022:
- Updated manual installation instructions
- February 2022:
- Ran cscripts under Stata 17.0
- Updated website examples to run under Stata 17.0
- September 2021:
- Changed relevant
http:URLs tohttps: - Minor edits to the helpfiles
- Changed relevant
- June 2021:
- Published an interactive Code Ocean capsule demonstrating the use of the mrrobust package here
- By default
mrforestnow specifies a fixed effect standard error for its IVW estimate
- April 2021:
- Added the I-squared statistic and its 95% CI to the
mregger ..., heterogioutput
- Added the I-squared statistic and its 95% CI to the
- February 2021:
- Fixes to
mrforestandmrleaveoneoutrelated to the recent update tometan.mrforestandmrleaveoneoutnow usemetan9instead ofmetanbecause of the changes tometansyntax. No change was necessary in the dependency scripts becausemetan9is also installed withssc install metan - Checked cscripts pass
- Checked examples on website run. And changed the 2 examples which use the TwoSampleMR R package to use the new ID code for the exposure data
- Updated
dependency.doto make it more robust to the more frequent updates tometan - Updated
mrdepsto make it more robust to the more frequent updates tometan
- Fixes to
- October 2020:
dependency.doandmrdepsnow install the updated version of themorematapackage- Checked the cscripts run under Stata 16.1
- Added description of Q-statistic as Cochran's and Ruecker's for the IVW and MR-Egger models respectively
- In various helpfiles added clarification that genotype-disease stands for SNP-outcome (or indeed instrument-outcome) and that genotype-phenotype stands for SNP-exposure (or indeed instrument-exposure) respectively; i.e. the estimates required for the top and bottom of the IV Wald ratio estimate
- August 2020:
- Added html versions of the helpfiles to the website. These are available from the Helpfiles website menu bar item
- Added extra decimal places examples to helpfiles of
mrforestandmrleaveoneout mrfunnelnow includes a legend on its plot
- July 2020:
- Added
gxse()option tomrmvivwto return instrument strength Q<sub>A</sub> statistic for instrument validity ine(Qa)(Sanderson et al. 2019) - The
gxse()option additionally returns the Q<sub>x</sub> and conditional F-statistics for each phenotype for instrument strength ine(Qx)ande(Fx)(Sanderson et al. 2020) - Added
tdistoption tomrmvivwandmrmvegger mrmvivwandmrmveggernow ereturn the RMSE ine(phi)mregger, ivwnow displays the square root of the residual variance (residual standard error) and ereturns this ise(phi)- Checked that examples on website still run
- Added
mrleaveoneoutcommand to perform leave one out analysis
- Added
- June 2020:
- Simplified the outcome variable name in
mreggerbandVe-returned matrices. Turn this off with newoldnamesoption - Added basic multivariable MR-Egger command,
mrmvegger - Added basic multivariable IVW command,
mrmvivw(currently command namesmvmrandmvivwalso work)
- Simplified the outcome variable name in
- February 2020:
- Updated contact details
- Minor edits to helpfiles, to show examples setting
seed()option where helpful - Fixed
mreggerbug wherer(table)was not returned with thegxseorheterogioptions. The output for these options now appears before the coefficient table. - Minor amendments to formatting of
mreggergxseoutput mreggernow ereturnse(phi), the scale parameter, in some cases
- January 2020:
mreggernow additionally returnsr(table)- Certification scripts: added
master.doand renamed and edited a few scripts - Added
mrcommand. Commands may now be run as eithermr egger ...or as previouslymregger .... - Best of IJE 2019!
mrmedian,mrmedianobs,mreggersimex,mrmodal, andmrrationow additionally return ther(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:
- Added
Q_GXto ereturn and display output whengxse()option specified tomregger - Changed
Q_GXandI^2_GXoutput to use first order weights inmreggeroutput. This matches the output from themr_egger()function in the MendelianRandomization R package. Use theunwi2gxoption to report the unweighted statistics.
- Added
- July 2019:
- Checked that examples on website still run
- December 2018:
- Improved compatibility with the github Stata package,
i.e., mrrobust and its dependencies can be installed simply by issuing:
gitget mrrobust, if you have the github package installed. See below for instructions. mrdepscommand added for conveniently installing dependencies
- Improved compatibility with the github Stata package,
i.e., mrrobust and its dependencies can be installed simply by issuing:
- November 2018:
- Example showing the use of the TwoSampleMR R package and mrrobust in the same
R Markdown script (
.Rmdfile) is here - Example showing the use of the TwoSampleMR R package and mrrobust in the same
Stata Markdown script (
.stmdfile) is here
- Example showing the use of the TwoSampleMR R package and mrrobust in the same
R Markdown script (
- September 2018:
- IJE paper published online here
- August 2018:
- Click here for the example code and output from our IJE article
- May 2018:
- April 2018:
mreggernow has optionradialwhich implements the radial formulation of the MR-Egger model, and of the IVW model when used with optionivw
Short video introduction
Click here for a short video demonstrating the use of the package.
<p align="center"><a href="https://drive.google.com/open?id=0B1owQlNgzNcPY0lMSGk0SnFfQWs"><img src="./img/mrconf2017_video_mrforest_screenshot.png" width="528" height="300" alt="A screenshot of a video demonstrating the use of the mrrobust package."></a></p>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.
Overview
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 https://www.mrbase.org (Hemani et al. 2016).
The package contains the following commands:
mrdepsinstalls dependencies for the packagemrratioimplements the standard instrumental variable ratio (Wald) estimate with a choice of standard errors/confidence intervalsmrivestsautomates callingmrratioon all the selected genotypes in your datasetmreggerimplements the IVW and MR-Egger regression approaches introduced in Bowden et al. (2015)mreggersimeximplements the simulatio
