{"id":28473370,"url":"https://github.com/remlapmot/mrrobust","last_synced_at":"2026-01-30T03:46:34.504Z","repository":{"id":44661027,"uuid":"60366663","full_name":"remlapmot/mrrobust","owner":"remlapmot","description":"Stata package for two-sample Mendelian randomization analyses using summary data","archived":false,"fork":false,"pushed_at":"2025-06-15T04:37:07.000Z","size":8258,"stargazers_count":24,"open_issues_count":0,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-15T05:37:18.073Z","etag":null,"topics":["iv","mendelian-randomisation","mendelian-randomization","mendelianrandomisation","mendelianrandomization","mr","mr-egger","stata","two-sample"],"latest_commit_sha":null,"homepage":"https://remlapmot.github.io/mrrobust/","language":"Stata","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/remlapmot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-06-03T17:45:19.000Z","updated_at":"2025-06-15T04:37:11.000Z","dependencies_parsed_at":"2023-02-07T10:15:27.775Z","dependency_job_id":"f7755ece-e292-4d9a-972f-b390d6d03391","html_url":"https://github.com/remlapmot/mrrobust","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/remlapmot/mrrobust","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remlapmot%2Fmrrobust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remlapmot%2Fmrrobust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remlapmot%2Fmrrobust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remlapmot%2Fmrrobust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remlapmot","download_url":"https://codeload.github.com/remlapmot/mrrobust/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remlapmot%2Fmrrobust/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263063865,"owners_count":23407999,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["iv","mendelian-randomisation","mendelian-randomization","mendelianrandomisation","mendelianrandomization","mr","mr-egger","stata","two-sample"],"created_at":"2025-06-07T12:07:05.543Z","updated_at":"2026-01-30T03:46:34.497Z","avatar_url":"https://github.com/remlapmot.png","language":"Stata","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mrrobust: Stata package for two-sample Mendelian randomization analyses\n\n* [Latest updates](#latest-updates)\n* [Short video introduction](#short-video-introduction)\n* [Helpfile examples](#helpfile-examples)\n* [Overview](#overview)\n* [Installing and updating mrrobust](#installing-and-updating-mrrobust)\n* [Unit tests](#unit-tests)\n* [Authors](#authors)\n* [How to cite the mrrobust package](#how-to-cite-the-mrrobust-package)\n* [References](#references)\n* [Collaboration](#collaboration)\n* [Acknowledgements](#acknowledgements)\n\n## Latest updates\n\nTo obtain the latest update please see the instructions [below](#installing-and-updating-mrrobust).\n\n* September 2025:\n  - Reran certification scripts on StataNow 19.5\n* May 2025:\n  - Reran certification scripts (a.k.a. tests) on StataNow 18.5\n* July 2024:\n  - Updated website to mention [OpenGWAS](https://api.opengwas.io/) instead of MR-Base\n  - In Stata 18 on a `graph twoway` plot the default legend position appears to have changed from the 6 o'clock to the 3 o'clock position. Amendments have been made to `mreggerplot`, `mrfunnel`, and `mrmodalplot` to use the 6 o'clock position as the default again.\n* January 2024:\n  - Reran certification scripts under Stata 18.0\n* August 2023:\n  - Added a record of the Stata version in the certification scripts\n* April 2023:\n  - Improved the alt text descriptions for the images in the *README* and package website, and also centred the images\n  - Remade the **mrrobust** website using [**Quarto**](https://quarto.org/)\n  - Updated the Sanderson et al., bioRxiv, 2020, [doi](https://doi.org/10.1101/2020.04.02.021980) reference to its published version Sanderson et al., Statistics in Medicine, 2021, [doi](https://doi.org/10.1002/sim.9133)\n  - Reran certification scripts under latest Stata 17.0\n* February 2023:\n  - Updated R Markdown example to use the CRAN version of the [**Statamarkdown**](https://cran.r-project.org/package=Statamarkdown) package\n* September 2022:\n  - Updated manual installation instructions\n* February 2022:\n  - Ran cscripts under Stata 17.0\n  - Updated website examples to run under Stata 17.0\n* September 2021:\n  - Changed relevant `http:` URLs to `https:`\n  - Minor edits to the helpfiles\n* June 2021:\n  - Published an interactive Code Ocean capsule demonstrating the use of the **mrrobust** package \n  [here](https://doi.org/10.24433/CO.0587524.v1)\n  - By default `mrforest` now specifies a fixed effect standard error for its IVW estimate \n* April 2021:\n  - Added the I-squared statistic and its 95% CI to the `mregger ..., heterogi` output\n* February 2021:\n  - Fixes to `mrforest` and `mrleaveoneout` related to the recent update to `metan`. \n  `mrforest` and `mrleaveoneout` now use `metan9` instead of `metan` because of the changes to \n  `metan` syntax. No change was necessary in the dependency scripts because `metan9` is also \n  installed with `ssc install metan`\n  - Checked cscripts pass\n  - Checked examples on website run. And changed the 2 examples which use the **TwoSampleMR** R\n  package to use the new ID code for the exposure data\n  - Updated `dependency.do` to make it more robust to the more frequent updates to `metan`\n  - Updated `mrdeps` to make it more robust to the more frequent updates to `metan`\n* October 2020:\n  - `dependency.do` and `mrdeps` now install the updated version of the `moremata` package\n  - Checked the cscripts run under Stata 16.1\n  - Added description of Q-statistic as Cochran's and Ruecker's for the IVW and MR-Egger models \n  respectively\n  - In various helpfiles added clarification that genotype-disease stands for SNP-outcome \n  (or indeed instrument-outcome) and that genotype-phenotype stands for SNP-exposure (or indeed \n  instrument-exposure) respectively; i.e. the estimates required for the top and bottom of the IV \n  Wald ratio estimate\n* August 2020:\n  - Added html versions of the helpfiles to the website. These are available from the *Helpfiles* website \n  menu bar item\n  - Added extra decimal places examples to helpfiles of `mrforest` and `mrleaveoneout`\n  - `mrfunnel` now includes a legend on its plot\n* July 2020:\n  - Added `gxse()` option to `mrmvivw` to return instrument strength Q\u003csub\u003eA\u003c/sub\u003e statistic for \n  instrument validity in `e(Qa)` ([Sanderson et al. 2019](#references))\n  - The `gxse()` option additionally returns the Q\u003csub\u003ex\u003c/sub\u003e and conditional F-statistics for \n  each phenotype for instrument strength in `e(Qx)` and `e(Fx)` \n  ([Sanderson et al. 2020](#references))\n  - Added `tdist` option to `mrmvivw` and `mrmvegger`\n  - `mrmvivw` and `mrmvegger` now ereturn the RMSE in `e(phi)`\n  - `mregger, ivw` now displays the square root of the residual variance (residual standard error) \n  and ereturns this is `e(phi)`\n  - Checked that examples on website still run\n  - Added `mrleaveoneout` command to perform leave one out analysis\n* June 2020:\n  - Simplified the outcome variable name in `mregger` `b` and `V` e-returned matrices. Turn this off \n  with new `oldnames` option\n  - Added basic multivariable MR-Egger command, `mrmvegger`\n  - Added basic multivariable IVW command, `mrmvivw` (currently command names `mvmr` and `mvivw` \n  also work)\n* February 2020:\n  - Updated contact details\n  - Minor edits to helpfiles, to show examples setting `seed()` option where helpful\n  - Fixed `mregger` bug where `r(table)` was not returned with the `gxse` or `heterogi` options. \n  The output for these options now appears before the coefficient table.\n  - Minor amendments to formatting of `mregger` `gxse` output\n  - `mregger` now ereturns `e(phi)`, the scale parameter, in some cases\n* January 2020:\n  - `mregger` now additionally returns `r(table)`\n  - Certification scripts: added `master.do` and renamed and edited a few scripts\n  - Added `mr` command. Commands may now be run as either `mr egger ...` or as previously \n  `mregger ...`.\n  - [*Best of IJE 2019*!](https://academic.oup.com/ije/pages/the_best_of_ije)\n  - `mrmedian`, `mrmedianobs`, `mreggersimex`, `mrmodal`, and `mrratio` now additionally return \n  the `r(table)` matrix (the information from the coefficient table)\n  - Added an example showing how you can save and export your estimates using `r(table)`, see \n  [here](https://remlapmot.github.io/mrrobust/examples/save-estimates/index.html)\n* December 2019:\n  - Added `Q_GX` to ereturn and display output when `gxse()` option specified to `mregger`\n  - Changed `Q_GX` and `I^2_GX` output to use first order weights in `mregger` output. This matches \n  the output from the `mr_egger()` function in the **MendelianRandomization** R package. Use the \n  `unwi2gx` option to report the unweighted statistics.\n* July 2019:\n  - Checked that examples on website still run\n* December 2018: \n  - Improved compatibility with the [**github**](https://haghish.github.io/github/) Stata package,\n  i.e., **mrrobust** and its dependencies can be installed simply by issuing: `gitget mrrobust`,\n  if you have the **github** package installed. \n  [See below for instructions](#2-use-the-github-package).\n  - `mrdeps` command added for conveniently installing dependencies\n* November 2018:\n  - Example showing the use of the **TwoSampleMR** R package and **mrrobust** in the same \n  [R Markdown script](https://rmarkdown.rstudio.com/) (`.Rmd` file) is \n  [here](https://remlapmot.github.io/mrrobust/examples/rmarkdown-call-stata-example/index.html)\n  - Example showing the use of the **TwoSampleMR** R package and **mrrobust** in the same \n  [Stata Markdown](https://data.princeton.edu/stata/markdown) script (`.stmd` file) is \n  [here](https://remlapmot.github.io/mrrobust/examples/markstat-call-R-example/index.html)\n* September 2018: \n  - IJE paper published online [here](https://doi.org/10.1093/ije/dyy195)\n* August 2018:\n  - Click [here](https://remlapmot.github.io/mrrobust/examples/spiller-ije-2018-examples/index.html) for the \n  example code and output from our IJE article\n* May 2018: \n  - Click [here](https://remlapmot.github.io/mrrobust/examples/mrrobust-examples/index.html) for code and output \n  from the examples in the helpfiles\n  - This page is now rendered on GitHub Pages [here](https://remlapmot.github.io/mrrobust/)\n* April 2018: \n  - `mregger` now has option `radial` which implements the radial formulation of the MR-Egger \n  model, and of the IVW model when used with option `ivw`\n\n## Short video introduction\nClick [here](https://drive.google.com/open?id=0B1owQlNgzNcPY0lMSGk0SnFfQWs) for a short video \ndemonstrating the use of the package.\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://drive.google.com/open?id=0B1owQlNgzNcPY0lMSGk0SnFfQWs\"\u003e\u003cimg src=\"./img/mrconf2017_video_mrforest_screenshot.png\" width=\"528\" height=\"300\" alt=\"A screenshot of a video demonstrating the use of the mrrobust package.\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n## Helpfile examples\nClick [here](https://remlapmot.github.io/mrrobust/examples/mrrobust-examples/index.html) for some of the code and \noutput from the examples in the helpfiles.\n\nOnce the package is installed, there is a summary helpfile which can be viewed in Stata with:\n```stata\nhelp mrrobust\n```\nThis has links to the helpfile for each command, which has an example near the bottom. In these \nexamples you can click on the code to run it.\n\n## Overview\nThe **mrrobust** package is a collection of commands for performing two-sample Mendelian randomization \nanalyses using summary data of genotype-phenotype and genotype-outcome associations. \n\nSuch data can be obtained from repositories such as MR-Base \u003chttps://www.mrbase.org\u003e \n([Hemani et al. 2016](#references)).\n\nThe package contains the following commands:\n\n - `mrdeps` installs dependencies for the package\n - `mrratio` implements the standard instrumental variable ratio (Wald) estimate with a choice of \n standard errors/confidence intervals\n - `mrivests` automates calling `mrratio` on all the selected genotypes in your dataset\n - `mregger` implements the IVW and MR-Egger regression approaches introduced in \n [Bowden et al. (2015)](#references)\n - `mreggersimex` implements the simulation extrapolation algorithm for the MR-Egger model\n - `mreggerplot` implements a scatter plot with fitted line (either from IVW, MR-Egger, or weighted \n median estimators) and confidence interval\n - `mrmedian` and `mrmedianobs` implement the unweighted, weighted, and penalized weighted median \n IV estimators robust to 50% invalid instruments in [Bowden et al. (2016)](#references)\n - `mrmodal` implements the zero modal estimator of [Hartwig et al. (2017)](#references)\n - `mrmodalplot` plot of density used in modal estimator\n - `mrforest` implements a forest plot of genotype specific IV estimates and estimates from models \n (e.g. IVW and MR-Egger)\n - `mrfunnel` funnel plot of genotype specific IV estimates\n - `mr` acts as a primary command, e.g. so the other commands can be run as `mr egger ...` as well \n as `mregger ...`\n - `mrmvivw` (`mvmr`, `mvivw`) implements the multivariable IVW model\n - `mrmvegger` implements the multivariable MR-Egger model\n - `mrleaveoneout` implements leave one (genotype) out analysis\n\n## Installing and updating mrrobust\nTo install **mrrobust** in Stata versions 13 and later you have two choices.\n\n### 1. Use `net install`\n\n``` stata\nnet install mrrobust, from(\"https://raw.github.com/remlapmot/mrrobust/master/\") replace\nmrdeps\n```\nIn this code `mrdeps` installs the dependencies. These are `addplot`, `kdens`, and `moremata` \npackages (all by Ben Jann), the `heterogi` command (Orsini et al.), the `metan` command (Harris et \nal.), and the `grc1leg` command (Wiggins).\n\nIf you have previously installed the package and the `net install` command above fails with an error\nmessage that there are two copies of the package installed simply run `adoupdate`.\n\nTo check if there is an update available to any of your user-written Stata packages run `adoupdate`.\nTo update **mrrobust** run:\n``` stata\nadoupdate mrrobust, update\n```\n\nTo uninstall **mrrobust**, issue in Stata:\n``` stata\nado uninstall mrrobust\n```\nIf this fails with an error message mentioning that you have *\"multiple citations/instances of the \npackage installed\"* simply issue `adoupdate mrrobust`. This should leave you with the most recent \nversion of the package you previously installed. You can then run `ado uninstall mrrobust`.\n\n### 2. Use the `github` package\n\n``` stata\nnet install github, from(\"https://haghish.github.io/github/\")\ngitget mrrobust\n```\nThis automatically installs the dependencies.\n\nTo update the package issue:\n``` stata\ngithub update mrrobust\n```\n\nTo uninstall mrrobust issue:\n``` stata\ngithub uninstall mrrobust\n```\n\n### Installation instructions for Stata version 12 and earlier versions (and perhaps Stata version 13)\nThe `net install` syntax for installing `mrrobust` does not work under Stata version 12 and earlier \nbecause this webpage has an address starting with https rather than http. In such cases you need to \ndo a manual installation.\n\n#### To download and install mrrobust manually:\n\n* Click the green \"Clone or download\" button at the top of the GitHub repository \n[here](https://github.com/remlapmot/mrrobust) and download as a zip archive or click this direct [link](https://github.com/remlapmot/mrrobust/archive/refs/heads/master.zip).\n* In your file explorer extract the zip archive and find its filepath, e.g. `C:\\Users\\tom\\Downloads\\mrrobust-master\\mrrobust-master`\n* In Stata run\n  ```stata\n  net install mrrobust, from(\"C:\\Users\\tom\\Downloads\\mrrobust-master\\mrrobust-master\") replace\n  ```\n\nThe installation commands for the other dependencies should work. However, if you need to install \nthem 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`): \n\n * the **moremata** package is available as a zip file \n [here](http://fmwww.bc.edu/repec/bocode/m/moremata.zip)\n * the `addplot` command is available [here](http://fmwww.bc.edu/repec/bocode/a/addplot.zip) \n * the `heterogi` command is available [here](https://ideas.repec.org/c/boc/bocode/s449201.html)\n * the `kdens` command is available [here](http://fmwww.bc.edu/repec/bocode/k/kdens.zip)\n * the `metan` command is available [here](https://ideas.repec.org/c/boc/bocode/s456798.html)\n * the `grc1leg` command can be installed with\n   ``` stata\n   net install grc1leg, from(\"https://www.stata.com/users/vwiggins\")\n   ```\n\n## Unit tests\nAs far as I know, and unlike R which has the **testthat** package (and other testing packages),\nthere is no recognised standard for writing unit tests for Stata commands.\nStataCorp. refer to do-files with tests as cscripts (certification scripts).\nI publish my cscripts (and their log files of output) in the\n[cscripts directory](https://github.com/remlapmot/mrrobust/tree/master/cscripts). \n\n## Authors\nTom Palmer \u003ctom.palmer@bristol.ac.uk\u003e, Wesley Spiller, Neil Davies\n\n## How to cite the mrrobust package\nSpiller W, Davies NM, Palmer TM. Software Application Profile: mrrobust \u0026mdash; A tool for performing \ntwo-sample summary Mendelian randomization analyses. International Journal of Epidemiology, 2019, \n48, 3, 684\u0026ndash;690. \u003chttps://doi.org/10.1093/ije/dyy195\u003e.\n\nThank you to all our users who have cited **mrrobust**. We made \n[*The Best of IJE 2019*](https://academic.oup.com/ije/pages/the_best_of_ije)!\n\n## Collaboration\nIf you would like to extend the code or add new commands I am open to receiving pull requests on \nGitHub or send me an email to \u003ctom.palmer@bristol.ac.uk\u003e.\n\n## References\n\n\u003cdiv class=\"hanging-indent\"\u003e\n\nBowden J, Davey Smith G, Burgess S. Mendelian randomization with invalid instruments: effect\nestimation and bias detection through Egger regression. International Journal of Epidemiology,\n2015, 44, 2, 512\u0026ndash;525. \u003chttps://dx.doi.org/10.1093/ije/dyv080\u003e.\n\nBowden J, Davey Smith G, Haycock PC, Burgess S. Consistent estimation in Mendelian randomization\nwith some invalid instruments using a weighted median estimator. Genetic Epidemiology, 2016, 40, 4,\n304\u0026ndash;314. \u003chttps://dx.doi.org/10.1002/gepi.21965\u003e.\n\nHartwig FP, Davey Smith G, Bowden J. Robust inference in two-sample Mendelian randomisation via\nthe zero modal pleiotropy assumption. International Journal of Epidemiology, 2017, 46, 6,\n1985\u0026ndash;1998. \u003chttps://doi.org/10.1093/ije/dyx102\u003e.\n\nHemani G et al. The MR-Base platform supports systematic causal inference across the human\nphenome. eLife, 2018, 7:e34408. \u003chttps://doi.org/10.7554/eLife.34408.001\u003e.\n\nSanderson E, Davey Smith G, Windmeijer F, Bowden J. An examination of multivariable Mendelian\nrandomization in the single-sample and two-sample summary data settings. International Journal of\nEpidemiology, 2019, 48, 3, 713\u0026ndash;727. \u003chttps://doi.org/10.1093/ije/dyy262\u003e.\n\nSanderson E, Spiller W, Bowden J. Testing and correcting for weak and pleiotropic instruments in\ntwo-sample multivariable Mendelian randomization. Statistics in Medicine, 2021, 40, 25, 5434\u0026ndash;5452.\n\u003chttps://doi.org/10.1002/sim.9133\u003e.\n\u003c/div\u003e\n\n## Acknowledgements\nThanks for helpful feedback and suggestions to (in no particular order): Jasmine Khouja, \nMichael Holmes, Caroline Dale, Amy Taylor, Rebecca Richmond, Judith Brand, Yanchun Bao, \nKawthar Al-Dabhani, Michalis Katsoulis, Ghazaleh Fatemifar, Lai-Te Chen, Sean Harrison,\nEmma Anderson, Cassianne Robinson-Cohen, Alisa Kjaergaard, and Steve Burgess.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremlapmot%2Fmrrobust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremlapmot%2Fmrrobust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremlapmot%2Fmrrobust/lists"}