if sel1==1, seed(12345)
+ mrmodalplot chdbeta chdse ldlcbeta ldlcse if sel1==1, seed(12345) legend(pos(6))
mrmodalplot chdbeta chdse ldlcbeta ldlcse qui gr export mrmodalplot.svg, width(600) replace
Number of genotypes = 73
@@ -601,7 +601,7 @@ mrmodal examples
mrfunnel examples
-if sel1==1, xlrange(0 10)
+ mrfunnel chdbeta chdse ldlcbeta ldlcse if sel1==1, xlrange(0 10) legend(pos(6))
mrfunnel chdbeta chdse ldlcbeta ldlcse qui gr export mrfunnel.svg, width(600) replace
diff --git a/docs/examples/mrrobust-examples/mreggerplot.svg b/docs/examples/mrrobust-examples/mreggerplot.svg
index 0edd61b..0663f3d 100644
--- a/docs/examples/mrrobust-examples/mreggerplot.svg
+++ b/docs/examples/mrrobust-examples/mreggerplot.svg
@@ -243,15 +243,15 @@
-
+
-
-
+
+
-
-
+
+
diff --git a/docs/examples/mrrobust-examples/mrfunnel.svg b/docs/examples/mrrobust-examples/mrfunnel.svg
index d418bd8..8bec352 100644
--- a/docs/examples/mrrobust-examples/mrfunnel.svg
+++ b/docs/examples/mrrobust-examples/mrfunnel.svg
@@ -6,123 +6,253 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
- 0
-
- 2
-
- 4
-
- 6
-
- 8
+
+
+ 0
+
+ 2
+
+ 4
+
+ 6
+
+ 8
10
-
+
Instrument strength (abs(
γ
j
@@ -910,29 +1050,29 @@
Yj
)
-
-
- -4
-
- -2
-
- 0
-
- 2
-
+
+
+ -4
+
+ -2
+
+ 0
+
+ 2
+
β
IV
-
-
-
-
-
-
-
-
-
- Genotypes
- IVW
- MR-Egger
+
+
+
+
+
+
+
+
+
+ Genotypes
+ IVW
+ MR-Egger
diff --git a/docs/examples/mrrobust-examples/mrmodalplot.svg b/docs/examples/mrrobust-examples/mrmodalplot.svg
index bbba705..70da4ef 100644
--- a/docs/examples/mrrobust-examples/mrmodalplot.svg
+++ b/docs/examples/mrrobust-examples/mrmodalplot.svg
@@ -6,80 +6,155 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -103,178 +178,188 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 0
-
- .5
-
- 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+ .5
+
+ 1
1.5
- Density
-
-
- -4
-
- -2
-
- 0
-
- 2
-
- 4
- IV estimates
-
-
-
-
-
- φ = .25
- φ = .5
- φ = 1
+ Density
+
+
+ -4
+
+ -2
+
+ 0
+
+ 2
+
+ 4
+ IV estimates
+
+
+
+
+
+ φ = .25
+ φ = .5
+ φ = 1
diff --git a/docs/examples/rmarkdown-call-stata-example/index.html b/docs/examples/rmarkdown-call-stata-example/index.html
index f9bf15d..a96a7ec 100644
--- a/docs/examples/rmarkdown-call-stata-example/index.html
+++ b/docs/examples/rmarkdown-call-stata-example/index.html
@@ -309,9 +309,10 @@ Introduction
repos = c(
"https://mrcieu.r-universe.dev",
"https://cloud.r-project.org"
-
- )
- )install.packages("foreign")
+
+ ),dependencies = TRUE
+
+ )install.packages("foreign")
Example R Markdown or Quarto document
diff --git a/docs/examples/spiller-ije-2018-examples/index.html b/docs/examples/spiller-ije-2018-examples/index.html
index 95a3997..8b7f307 100644
--- a/docs/examples/spiller-ije-2018-examples/index.html
+++ b/docs/examples/spiller-ije-2018-examples/index.html
@@ -454,7 +454,7 @@ Weighted median
Stata output using the mode-based estimator using mrrobust: BMI-Serum Glucose
Using the mrmodalplot
command, modal estimates are calculated using bandwidths of 0.25, 0.5, and 1 respectively. This command also produces three overlaid density plots for each value, as shown in the Figure.
-seed(300818)
+ mrmodalplot betaoutcome seoutcome betaexposure seexposure, lc(gs10 gs5 gs0) seed(300818) legend(pos(6))
mrmodalplot betaoutcome seoutcome betaexposure seexposure, lc(gs10 gs5 gs0) qui gr export mrmodalplot-bmi.svg, width(600) replace
Number of genotypes = 79
@@ -573,7 +573,7 @@ Weighted median
Stata output using the mode-based estimator using mrrobust: Height-Serum Glucose
-seed(300818)
+ mrmodalplot betaoutcome seoutcome betaexposure seexposure, lc(gs10 gs5 gs0) seed(300818) legend(pos(6))
mrmodalplot betaoutcome seoutcome betaexposure seexposure, lc(gs10 gs5 gs0) qui gr export mrmodalplot-height.svg, width(600) replace
Number of genotypes = 367
diff --git a/docs/examples/spiller-ije-2018-examples/mreggerplot-bmi.svg b/docs/examples/spiller-ije-2018-examples/mreggerplot-bmi.svg
index df53919..00f0213 100644
--- a/docs/examples/spiller-ije-2018-examples/mreggerplot-bmi.svg
+++ b/docs/examples/spiller-ije-2018-examples/mreggerplot-bmi.svg
@@ -175,15 +175,15 @@
-
+
-
-
+
+
-
-
+
+
diff --git a/docs/examples/spiller-ije-2018-examples/mreggerplot-height.svg b/docs/examples/spiller-ije-2018-examples/mreggerplot-height.svg
index 992a588..1cfbc3c 100644
--- a/docs/examples/spiller-ije-2018-examples/mreggerplot-height.svg
+++ b/docs/examples/spiller-ije-2018-examples/mreggerplot-height.svg
@@ -227,15 +227,15 @@
-
+
-
-
+
+
-
-
+
+
diff --git a/docs/examples/spiller-ije-2018-examples/mrmodalplot-bmi.svg b/docs/examples/spiller-ije-2018-examples/mrmodalplot-bmi.svg
index c29803d..3ceedb6 100644
--- a/docs/examples/spiller-ije-2018-examples/mrmodalplot-bmi.svg
+++ b/docs/examples/spiller-ije-2018-examples/mrmodalplot-bmi.svg
@@ -6,276 +6,389 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 0
-
- 2
-
- 4
-
- 6
-
- 8
- Density
-
-
- -.2
-
- 0
-
- .2
-
- .4
- IV estimates
-
-
-
-
-
- φ = .25
- φ = .5
- φ = 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+ 2
+
+ 4
+
+ 6
+
+ 8
+ Density
+
+
+ -.2
+
+ 0
+
+ .2
+
+ .4
+ IV estimates
+
+
+
+
+
+ φ = .25
+ φ = .5
+ φ = 1
diff --git a/docs/examples/spiller-ije-2018-examples/mrmodalplot-height.svg b/docs/examples/spiller-ije-2018-examples/mrmodalplot-height.svg
index 13b76de..5f72628 100644
--- a/docs/examples/spiller-ije-2018-examples/mrmodalplot-height.svg
+++ b/docs/examples/spiller-ije-2018-examples/mrmodalplot-height.svg
@@ -6,83 +6,158 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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+ IV estimates
+
+
+
+
+
+ φ = .25
+ φ = .5
+ φ = 1
diff --git a/docs/search.json b/docs/search.json
index ba11fe2..b400386 100644
--- a/docs/search.json
+++ b/docs/search.json
@@ -60,14 +60,14 @@
"href": "examples/mrrobust-examples/index.html#mrmodal-examples",
"title": "Examples from helpfiles in the mrrobust package",
"section": "mrmodal examples",
- "text": "mrmodal examples\n\nmrmodalplot chdbeta chdse ldlcbeta ldlcse if sel1==1, seed(12345)\nqui gr export mrmodalplot.svg, width(600) replace\n\n Number of genotypes = 73\n Replications = 1000\n Phi = .25\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4198713 .2267297 1.85 0.064 -.0245107 .8642533\n------------------------------------------------------------------------------\n\n Number of genotypes = 73\n Replications = 1000\n Phi = .5\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4218667 .1981169 2.13 0.033 .0335647 .8101688\n------------------------------------------------------------------------------\n\n Number of genotypes = 73\n Replications = 1000\n Phi = 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4917353 .1356432 3.63 0.000 .2258796 .757591\n------------------------------------------------------------------------------\n\n\n\n\n\n\n\nDensities of the IV estimates using different values of the phi parameter.\n\n\n\n\nSimple mode estimator.\n\nmrmodal chdbeta chdse ldlcbeta ldlcse if sel1==1\n\n Number of genotypes = 73\n Replications = 1000\n Phi = 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4917353 .1276278 3.85 0.000 .2415894 .7418812\n------------------------------------------------------------------------------\n\n\nWeighted mode estimator.\n\nmrmodal chdbeta chdse ldlcbeta ldlcse if sel1==1, weighted\n\n Number of genotypes = 73\n Replications = 1000\n Phi = 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4789702 .0663145 7.22 0.000 .3489963 .6089441\n------------------------------------------------------------------------------\n\n\nSimple mode estimator with NOME assumption.\n\nmrmodal chdbeta chdse ldlcbeta ldlcse if sel1==1, nome\n\n Number of genotypes = 73\n Replications = 1000\n Phi = 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4917353 .1266936 3.88 0.000 .2434204 .7400501\n------------------------------------------------------------------------------"
+ "text": "mrmodal examples\n\nmrmodalplot chdbeta chdse ldlcbeta ldlcse if sel1==1, seed(12345) legend(pos(6))\nqui gr export mrmodalplot.svg, width(600) replace\n\n Number of genotypes = 73\n Replications = 1000\n Phi = .25\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4198713 .2267297 1.85 0.064 -.0245107 .8642533\n------------------------------------------------------------------------------\n\n Number of genotypes = 73\n Replications = 1000\n Phi = .5\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4218667 .1981169 2.13 0.033 .0335647 .8101688\n------------------------------------------------------------------------------\n\n Number of genotypes = 73\n Replications = 1000\n Phi = 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4917353 .1356432 3.63 0.000 .2258796 .757591\n------------------------------------------------------------------------------\n\n\n\n\n\n\n\nDensities of the IV estimates using different values of the phi parameter.\n\n\n\n\nSimple mode estimator.\n\nmrmodal chdbeta chdse ldlcbeta ldlcse if sel1==1\n\n Number of genotypes = 73\n Replications = 1000\n Phi = 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4917353 .1276278 3.85 0.000 .2415894 .7418812\n------------------------------------------------------------------------------\n\n\nWeighted mode estimator.\n\nmrmodal chdbeta chdse ldlcbeta ldlcse if sel1==1, weighted\n\n Number of genotypes = 73\n Replications = 1000\n Phi = 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4789702 .0663145 7.22 0.000 .3489963 .6089441\n------------------------------------------------------------------------------\n\n\nSimple mode estimator with NOME assumption.\n\nmrmodal chdbeta chdse ldlcbeta ldlcse if sel1==1, nome\n\n Number of genotypes = 73\n Replications = 1000\n Phi = 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4917353 .1266936 3.88 0.000 .2434204 .7400501\n------------------------------------------------------------------------------"
},
{
"objectID": "examples/mrrobust-examples/index.html#mrfunnel-examples",
"href": "examples/mrrobust-examples/index.html#mrfunnel-examples",
"title": "Examples from helpfiles in the mrrobust package",
"section": "mrfunnel examples",
- "text": "mrfunnel examples\n\nmrfunnel chdbeta chdse ldlcbeta ldlcse if sel1==1, xlrange(0 10)\nqui gr export mrfunnel.svg, width(600) replace\n\n\n\n\n\n\nExample funnel plot."
+ "text": "mrfunnel examples\n\nmrfunnel chdbeta chdse ldlcbeta ldlcse if sel1==1, xlrange(0 10) legend(pos(6))\nqui gr export mrfunnel.svg, width(600) replace\n\n\n\n\n\n\nExample funnel plot."
},
{
"objectID": "examples/mrrobust-examples/index.html#leave-one-out-analysis",
@@ -200,7 +200,7 @@
"href": "examples/markstat-call-R-example/index.html",
"title": "Access the OpenGWAS API from a Stata do-file or Stata Markdown script",
"section": "",
- "text": "This example shows how to run R and Stata code within the same Stata Markdown (.stmd) script. The general approach is detailed on the Stata Markdown website here and here.\nThis means that we can use the functions provided by the TwoSampleMR package to obtain data from the [OpenGWAS API}(https://api.opengwas.io/) which is the successor to MR-Base (Hemani et al. 2018).\nThe OpenGWAS API requires authentication. You must place an OPENGWAS_JWT token (by creating a free account on https://api.opengwas.io/profile/) in your .Renviron file before running the code below. See the ieugwasr website for more information.\nBefore you start please install the following two Stata packages from the SSC archive, so in Stata issue the following commands (I have commented them out because I have already installed them).\nssc install whereis\nssc install markstat\n\n\n\nThe following is the example Stata Markdown document.\n---\ntitle: Using mrrobust in a Markstat document example\n---\n\nWe first need to register the R executable with Stata.\n\n```s\nif c(os) == \"Windows\" local rpath \"C:\\\\Program Files\\\\R\\\\R-4.4.1\\\\bin\\\\x64\\\\R.exe\"\nelse if c(os) == \"Unix\" local rpath \"/usr/bin/R\"\nelse local rpath \"/usr/local/bin/R\"\nwhereis R \"`rpath'\"\n```\n\nNext we have an R code chunk in which we install the required packages in R.\n\n```r\ninstall.packages(\"remotes\")\nremotes::install_github(\"MRCIEU/TwoSampleMR\")\nremotes::install_github(\"MRCIEU/MRInstruments\")\n```\n\n## Extracting data from the OpenGWAS API\n\nWe will be running the script from the MR-Base paper \n([Hemani et al., 2018](https://doi.org/10.7554/eLife.34408)). \nThe R code we will use is from \n[here](https://raw.githubusercontent.com/explodecomputer/mr-base-methods-paper/master/scripts/ldl-chd.R).\n\nFirst, we load the packages into our R session.\nNote that the **foreign** package provides the \n`write.dta()` function which we will use to save the data in Stata format.\n\n```r\nlibrary(TwoSampleMR)\nlibrary(MRInstruments)\nlibrary(foreign)\n```\n\nOur edited version of the code starts by reading in some code\nto generate a set of plots in R.\n\n```r\nsource(\"mrplots.R\")\n```\n\nWe can access the data using the **MRInstruments** package.\n\n```r\ndata(gwas_catalog)\n\n# Get published SNPs for LDL cholesterol\nldl_snps <- \n subset(gwas_catalog, \n grepl(\"LDL choles\", Phenotype) & Author == \"Willer CJ\")$SNP\n\n# Extract from GLGC dataset\nexposure <- \n convert_outcome_to_exposure(\n extract_outcome_data(ldl_snps, \"ieu-a-300\"))\n\n# Get outcome data from Cardiogram 2015\noutcome <- extract_outcome_data(exposure$SNP, \"ieu-a-7\")\n\n# Harmonise exposure and outcome datasets\n# Assume alleles are on the forward strand\ndat <- harmonise_data(exposure, outcome, action = 1)\n```\n\nAt this point we have our harmonised genotype-exposure and \ngenotype-outcome association data saved in an object in our \nR session called `dat`.\n\nThe next two code chunks perform the analysis in R.\n\n```r\n# Perform MR\nmr(dat)\nmr_heterogeneity(dat)\ndat$exposure <- \"LDL cholesterol\"\ndat$outcome <- \"Coronary heart disease\"\n\n# Label outliers and create plots\ndat$labels <- dat$SNP\ndat$labels[! dat$SNP %in% c(\"rs11065987\", \"rs1250229\", \"rs4530754\")] <- NA\n```\n\n```r\npng(\"ldl-chd.png\", width=1000, height=1000)\nmr_plots(dat)\ndev.off()\n```\n\n![Plots generated by the TwoSampleMR R package.](ldl-chd.png)\n\nWe now save our `dat` object as a Stata dataset.\n\n```r\nwrite.dta(dat, file = \"dat.dta\")\n```\n\n## Performing the analysis using mrrobust in Stata\n\nWe now switch from using R code chunks to Stata code chunks.\nWe read the data into Stata and list the variable names\n(note any `.` in the colnames of `dat` have been replaced with `_`).\n\n```s\nuse dat, clear\nds, v(28)\ndi _N\n```\n\nWe can then run the IVW model using `mregger` with multiplicative\nstandard errors.\n\n```s\nmregger beta_outcome beta_exposure [aw=1/(se_outcome^2)], ivw\n```\n\nIt is helpful to view the forest plot of genotype specific IV estimates.\n\n```s\nmrforest beta_outcome se_outcome beta_exposure se_exposure, ivid(SNP) ///\n xlabel(-3,-2,-1,0,1,2,3)\ngraph export ldl-chd-mrforest.svg, width(600) replace\n```\n\n![Forest plot of genotype specific IV estimates.](ldl-chd-mrforest.svg)\n\nWe can visualise this model with `mreggerplot`.\n\n```s\nmreggerplot beta_outcome se_outcome beta_exposure se_exposure\ngraph export ldl-chd-mreggerplot.svg, width(600) replace\n```\n\n![Plot of the MR-Egger model.](ldl-chd-mreggerplot.svg)\n\nWe then fit the MR-Egger, median, and modal based estimators.\n\n```s\nmregger beta_outcome beta_exposure [aw=1/(se_outcome^2)]\n```\n\n```s\nmrmedian beta_outcome se_outcome beta_exposure se_exposure, weighted\n```\n\n```s\nmrmodal beta_outcome se_outcome beta_exposure se_exposure, weighted\n```\nAnd we could continue with additional Stata code (or indeed R code) as we liked.\nNote to run this .stmd file in Stata we do so with the following command (specifying additional options as required, see help markstat for more information).\nmarkstat using markstat-call-R-example\n\n\n\n\n\nHemani, Gibran, Jie Zheng, Benjamin Elsworth, Kaitlin H Wade, Valeriia Haberland, Denis Baird, Charles Laurin, et al. 2018. “The MR-Base platform supports systematic causal inference across the human phenome.” eLife 7: e34408. https://doi.org/10.7554/eLife.34408."
+ "text": "This example shows how to run R and Stata code within the same Stata Markdown (.stmd) script. The general approach is detailed on the Stata Markdown website here and here.\nThis means that we can use the functions provided by the TwoSampleMR package to obtain data from the [OpenGWAS API}(https://api.opengwas.io/) which is the successor to MR-Base (Hemani et al. 2018).\nThe OpenGWAS API requires authentication. You must place an OPENGWAS_JWT token (by creating a free account on https://api.opengwas.io/profile/) in your .Renviron file before running the code below. See the ieugwasr website for more information.\nBefore you start please install the following two Stata packages from the SSC archive, so in Stata issue the following commands (I have commented them out because I have already installed them).\nssc install whereis\nssc install markstat\n\n\n\nThe following is the example Stata Markdown document.\n---\ntitle: Using mrrobust in a Markstat document example\n---\n\nWe first need to register the R executable with Stata.\n\n```s\nif c(os) == \"Windows\" local rpath \"C:\\\\Program Files\\\\R\\\\R-4.4.1\\\\bin\\\\x64\\\\R.exe\"\nelse if c(os) == \"Unix\" local rpath \"/usr/bin/R\"\nelse local rpath \"/usr/local/bin/R\"\nwhereis R \"`rpath'\"\n```\n\nNext we have an R code chunk in which we install the required packages in R.\n\n```r\ninstall.packages(\n \"TwoSampleMR\",\n repos = c(\n \"https://mrcieu.r-universe.dev\",\n \"https://cloud.r-project.org\"\n ),\n dependencies = TRUE\n)\n```\n\n## Extracting data from the OpenGWAS API\n\nWe will be running the script from the MR-Base paper \n([Hemani et al., 2018](https://doi.org/10.7554/eLife.34408)). \nThe R code we will use is from \n[here](https://raw.githubusercontent.com/explodecomputer/mr-base-methods-paper/master/scripts/ldl-chd.R).\n\nFirst, we load the packages into our R session.\nNote that the **foreign** package provides the \n`write.dta()` function which we will use to save the data in Stata format.\n\n```r\nlibrary(TwoSampleMR)\nlibrary(MRInstruments)\nlibrary(foreign)\n```\n\nOur edited version of the code starts by reading in some code\nto generate a set of plots in R.\n\n```r\nsource(\"mrplots.R\")\n```\n\nWe can access the data using the **MRInstruments** package.\n\n```r\ndata(gwas_catalog)\n\n# Get published SNPs for LDL cholesterol\nldl_snps <- \n subset(gwas_catalog, \n grepl(\"LDL choles\", Phenotype) & Author == \"Willer CJ\")$SNP\n\n# Extract from GLGC dataset\nexposure <- \n convert_outcome_to_exposure(\n extract_outcome_data(ldl_snps, \"ieu-a-300\"))\n\n# Get outcome data from Cardiogram 2015\noutcome <- extract_outcome_data(exposure$SNP, \"ieu-a-7\")\n\n# Harmonise exposure and outcome datasets\n# Assume alleles are on the forward strand\ndat <- harmonise_data(exposure, outcome, action = 1)\n```\n\nAt this point we have our harmonised genotype-exposure and \ngenotype-outcome association data saved in an object in our \nR session called `dat`.\n\nThe next two code chunks perform the analysis in R.\n\n```r\n# Perform MR\nmr(dat)\nmr_heterogeneity(dat)\ndat$exposure <- \"LDL cholesterol\"\ndat$outcome <- \"Coronary heart disease\"\n\n# Label outliers and create plots\ndat$labels <- dat$SNP\ndat$labels[! dat$SNP %in% c(\"rs11065987\", \"rs1250229\", \"rs4530754\")] <- NA\n```\n\n```r\npng(\"ldl-chd.png\", width=1000, height=1000)\nmr_plots(dat)\ndev.off()\n```\n\n![Plots generated by the TwoSampleMR R package.](ldl-chd.png)\n\nWe now save our `dat` object as a Stata dataset.\n\n```r\nwrite.dta(dat, file = \"dat.dta\")\n```\n\n## Performing the analysis using mrrobust in Stata\n\nWe now switch from using R code chunks to Stata code chunks.\nWe read the data into Stata and list the variable names\n(note any `.` in the colnames of `dat` have been replaced with `_`).\n\n```s\nuse dat, clear\nds, v(28)\ndi _N\n```\n\nWe can then run the IVW model using `mregger` with multiplicative\nstandard errors.\n\n```s\nmregger beta_outcome beta_exposure [aw=1/(se_outcome^2)], ivw\n```\n\nIt is helpful to view the forest plot of genotype specific IV estimates.\n\n```s\nmrforest beta_outcome se_outcome beta_exposure se_exposure, ivid(SNP) ///\n xlabel(-3,-2,-1,0,1,2,3)\ngraph export ldl-chd-mrforest.svg, width(600) replace\n```\n\n![Forest plot of genotype specific IV estimates.](ldl-chd-mrforest.svg)\n\nWe can visualise this model with `mreggerplot`.\n\n```s\nmreggerplot beta_outcome se_outcome beta_exposure se_exposure\ngraph export ldl-chd-mreggerplot.svg, width(600) replace\n```\n\n![Plot of the MR-Egger model.](ldl-chd-mreggerplot.svg)\n\nWe then fit the MR-Egger, median, and modal based estimators.\n\n```s\nmregger beta_outcome beta_exposure [aw=1/(se_outcome^2)]\n```\n\n```s\nmrmedian beta_outcome se_outcome beta_exposure se_exposure, weighted\n```\n\n```s\nmrmodal beta_outcome se_outcome beta_exposure se_exposure, weighted\n```\nAnd we could continue with additional Stata code (or indeed R code) as we liked.\nNote to run this .stmd file in Stata we do so with the following command (specifying additional options as required, see help markstat for more information).\nmarkstat using markstat-call-R-example\n\n\n\n\n\nHemani, Gibran, Jie Zheng, Benjamin Elsworth, Kaitlin H Wade, Valeriia Haberland, Denis Baird, Charles Laurin, et al. 2018. “The MR-Base platform supports systematic causal inference across the human phenome.” eLife 7: e34408. https://doi.org/10.7554/eLife.34408."
},
{
"objectID": "examples/markstat-call-R-example/index.html#introduction",
@@ -214,7 +214,7 @@
"href": "examples/markstat-call-R-example/index.html#example-stata-markdown-document",
"title": "Access the OpenGWAS API from a Stata do-file or Stata Markdown script",
"section": "",
- "text": "The following is the example Stata Markdown document.\n---\ntitle: Using mrrobust in a Markstat document example\n---\n\nWe first need to register the R executable with Stata.\n\n```s\nif c(os) == \"Windows\" local rpath \"C:\\\\Program Files\\\\R\\\\R-4.4.1\\\\bin\\\\x64\\\\R.exe\"\nelse if c(os) == \"Unix\" local rpath \"/usr/bin/R\"\nelse local rpath \"/usr/local/bin/R\"\nwhereis R \"`rpath'\"\n```\n\nNext we have an R code chunk in which we install the required packages in R.\n\n```r\ninstall.packages(\"remotes\")\nremotes::install_github(\"MRCIEU/TwoSampleMR\")\nremotes::install_github(\"MRCIEU/MRInstruments\")\n```\n\n## Extracting data from the OpenGWAS API\n\nWe will be running the script from the MR-Base paper \n([Hemani et al., 2018](https://doi.org/10.7554/eLife.34408)). \nThe R code we will use is from \n[here](https://raw.githubusercontent.com/explodecomputer/mr-base-methods-paper/master/scripts/ldl-chd.R).\n\nFirst, we load the packages into our R session.\nNote that the **foreign** package provides the \n`write.dta()` function which we will use to save the data in Stata format.\n\n```r\nlibrary(TwoSampleMR)\nlibrary(MRInstruments)\nlibrary(foreign)\n```\n\nOur edited version of the code starts by reading in some code\nto generate a set of plots in R.\n\n```r\nsource(\"mrplots.R\")\n```\n\nWe can access the data using the **MRInstruments** package.\n\n```r\ndata(gwas_catalog)\n\n# Get published SNPs for LDL cholesterol\nldl_snps <- \n subset(gwas_catalog, \n grepl(\"LDL choles\", Phenotype) & Author == \"Willer CJ\")$SNP\n\n# Extract from GLGC dataset\nexposure <- \n convert_outcome_to_exposure(\n extract_outcome_data(ldl_snps, \"ieu-a-300\"))\n\n# Get outcome data from Cardiogram 2015\noutcome <- extract_outcome_data(exposure$SNP, \"ieu-a-7\")\n\n# Harmonise exposure and outcome datasets\n# Assume alleles are on the forward strand\ndat <- harmonise_data(exposure, outcome, action = 1)\n```\n\nAt this point we have our harmonised genotype-exposure and \ngenotype-outcome association data saved in an object in our \nR session called `dat`.\n\nThe next two code chunks perform the analysis in R.\n\n```r\n# Perform MR\nmr(dat)\nmr_heterogeneity(dat)\ndat$exposure <- \"LDL cholesterol\"\ndat$outcome <- \"Coronary heart disease\"\n\n# Label outliers and create plots\ndat$labels <- dat$SNP\ndat$labels[! dat$SNP %in% c(\"rs11065987\", \"rs1250229\", \"rs4530754\")] <- NA\n```\n\n```r\npng(\"ldl-chd.png\", width=1000, height=1000)\nmr_plots(dat)\ndev.off()\n```\n\n![Plots generated by the TwoSampleMR R package.](ldl-chd.png)\n\nWe now save our `dat` object as a Stata dataset.\n\n```r\nwrite.dta(dat, file = \"dat.dta\")\n```\n\n## Performing the analysis using mrrobust in Stata\n\nWe now switch from using R code chunks to Stata code chunks.\nWe read the data into Stata and list the variable names\n(note any `.` in the colnames of `dat` have been replaced with `_`).\n\n```s\nuse dat, clear\nds, v(28)\ndi _N\n```\n\nWe can then run the IVW model using `mregger` with multiplicative\nstandard errors.\n\n```s\nmregger beta_outcome beta_exposure [aw=1/(se_outcome^2)], ivw\n```\n\nIt is helpful to view the forest plot of genotype specific IV estimates.\n\n```s\nmrforest beta_outcome se_outcome beta_exposure se_exposure, ivid(SNP) ///\n xlabel(-3,-2,-1,0,1,2,3)\ngraph export ldl-chd-mrforest.svg, width(600) replace\n```\n\n![Forest plot of genotype specific IV estimates.](ldl-chd-mrforest.svg)\n\nWe can visualise this model with `mreggerplot`.\n\n```s\nmreggerplot beta_outcome se_outcome beta_exposure se_exposure\ngraph export ldl-chd-mreggerplot.svg, width(600) replace\n```\n\n![Plot of the MR-Egger model.](ldl-chd-mreggerplot.svg)\n\nWe then fit the MR-Egger, median, and modal based estimators.\n\n```s\nmregger beta_outcome beta_exposure [aw=1/(se_outcome^2)]\n```\n\n```s\nmrmedian beta_outcome se_outcome beta_exposure se_exposure, weighted\n```\n\n```s\nmrmodal beta_outcome se_outcome beta_exposure se_exposure, weighted\n```\nAnd we could continue with additional Stata code (or indeed R code) as we liked.\nNote to run this .stmd file in Stata we do so with the following command (specifying additional options as required, see help markstat for more information).\nmarkstat using markstat-call-R-example"
+ "text": "The following is the example Stata Markdown document.\n---\ntitle: Using mrrobust in a Markstat document example\n---\n\nWe first need to register the R executable with Stata.\n\n```s\nif c(os) == \"Windows\" local rpath \"C:\\\\Program Files\\\\R\\\\R-4.4.1\\\\bin\\\\x64\\\\R.exe\"\nelse if c(os) == \"Unix\" local rpath \"/usr/bin/R\"\nelse local rpath \"/usr/local/bin/R\"\nwhereis R \"`rpath'\"\n```\n\nNext we have an R code chunk in which we install the required packages in R.\n\n```r\ninstall.packages(\n \"TwoSampleMR\",\n repos = c(\n \"https://mrcieu.r-universe.dev\",\n \"https://cloud.r-project.org\"\n ),\n dependencies = TRUE\n)\n```\n\n## Extracting data from the OpenGWAS API\n\nWe will be running the script from the MR-Base paper \n([Hemani et al., 2018](https://doi.org/10.7554/eLife.34408)). \nThe R code we will use is from \n[here](https://raw.githubusercontent.com/explodecomputer/mr-base-methods-paper/master/scripts/ldl-chd.R).\n\nFirst, we load the packages into our R session.\nNote that the **foreign** package provides the \n`write.dta()` function which we will use to save the data in Stata format.\n\n```r\nlibrary(TwoSampleMR)\nlibrary(MRInstruments)\nlibrary(foreign)\n```\n\nOur edited version of the code starts by reading in some code\nto generate a set of plots in R.\n\n```r\nsource(\"mrplots.R\")\n```\n\nWe can access the data using the **MRInstruments** package.\n\n```r\ndata(gwas_catalog)\n\n# Get published SNPs for LDL cholesterol\nldl_snps <- \n subset(gwas_catalog, \n grepl(\"LDL choles\", Phenotype) & Author == \"Willer CJ\")$SNP\n\n# Extract from GLGC dataset\nexposure <- \n convert_outcome_to_exposure(\n extract_outcome_data(ldl_snps, \"ieu-a-300\"))\n\n# Get outcome data from Cardiogram 2015\noutcome <- extract_outcome_data(exposure$SNP, \"ieu-a-7\")\n\n# Harmonise exposure and outcome datasets\n# Assume alleles are on the forward strand\ndat <- harmonise_data(exposure, outcome, action = 1)\n```\n\nAt this point we have our harmonised genotype-exposure and \ngenotype-outcome association data saved in an object in our \nR session called `dat`.\n\nThe next two code chunks perform the analysis in R.\n\n```r\n# Perform MR\nmr(dat)\nmr_heterogeneity(dat)\ndat$exposure <- \"LDL cholesterol\"\ndat$outcome <- \"Coronary heart disease\"\n\n# Label outliers and create plots\ndat$labels <- dat$SNP\ndat$labels[! dat$SNP %in% c(\"rs11065987\", \"rs1250229\", \"rs4530754\")] <- NA\n```\n\n```r\npng(\"ldl-chd.png\", width=1000, height=1000)\nmr_plots(dat)\ndev.off()\n```\n\n![Plots generated by the TwoSampleMR R package.](ldl-chd.png)\n\nWe now save our `dat` object as a Stata dataset.\n\n```r\nwrite.dta(dat, file = \"dat.dta\")\n```\n\n## Performing the analysis using mrrobust in Stata\n\nWe now switch from using R code chunks to Stata code chunks.\nWe read the data into Stata and list the variable names\n(note any `.` in the colnames of `dat` have been replaced with `_`).\n\n```s\nuse dat, clear\nds, v(28)\ndi _N\n```\n\nWe can then run the IVW model using `mregger` with multiplicative\nstandard errors.\n\n```s\nmregger beta_outcome beta_exposure [aw=1/(se_outcome^2)], ivw\n```\n\nIt is helpful to view the forest plot of genotype specific IV estimates.\n\n```s\nmrforest beta_outcome se_outcome beta_exposure se_exposure, ivid(SNP) ///\n xlabel(-3,-2,-1,0,1,2,3)\ngraph export ldl-chd-mrforest.svg, width(600) replace\n```\n\n![Forest plot of genotype specific IV estimates.](ldl-chd-mrforest.svg)\n\nWe can visualise this model with `mreggerplot`.\n\n```s\nmreggerplot beta_outcome se_outcome beta_exposure se_exposure\ngraph export ldl-chd-mreggerplot.svg, width(600) replace\n```\n\n![Plot of the MR-Egger model.](ldl-chd-mreggerplot.svg)\n\nWe then fit the MR-Egger, median, and modal based estimators.\n\n```s\nmregger beta_outcome beta_exposure [aw=1/(se_outcome^2)]\n```\n\n```s\nmrmedian beta_outcome se_outcome beta_exposure se_exposure, weighted\n```\n\n```s\nmrmodal beta_outcome se_outcome beta_exposure se_exposure, weighted\n```\nAnd we could continue with additional Stata code (or indeed R code) as we liked.\nNote to run this .stmd file in Stata we do so with the following command (specifying additional options as required, see help markstat for more information).\nmarkstat using markstat-call-R-example"
},
{
"objectID": "examples/markstat-call-R-example/index.html#references",
@@ -235,14 +235,14 @@
"href": "examples/rmarkdown-call-stata-example/index.html",
"title": "How to include mrrobust Stata code in an R Markdown or Quarto document using the Statamarkdown R package",
"section": "",
- "text": "This example shows how to run R and Stata code within the same R Markdown (.Rmd) or Quarto (.qmd) file using the Statamarkdown R package. More information about this package is available here and here. To install this package run the following in R.\ninstall.packages(\"Statamarkdown\")\nNote when writing our Stata code chunks we need to be careful when we specify the collectcode=TRUE code chunk option, because each Stata code chunk is run as a separate batch job. For example, we include this chunk option in a chunk which reads in a dataset which we wish to use in subsequent chunks.\nUsing R and Stata code in the same script means that we can use the functions provided by the TwoSampleMR package to obtain data from the OpenGWAS API, which is the successor to MR-Base (Hemani et al. 2018).\nThe OpenGWAS API requires authentication. You must place an OPENGWAS_JWT token (by creating a free account on https://api.opengwas.io/profile/) in your .Renviron file before running the code below. See the ieugwasr website for more information.\nNext we install the other required packages in R.\ninstall.packages(\n \"TwoSampleMR\",\n repos = c(\n \"https://mrcieu.r-universe.dev\",\n \"https://cloud.r-project.org\"\n )\n)\ninstall.packages(\"foreign\")\n\n\n\nSave the following code chunk as an .Rmd or .qmd file, e.g. myanalysis.Rmd.\n---\ntitle: Using mrrobust in an R Markdown or Quarto document\n---\n\n## Extracting data from MR-Base\n\nWe will be running the script from the MR-Base paper \n([Hemani et al., 2018](https://doi.org/10.7554/eLife.34408)).\nThe R code we will use is from\n[here](https://raw.githubusercontent.com/explodecomputer/mr-base-methods-paper/master/scripts/ldl-chd.R).\n\nWe load the packages into our R session.\nNote that the **foreign** package provides the `write.dta()` function\nwhich we will use to save the data in Stata format.\n\n```{r}\nlibrary(TwoSampleMR)\nlibrary(MRInstruments)\nlibrary(foreign)\nlibrary(Statamarkdown)\n```\n\nWe can access the data using the **MRInstruments** package.\n\n```{r}\ndata(gwas_catalog)\n\n# Get published SNPs for LDL cholesterol\nldl_snps <-\n subset(gwas_catalog,\n grepl(\"LDL choles\", Phenotype) & Author == \"Willer CJ\")$SNP\n\n# Extract from GLGC dataset\nexposure <-\n convert_outcome_to_exposure(\n extract_outcome_data(ldl_snps, \"ieu-a-300\"))\n\n# Get outcome data from Cardiogram 2015\noutcome <- extract_outcome_data(exposure$SNP, \"ieu-a-7\")\n\n# Harmonise exposure and outcome datasets\n# Assume alleles are on the forward strand\ndat <- harmonise_data(exposure, outcome, action = 1)\n```\n\nAt this point we have our harmonised genotype-exposure and genotype-outcome\nassociation data saved in an object in our R session called `dat`.\n\nThe next two code chunks perform the analysis in R.\n\n```{r}\n# Perform MR analysis\nmr(dat)\nmr_heterogeneity(dat)\ndat$exposure <- \"LDL cholesterol\"\ndat$outcome <- \"Coronary heart disease\"\n\n# Label outliers and create plots\ndat$labels <- dat$SNP\ndat$labels[! dat$SNP %in% c(\"rs11065987\", \"rs1250229\", \"rs4530754\")] <- NA\n```\n\nTo proceed in Stata we can save our `dat` object as a Stata dataset\n\n```{r}\nwrite.dta(dat, file = \"dat.dta\")\n```\n\n## Analysis in Stata using the mrrobust package\n\nAt this point in Stata install the **mrrobust** package and its\ndependencies if you have not done so previously.\n\n```stata\nnet install github, from(\"https://haghish.github.io/github/\")\ngitget mrrobust\n```\n\nWe now read the dataset into Stata and look at the variable names\nand the number of observations.\n\n```{stata, collectcode=TRUE}\nqui use dat, clear\n```\n\n```{stata}\nds, v(28)\n```\n\n```{stata}\ndi _N\n```\n\nWe can then run the IVW model using `mregger` with fixed effect standard errors.\n\n```{stata}\nmregger beta_outcome beta_exposure [aw=1/(se_outcome^2)], ivw fe\n```\n\nWe then fit the MR-Egger, median, and modal based estimators.\n\n```{stata}\nmregger beta_outcome beta_exposure [aw=1/(se_outcome^2)]\n```\n\n```{stata}\nmrmedian beta_outcome se_outcome beta_exposure se_exposure, weighted\n```\n\n```{stata}\nmrmodal beta_outcome se_outcome beta_exposure se_exposure, weighted\n```\n\nAnd we could continue with additional Stata code (or indeed R code) as we like.\nTo render your R Markdown file, either; open it in RStudio and click the Knit button in the toolbar of the Source code window, or run\nrmarkdown::render('myanalysis.Rmd')\nor to render a Quarto file run the following in your Terminal\nquarto render myanalysis.qmd\n\n\n\n\n\nHemani, Gibran, Jie Zheng, Benjamin Elsworth, Kaitlin H Wade, Valeriia Haberland, Denis Baird, Charles Laurin, et al. 2018. “The MR-Base platform supports systematic causal inference across the human phenome.” eLife 7: e34408. https://doi.org/10.7554/eLife.34408."
+ "text": "This example shows how to run R and Stata code within the same R Markdown (.Rmd) or Quarto (.qmd) file using the Statamarkdown R package. More information about this package is available here and here. To install this package run the following in R.\ninstall.packages(\"Statamarkdown\")\nNote when writing our Stata code chunks we need to be careful when we specify the collectcode=TRUE code chunk option, because each Stata code chunk is run as a separate batch job. For example, we include this chunk option in a chunk which reads in a dataset which we wish to use in subsequent chunks.\nUsing R and Stata code in the same script means that we can use the functions provided by the TwoSampleMR package to obtain data from the OpenGWAS API, which is the successor to MR-Base (Hemani et al. 2018).\nThe OpenGWAS API requires authentication. You must place an OPENGWAS_JWT token (by creating a free account on https://api.opengwas.io/profile/) in your .Renviron file before running the code below. See the ieugwasr website for more information.\nNext we install the other required packages in R.\ninstall.packages(\n \"TwoSampleMR\",\n repos = c(\n \"https://mrcieu.r-universe.dev\",\n \"https://cloud.r-project.org\"\n ),\n dependencies = TRUE\n)\ninstall.packages(\"foreign\")\n\n\n\nSave the following code chunk as an .Rmd or .qmd file, e.g. myanalysis.Rmd.\n---\ntitle: Using mrrobust in an R Markdown or Quarto document\n---\n\n## Extracting data from MR-Base\n\nWe will be running the script from the MR-Base paper \n([Hemani et al., 2018](https://doi.org/10.7554/eLife.34408)).\nThe R code we will use is from\n[here](https://raw.githubusercontent.com/explodecomputer/mr-base-methods-paper/master/scripts/ldl-chd.R).\n\nWe load the packages into our R session.\nNote that the **foreign** package provides the `write.dta()` function\nwhich we will use to save the data in Stata format.\n\n```{r}\nlibrary(TwoSampleMR)\nlibrary(MRInstruments)\nlibrary(foreign)\nlibrary(Statamarkdown)\n```\n\nWe can access the data using the **MRInstruments** package.\n\n```{r}\ndata(gwas_catalog)\n\n# Get published SNPs for LDL cholesterol\nldl_snps <-\n subset(gwas_catalog,\n grepl(\"LDL choles\", Phenotype) & Author == \"Willer CJ\")$SNP\n\n# Extract from GLGC dataset\nexposure <-\n convert_outcome_to_exposure(\n extract_outcome_data(ldl_snps, \"ieu-a-300\"))\n\n# Get outcome data from Cardiogram 2015\noutcome <- extract_outcome_data(exposure$SNP, \"ieu-a-7\")\n\n# Harmonise exposure and outcome datasets\n# Assume alleles are on the forward strand\ndat <- harmonise_data(exposure, outcome, action = 1)\n```\n\nAt this point we have our harmonised genotype-exposure and genotype-outcome\nassociation data saved in an object in our R session called `dat`.\n\nThe next two code chunks perform the analysis in R.\n\n```{r}\n# Perform MR analysis\nmr(dat)\nmr_heterogeneity(dat)\ndat$exposure <- \"LDL cholesterol\"\ndat$outcome <- \"Coronary heart disease\"\n\n# Label outliers and create plots\ndat$labels <- dat$SNP\ndat$labels[! dat$SNP %in% c(\"rs11065987\", \"rs1250229\", \"rs4530754\")] <- NA\n```\n\nTo proceed in Stata we can save our `dat` object as a Stata dataset\n\n```{r}\nwrite.dta(dat, file = \"dat.dta\")\n```\n\n## Analysis in Stata using the mrrobust package\n\nAt this point in Stata install the **mrrobust** package and its\ndependencies if you have not done so previously.\n\n```stata\nnet install github, from(\"https://haghish.github.io/github/\")\ngitget mrrobust\n```\n\nWe now read the dataset into Stata and look at the variable names\nand the number of observations.\n\n```{stata, collectcode=TRUE}\nqui use dat, clear\n```\n\n```{stata}\nds, v(28)\n```\n\n```{stata}\ndi _N\n```\n\nWe can then run the IVW model using `mregger` with fixed effect standard errors.\n\n```{stata}\nmregger beta_outcome beta_exposure [aw=1/(se_outcome^2)], ivw fe\n```\n\nWe then fit the MR-Egger, median, and modal based estimators.\n\n```{stata}\nmregger beta_outcome beta_exposure [aw=1/(se_outcome^2)]\n```\n\n```{stata}\nmrmedian beta_outcome se_outcome beta_exposure se_exposure, weighted\n```\n\n```{stata}\nmrmodal beta_outcome se_outcome beta_exposure se_exposure, weighted\n```\n\nAnd we could continue with additional Stata code (or indeed R code) as we like.\nTo render your R Markdown file, either; open it in RStudio and click the Knit button in the toolbar of the Source code window, or run\nrmarkdown::render('myanalysis.Rmd')\nor to render a Quarto file run the following in your Terminal\nquarto render myanalysis.qmd\n\n\n\n\n\nHemani, Gibran, Jie Zheng, Benjamin Elsworth, Kaitlin H Wade, Valeriia Haberland, Denis Baird, Charles Laurin, et al. 2018. “The MR-Base platform supports systematic causal inference across the human phenome.” eLife 7: e34408. https://doi.org/10.7554/eLife.34408."
},
{
"objectID": "examples/rmarkdown-call-stata-example/index.html#introduction",
"href": "examples/rmarkdown-call-stata-example/index.html#introduction",
"title": "How to include mrrobust Stata code in an R Markdown or Quarto document using the Statamarkdown R package",
"section": "",
- "text": "This example shows how to run R and Stata code within the same R Markdown (.Rmd) or Quarto (.qmd) file using the Statamarkdown R package. More information about this package is available here and here. To install this package run the following in R.\ninstall.packages(\"Statamarkdown\")\nNote when writing our Stata code chunks we need to be careful when we specify the collectcode=TRUE code chunk option, because each Stata code chunk is run as a separate batch job. For example, we include this chunk option in a chunk which reads in a dataset which we wish to use in subsequent chunks.\nUsing R and Stata code in the same script means that we can use the functions provided by the TwoSampleMR package to obtain data from the OpenGWAS API, which is the successor to MR-Base (Hemani et al. 2018).\nThe OpenGWAS API requires authentication. You must place an OPENGWAS_JWT token (by creating a free account on https://api.opengwas.io/profile/) in your .Renviron file before running the code below. See the ieugwasr website for more information.\nNext we install the other required packages in R.\ninstall.packages(\n \"TwoSampleMR\",\n repos = c(\n \"https://mrcieu.r-universe.dev\",\n \"https://cloud.r-project.org\"\n )\n)\ninstall.packages(\"foreign\")"
+ "text": "This example shows how to run R and Stata code within the same R Markdown (.Rmd) or Quarto (.qmd) file using the Statamarkdown R package. More information about this package is available here and here. To install this package run the following in R.\ninstall.packages(\"Statamarkdown\")\nNote when writing our Stata code chunks we need to be careful when we specify the collectcode=TRUE code chunk option, because each Stata code chunk is run as a separate batch job. For example, we include this chunk option in a chunk which reads in a dataset which we wish to use in subsequent chunks.\nUsing R and Stata code in the same script means that we can use the functions provided by the TwoSampleMR package to obtain data from the OpenGWAS API, which is the successor to MR-Base (Hemani et al. 2018).\nThe OpenGWAS API requires authentication. You must place an OPENGWAS_JWT token (by creating a free account on https://api.opengwas.io/profile/) in your .Renviron file before running the code below. See the ieugwasr website for more information.\nNext we install the other required packages in R.\ninstall.packages(\n \"TwoSampleMR\",\n repos = c(\n \"https://mrcieu.r-universe.dev\",\n \"https://cloud.r-project.org\"\n ),\n dependencies = TRUE\n)\ninstall.packages(\"foreign\")"
},
{
"objectID": "examples/rmarkdown-call-stata-example/index.html#example-r-markdown-or-quarto-document",
@@ -319,7 +319,7 @@
"href": "examples/spiller-ije-2018-examples/index.html#mode",
"title": "Examples from our IJE paper",
"section": "Stata output using the mode-based estimator using mrrobust: BMI-Serum Glucose",
- "text": "Stata output using the mode-based estimator using mrrobust: BMI-Serum Glucose\nUsing the mrmodalplot command, modal estimates are calculated using bandwidths of 0.25, 0.5, and 1 respectively. This command also produces three overlaid density plots for each value, as shown in the Figure.\n\nmrmodalplot betaoutcome seoutcome betaexposure seexposure, lc(gs10 gs5 gs0) seed(300818)\nqui gr export mrmodalplot-bmi.svg, width(600) replace\n\n Number of genotypes = 79\n Replications = 1000\n Phi = .25\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .0374507 .0424036 0.88 0.377 -.0456588 .1205602\n------------------------------------------------------------------------------\n\n Number of genotypes = 79\n Replications = 1000\n Phi = .5\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .0416424 .0369758 1.13 0.260 -.0308289 .1141137\n------------------------------------------------------------------------------\n\n Number of genotypes = 79\n Replications = 1000\n Phi = 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .0431816 .0281684 1.53 0.125 -.0120274 .0983906\n------------------------------------------------------------------------------\n\n\n\n\n\n\n\nDensities of the IV estimates using different values of phi."
+ "text": "Stata output using the mode-based estimator using mrrobust: BMI-Serum Glucose\nUsing the mrmodalplot command, modal estimates are calculated using bandwidths of 0.25, 0.5, and 1 respectively. This command also produces three overlaid density plots for each value, as shown in the Figure.\n\nmrmodalplot betaoutcome seoutcome betaexposure seexposure, lc(gs10 gs5 gs0) seed(300818) legend(pos(6))\nqui gr export mrmodalplot-bmi.svg, width(600) replace\n\n Number of genotypes = 79\n Replications = 1000\n Phi = .25\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .0374507 .0424036 0.88 0.377 -.0456588 .1205602\n------------------------------------------------------------------------------\n\n Number of genotypes = 79\n Replications = 1000\n Phi = .5\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .0416424 .0369758 1.13 0.260 -.0308289 .1141137\n------------------------------------------------------------------------------\n\n Number of genotypes = 79\n Replications = 1000\n Phi = 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .0431816 .0281684 1.53 0.125 -.0120274 .0983906\n------------------------------------------------------------------------------\n\n\n\n\n\n\n\nDensities of the IV estimates using different values of phi."
},
{
"objectID": "examples/spiller-ije-2018-examples/index.html#height",
@@ -333,7 +333,7 @@
"href": "examples/spiller-ije-2018-examples/index.html#height-mode",
"title": "Examples from our IJE paper",
"section": "Stata output using the mode-based estimator using mrrobust: Height-Serum Glucose",
- "text": "Stata output using the mode-based estimator using mrrobust: Height-Serum Glucose\n\nmrmodalplot betaoutcome seoutcome betaexposure seexposure, lc(gs10 gs5 gs0) seed(300818)\nqui gr export mrmodalplot-height.svg, width(600) replace\n\n Number of genotypes = 367\n Replications = 1000\n Phi = .25\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .0061368 .0245472 0.25 0.803 -.0419748 .0542484\n------------------------------------------------------------------------------\n\n Number of genotypes = 367\n Replications = 1000\n Phi = .5\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .0015595 .0212232 0.07 0.941 -.0400372 .0431561\n------------------------------------------------------------------------------\n\n Number of genotypes = 367\n Replications = 1000\n Phi = 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | -.0054772 .0149074 -0.37 0.713 -.0346952 .0237408\n------------------------------------------------------------------------------\n\n\n\n\n\n\n\nDensities of the IV estimates using different values of phi."
+ "text": "Stata output using the mode-based estimator using mrrobust: Height-Serum Glucose\n\nmrmodalplot betaoutcome seoutcome betaexposure seexposure, lc(gs10 gs5 gs0) seed(300818) legend(pos(6))\nqui gr export mrmodalplot-height.svg, width(600) replace\n\n Number of genotypes = 367\n Replications = 1000\n Phi = .25\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .0061368 .0245472 0.25 0.803 -.0419748 .0542484\n------------------------------------------------------------------------------\n\n Number of genotypes = 367\n Replications = 1000\n Phi = .5\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .0015595 .0212232 0.07 0.941 -.0400372 .0431561\n------------------------------------------------------------------------------\n\n Number of genotypes = 367\n Replications = 1000\n Phi = 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | -.0054772 .0149074 -0.37 0.713 -.0346952 .0237408\n------------------------------------------------------------------------------\n\n\n\n\n\n\n\nDensities of the IV estimates using different values of phi."
},
{
"objectID": "examples/spiller-ije-2018-examples/index.html#references",
diff --git a/site/_freeze/examples/markstat-call-R-example/index/execute-results/html.json b/site/_freeze/examples/markstat-call-R-example/index/execute-results/html.json
new file mode 100644
index 0000000..2fbd615
--- /dev/null
+++ b/site/_freeze/examples/markstat-call-R-example/index/execute-results/html.json
@@ -0,0 +1,15 @@
+{
+ "hash": "f35ae37f8cc5a992a2d046918ae8d7d4",
+ "result": {
+ "engine": "knitr",
+ "markdown": "---\nengine: knitr\n---\n\n\n\n\n# Access the OpenGWAS API from a Stata do-file or Stata Markdown script {#title}\n\n## Introduction\n\nThis example shows how to run R and Stata code within the same Stata Markdown (`.stmd`) script. \nThe general approach is detailed on the Stata Markdown website \n[here](https://grodri.github.io/markstat/quantiles) and \n[here](https://grodri.github.io/markstat/gettingStarted#R).\n\nThis means that we can use the functions provided by the \n[**TwoSampleMR**](https://github.com/MRCIEU/TwoSampleMR) package to obtain data from the [OpenGWAS API}(https://api.opengwas.io/) which is the successor to [MR-Base](https://www.mrbase.org/) [@mrbase].\n\nThe OpenGWAS API requires authentication. You must place an `OPENGWAS_JWT` token (by creating a free account on ) in your _.Renviron_ file before running the code below. See the [**ieugwasr** website](https://mrcieu.github.io/ieugwasr/articles/guide.html#authentication) for more information.\n\nBefore you start please install the following two Stata packages from the SSC archive, so in Stata \nissue the following commands (I have commented them out because I have already installed them).\n\n```stata\nssc install whereis\nssc install markstat\n```\n\n## Example Stata Markdown document\n\nThe following is the example Stata Markdown document.\n\n\n\n\n\n````{.markdown}\n---\ntitle: Using mrrobust in a Markstat document example\n---\n\nWe first need to register the R executable with Stata.\n\n```s\nif c(os) == \"Windows\" local rpath \"C:\\\\Program Files\\\\R\\\\R-4.4.1\\\\bin\\\\x64\\\\R.exe\"\nelse if c(os) == \"Unix\" local rpath \"/usr/bin/R\"\nelse local rpath \"/usr/local/bin/R\"\nwhereis R \"`rpath'\"\n```\n\nNext we have an R code chunk in which we install the required packages in R.\n\n```r\ninstall.packages(\n \"TwoSampleMR\",\n repos = c(\n \"https://mrcieu.r-universe.dev\",\n \"https://cloud.r-project.org\"\n ),\n dependencies = TRUE\n)\n```\n\n## Extracting data from the OpenGWAS API\n\nWe will be running the script from the MR-Base paper \n([Hemani et al., 2018](https://doi.org/10.7554/eLife.34408)). \nThe R code we will use is from \n[here](https://raw.githubusercontent.com/explodecomputer/mr-base-methods-paper/master/scripts/ldl-chd.R).\n\nFirst, we load the packages into our R session.\nNote that the **foreign** package provides the \n`write.dta()` function which we will use to save the data in Stata format.\n\n```r\nlibrary(TwoSampleMR)\nlibrary(MRInstruments)\nlibrary(foreign)\n```\n\nOur edited version of the code starts by reading in some code\nto generate a set of plots in R.\n\n```r\nsource(\"mrplots.R\")\n```\n\nWe can access the data using the **MRInstruments** package.\n\n```r\ndata(gwas_catalog)\n\n# Get published SNPs for LDL cholesterol\nldl_snps <- \n subset(gwas_catalog, \n grepl(\"LDL choles\", Phenotype) & Author == \"Willer CJ\")$SNP\n\n# Extract from GLGC dataset\nexposure <- \n convert_outcome_to_exposure(\n extract_outcome_data(ldl_snps, \"ieu-a-300\"))\n\n# Get outcome data from Cardiogram 2015\noutcome <- extract_outcome_data(exposure$SNP, \"ieu-a-7\")\n\n# Harmonise exposure and outcome datasets\n# Assume alleles are on the forward strand\ndat <- harmonise_data(exposure, outcome, action = 1)\n```\n\nAt this point we have our harmonised genotype-exposure and \ngenotype-outcome association data saved in an object in our \nR session called `dat`.\n\nThe next two code chunks perform the analysis in R.\n\n```r\n# Perform MR\nmr(dat)\nmr_heterogeneity(dat)\ndat$exposure <- \"LDL cholesterol\"\ndat$outcome <- \"Coronary heart disease\"\n\n# Label outliers and create plots\ndat$labels <- dat$SNP\ndat$labels[! dat$SNP %in% c(\"rs11065987\", \"rs1250229\", \"rs4530754\")] <- NA\n```\n\n```r\npng(\"ldl-chd.png\", width=1000, height=1000)\nmr_plots(dat)\ndev.off()\n```\n\n![Plots generated by the TwoSampleMR R package.](ldl-chd.png)\n\nWe now save our `dat` object as a Stata dataset.\n\n```r\nwrite.dta(dat, file = \"dat.dta\")\n```\n\n## Performing the analysis using mrrobust in Stata\n\nWe now switch from using R code chunks to Stata code chunks.\nWe read the data into Stata and list the variable names\n(note any `.` in the colnames of `dat` have been replaced with `_`).\n\n```s\nuse dat, clear\nds, v(28)\ndi _N\n```\n\nWe can then run the IVW model using `mregger` with multiplicative\nstandard errors.\n\n```s\nmregger beta_outcome beta_exposure [aw=1/(se_outcome^2)], ivw\n```\n\nIt is helpful to view the forest plot of genotype specific IV estimates.\n\n```s\nmrforest beta_outcome se_outcome beta_exposure se_exposure, ivid(SNP) ///\n\txlabel(-3,-2,-1,0,1,2,3)\ngraph export ldl-chd-mrforest.svg, width(600) replace\n```\n\n![Forest plot of genotype specific IV estimates.](ldl-chd-mrforest.svg)\n\nWe can visualise this model with `mreggerplot`.\n\n```s\nmreggerplot beta_outcome se_outcome beta_exposure se_exposure\ngraph export ldl-chd-mreggerplot.svg, width(600) replace\n```\n\n![Plot of the MR-Egger model.](ldl-chd-mreggerplot.svg)\n\nWe then fit the MR-Egger, median, and modal based estimators.\n\n```s\nmregger beta_outcome beta_exposure [aw=1/(se_outcome^2)]\n```\n\n```s\nmrmedian beta_outcome se_outcome beta_exposure se_exposure, weighted\n```\n\n```s\nmrmodal beta_outcome se_outcome beta_exposure se_exposure, weighted\n```\n````\n\n\n\n\nAnd we could continue with additional Stata code (or indeed R code) as we liked.\n\nNote to run this `.stmd` file in Stata we do so with the following command (specifying additional \noptions as required, see `help markstat` for more information).\n\n```stata\nmarkstat using markstat-call-R-example\n```\n\n## References\n\n::: {#refs}\n:::\n",
+ "supporting": [],
+ "filters": [
+ "rmarkdown/pagebreak.lua"
+ ],
+ "includes": {},
+ "engineDependencies": {},
+ "preserve": {},
+ "postProcess": true
+ }
+}
\ No newline at end of file
diff --git a/site/_freeze/examples/mrrobust-examples/index/execute-results/html.json b/site/_freeze/examples/mrrobust-examples/index/execute-results/html.json
new file mode 100644
index 0000000..d46022c
--- /dev/null
+++ b/site/_freeze/examples/mrrobust-examples/index/execute-results/html.json
@@ -0,0 +1,17 @@
+{
+ "hash": "bcd2d14dba6ec4a4ca9dece871580db4",
+ "result": {
+ "engine": "knitr",
+ "markdown": "---\ntitle: Examples from helpfiles in the mrrobust package\n---\n\n\n\n\n\n\n\n\n\n\n## Install the mrrobust package\n\n```stata\nnet install github, from(\"https://haghish.github.io/github/\")\ngitget mrrobust\n```\n\n## Read in example data\n\nRead in example data from @do-natgen-2013.\n\n\n\n\n::: {.cell layout-align=\"center\" collectcode='true'}\n\n```{.stata .cell-code}\nuse https://raw.github.com/remlapmot/mrrobust/master/dodata, clear\n```\n:::\n\n\n\n\nSelect observations (*p*-value with exposure < 10^-8^).\n\n\n\n\n::: {.cell layout-align=\"center\" collectcode='true'}\n\n```{.stata .cell-code}\ngen byte sel1 = (ldlcp2 < 1e-8)\n```\n:::\n\n\n\n\n## mrforest examples\n\nForest plot of genotype specific IV estimates and IVW and MR-Egger estimates, \nlabelling the genotypes with their RSID.\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmrforest chdbeta chdse ldlcbeta ldlcse if sel1==1, ivid(rsid) ///\n xlabel(-5,-4,-3,-2,-1,0,1,2,3,4,5)\nqui gr export mrforest.svg, width(600) replace\n```\n:::\n\n::: {.cell layout-align=\"center\"}\n::: {.cell-output-display}\n![Example forest plot of genotype specific IV estimates.](mrforest.svg){fig-align='center' fig-alt='Example forest plot of genotype specific IV estimates.'}\n:::\n:::\n\n\n\n\n## mregger examples\n\nUsing the data provided by @do-natgen-2013 \nrecreate from @bowden-genepi-2016 the Table 4, LDL-c \"All genetic variants\" estimates.\n\nIVW (with fixed effect standard errors, i.e. variance of residuals \n[residual variance] constrained to 1).\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmregger chdbeta ldlcbeta [aw=1/(chdse^2)] if sel1==1, ivw fe\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 73\n Residual standard error constrained at 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\nchdbeta |\n ldlcbeta | .4815055 .038221 12.60 0.000 .4065938 .5564173\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\nMR-Egger (with SEs using an unconstrained residual variance \n[multiplicative random effects]).\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmregger chdbeta ldlcbeta [aw=1/(chdse^2)] if sel1==1\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 73\n Residual standard error = 1.548\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\nchdbeta |\n slope | .6173131 .1034573 5.97 0.000 .4145405 .8200858\n _cons | -.0087706 .0054812 -1.60 0.110 -.0195136 .0019723\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\nMR-Egger reporting I^2^~GX~ statistic and heterogeneity Q-test.\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmregger chdbeta ldlcbeta [aw=1/(chdse^2)] if sel1==1, gxse(ldlcse) heterogi\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Q_GX statistic (weighted) = 3454.26\n I^2_GX statistic (weighted) = 97.92%\n Number of genotypes = 73\n Residual standard error = 1.548\n Ruecker's Q for heterogeneity; chi2(71) = 170.11 (p = 0.0000)\n I-squared statistic = 58.3% (95% CI 45.8%, 67.8%)\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\nchdbeta |\n slope | .6173131 .1034573 5.97 0.000 .4145405 .8200858\n _cons | -.0087706 .0054812 -1.60 0.110 -.0195136 .0019723\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\nMR-Egger using a t-distribution for inference (p-values) & CI limits.\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmregger chdbeta ldlcbeta [aw=1/(chdse^2)] if sel1==1, tdist\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 73\n Residual standard error = 1.548\n------------------------------------------------------------------------------\n | Coefficient Std. err. t P>|t| [95% conf. interval]\n-------------+----------------------------------------------------------------\nchdbeta |\n slope | .6173131 .1034573 5.97 0.000 .4110251 .8236012\n _cons | -.0087706 .0054812 -1.60 0.114 -.0196998 .0021585\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\nMR-Egger using the radial formulation.\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmregger chdbeta ldlcbeta [aw=1/(chdse^2)] if sel1==1, radial\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 73\n Residual standard error = 1.547\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\nradialGD |\n radialGP | .642582 .1157871 5.55 0.000 .4156434 .8695205\n _cons | -.5737301 .3545658 -1.62 0.106 -1.268666 .1212062\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\nMR-Egger using the radial formulation and reporting heterogeneity (Rucker's) Q-test.\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmregger chdbeta ldlcbeta [aw=1/(chdse^2)] if sel1==1, radial heterogi\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 73\n Residual standard error = 1.547\n Ruecker's Q for heterogeneity; chi2(71) = 169.98 (p = 0.0000)\n I-squared statistic = 58.2% (95% CI 45.8%, 67.8%)\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\nradialGD |\n radialGP | .642582 .1157871 5.55 0.000 .4156434 .8695205\n _cons | -.5737301 .3545658 -1.62 0.106 -1.268666 .1212062\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\n## mreggersimex examples\n\nSIMEX suppressing bootstrapped SEs (for speed - remove the `noboot` option to obtain SEs).\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmreggersimex chdbeta ldlcbeta [aw=1/chdse^2] if sel1==1, gxse(ldlcse) seed(12345) noboot\nqui gr export mreggersimex-plot.svg, width(600) replace\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 73\n Bootstrap replications = 0\n Simulation replications = 50\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n slope | .6256194 . . . . .\n _cons | -.0089987 . . . . .\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n::: {.cell layout-align=\"center\"}\n::: {.cell-output-display}\n![SIMEX plots for the MR-Egger model.](mreggersimex-plot.svg){fig-align='center' fig-alt='SIMEX plots for the MR-Egger model.'}\n:::\n:::\n\n\n\n\n## mreggerplot examples\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmreggerplot chdbeta chdse ldlcbeta ldlcse if sel1==1\nqui gr export mreggerplot.svg, width(600) replace\n```\n:::\n\n::: {.cell layout-align=\"center\"}\n::: {.cell-output-display}\n![Scatter plot showing the genotype summary level data points and the fitted MR-Egger model.](mreggerplot.svg){fig-align='center' fig-alt='Scatter plot showing the genotype summary level data points and the fitted MR-Egger model.'}\n:::\n:::\n\n\n\n\n## mrmedian examples\n\nWeighted median estimator.\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmrmedian chdbeta chdse ldlcbeta ldlcse if sel1==1, weighted\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 73\n Replications = 1000\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4582573 .0633137 7.24 0.000 .3341648 .5823499\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\n## mrmodal examples\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmrmodalplot chdbeta chdse ldlcbeta ldlcse if sel1==1, seed(12345) legend(pos(6))\nqui gr export mrmodalplot.svg, width(600) replace\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 73\n Replications = 1000\n Phi = .25\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4198713 .2267297 1.85 0.064 -.0245107 .8642533\n------------------------------------------------------------------------------\n\n Number of genotypes = 73\n Replications = 1000\n Phi = .5\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4218667 .1981169 2.13 0.033 .0335647 .8101688\n------------------------------------------------------------------------------\n\n Number of genotypes = 73\n Replications = 1000\n Phi = 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4917353 .1356432 3.63 0.000 .2258796 .757591\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n::: {.cell layout-align=\"center\"}\n::: {.cell-output-display}\n![Densities of the IV estimates using different values of the phi parameter.](mrmodalplot.svg){fig-align='center' fig-alt='Densities of the IV estimates using different values of the phi parameter.'}\n:::\n:::\n\n\n\n\nSimple mode estimator.\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmrmodal chdbeta chdse ldlcbeta ldlcse if sel1==1\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 73\n Replications = 1000\n Phi = 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4917353 .1276278 3.85 0.000 .2415894 .7418812\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\nWeighted mode estimator.\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmrmodal chdbeta chdse ldlcbeta ldlcse if sel1==1, weighted\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 73\n Replications = 1000\n Phi = 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4789702 .0663145 7.22 0.000 .3489963 .6089441\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\nSimple mode estimator with NOME assumption.\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmrmodal chdbeta chdse ldlcbeta ldlcse if sel1==1, nome\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 73\n Replications = 1000\n Phi = 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4917353 .1266936 3.88 0.000 .2434204 .7400501\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\n## mrfunnel examples\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmrfunnel chdbeta chdse ldlcbeta ldlcse if sel1==1, xlrange(0 10) legend(pos(6))\nqui gr export mrfunnel.svg, width(600) replace\n```\n:::\n\n::: {.cell layout-align=\"center\"}\n::: {.cell-output-display}\n![Example funnel plot.](mrfunnel.svg){fig-align='center' fig-alt='Example funnel plot.'}\n:::\n:::\n\n\n\n\n## Leave one out analysis\n\nCreate a smaller subset of data.\n\n\n\n\n::: {.cell layout-align=\"center\" collectcode='true'}\n\n```{.stata .cell-code}\ngen byte sel2 = (ldlcp2 < 1e-25)\n```\n:::\n\n\n\n\nPerform leave one out analysis using the IVW estimator\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmrleaveoneout chdbeta ldlcbeta if sel2==1, gyse(chdse) genotype(rsid) noprint\nqui gr export mrleaveoneout-plot-01.svg, width(600) replace\n```\n:::\n\n::: {.cell layout-align=\"center\"}\n::: {.cell-output-display}\n![Plot showing leave one (genotype) out at a time analysis for the IVW estimate.](mrleaveoneout-plot-01.svg){fig-align='center' fig-alt='Plot showing leave one (genotype) out at a time analysis for the IVW estimate.'}\n:::\n:::\n\n\n\n\nPerform leave one out analysis using MVMR collecting the estimate for LDL-c.\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmrleaveoneout chdbeta ldlcbeta hdlcbeta tgbeta if sel2==1, ///\n method(mvmr) gyse(chdse) genotype(rsid) noprint\nqui gr export mrleaveoneout-plot-02.svg, width(600) replace\n```\n:::\n\n::: {.cell layout-align=\"center\"}\n::: {.cell-output-display}\n![Plot showing leave one (genotype) out at a time analysis for the MVMR estimate.](mrleaveoneout-plot-02.svg){fig-align='center' fig-alt='Plot showing leave one (genotype) out at a time analysis for the MVMR estimate.'}\n:::\n:::\n\n\n\n\n## References\n\n::: {#refs}\n:::\n",
+ "supporting": [
+ "index_files"
+ ],
+ "filters": [
+ "rmarkdown/pagebreak.lua"
+ ],
+ "includes": {},
+ "engineDependencies": {},
+ "preserve": {},
+ "postProcess": true
+ }
+}
\ No newline at end of file
diff --git a/site/_freeze/examples/mvcommands-example/index/execute-results/html.json b/site/_freeze/examples/mvcommands-example/index/execute-results/html.json
new file mode 100644
index 0000000..8aa0de1
--- /dev/null
+++ b/site/_freeze/examples/mvcommands-example/index/execute-results/html.json
@@ -0,0 +1,15 @@
+{
+ "hash": "6279b4154c55c0b3f983ac1d380a1c0a",
+ "result": {
+ "engine": "knitr",
+ "markdown": "---\n---\n\n\n\n\n\n\n\n\n\n\n# Example demonstrating MVMR commands\n\nRead in the @do-natgen-2013 example dataset.\n\n\n\n\n::: {.cell layout-align=\"center\" collectcode='true'}\n\n```{.stata .cell-code}\nuse https://raw.github.com/remlapmot/mrrobust/master/dodata, clear\n```\n:::\n\n\n\n\nSelect observations (p-value with LDL-C < 10-8)\n\n\n\n\n::: {.cell layout-align=\"center\" collectcode='true'}\n\n```{.stata .cell-code}\ngen byte sel1 = (ldlcp2 < 1e-8)\n```\n:::\n\n\n\n\n## MV-IVW\n\nFit the multivariable inverse-variance weighted (MV-IVW a.k.a. multivariable \nMendelian randomization, MVMR) estimator with phenotypes LDL-c and HDL-c [@burgess-aje-2015].\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmrmvivw chdbeta ldlcbeta hdlcbeta [aw=1/(chdse^2)] if sel1==1\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 73\n Number of phenotypes = 2\n Standard errors: Random effect\n Residual standard error = 1.514\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\nchdbeta |\n ldlcbeta | .4670719 .0581901 8.03 0.000 .3530214 .5811224\n hdlcbeta | -.2930048 .1211822 -2.42 0.016 -.5305175 -.0554921\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\nAdditionally include a third phenotype -- triglycerides.\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmrmvivw chdbeta ldlcbeta hdlcbeta tgbeta [aw=1/(chdse^2)] if sel1==1\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 73\n Number of phenotypes = 3\n Standard errors: Random effect\n Residual standard error = 1.490\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\nchdbeta |\n ldlcbeta | .42862 .0609661 7.03 0.000 .3091286 .5481113\n hdlcbeta | -.1941989 .1308289 -1.48 0.138 -.4506189 .0622211\n tgbeta | .2260456 .1232828 1.83 0.067 -.0155842 .4676755\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\nReport the QA statistic for instrument validity and the conditional \nF-statistics for instrument strength for each phenotype [@sanderson-ije-2019; \n@sanderson-statsmed-2021].\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmrmvivw chdbeta ldlcbeta hdlcbeta tgbeta [aw=1/(chdse^2)] if sel1==1, gxse(ldlcse hdlcse tgse)\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 73\n Number of phenotypes = 3\n Standard errors: Random effect\n Residual standard error = 1.490\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\nchdbeta |\n ldlcbeta | .42862 .0609661 7.03 0.000 .3091286 .5481113\n hdlcbeta | -.1941989 .1308289 -1.48 0.138 -.4506189 .0622211\n tgbeta | .2260456 .1232828 1.83 0.067 -.0155842 .4676755\n------------------------------------------------------------------------------\n Q_A statistic for instrument validity; chi2(70) = 152.88 (p = 0.0000)\n Conditional F-statistics for instrument strength:\n F_x1 = 130.31 (ldlcbeta)\n F_x2 = 36.29 (hdlcbeta)\n F_x3 = 40.44 (tgbeta)\n```\n\n\n:::\n:::\n\n\n\n\n## MVMR-Egger\n\nFit MVMR-Egger regression [@rees-statsmed-2017], by default orienting the model \nto the first phenotype in the main varlist.\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmrmvegger chdbeta ldlcbeta hdlcbeta tgbeta [aw=1/(chdse^2)] if sel1==1\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n MVMR-Egger model oriented wrt: ldlcbeta\n Number of genotypes = 73\n Number of phenotypes = 3\n Residual standard error = 1.469\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\nchdbeta |\n ldlcbeta | .5672993 .1002611 5.66 0.000 .370791 .7638075\n hdlcbeta | -.1364113 .1332727 -1.02 0.306 -.3976209 .1247983\n tgbeta | .2739803 .1246927 2.20 0.028 .0295871 .5183735\n _cons | -.0093655 .0054187 -1.73 0.084 -.019986 .001255\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\nWe can also orient the model with respect to HDL-C instead of LDL-C.\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmrmvegger chdbeta ldlcbeta hdlcbeta tgbeta [aw=1/(chdse^2)] if sel1==1, orient(2)\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n MVMR-Egger model oriented wrt: hdlcbeta\n Number of genotypes = 73\n Number of phenotypes = 3\n Residual standard error = 1.501\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\nchdbeta |\n ldlcbeta | .4286398 .0614056 6.98 0.000 .308287 .5489926\n hdlcbeta | -.1989637 .1541909 -1.29 0.197 -.5011723 .1032449\n tgbeta | .2256794 .1243221 1.82 0.069 -.0179875 .4693463\n _cons | .0002155 .0036218 0.06 0.953 -.006883 .0073141\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\nOr we can orient the model with respect to triglycerides instead of LDL-C.\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmrmvegger chdbeta ldlcbeta hdlcbeta tgbeta [aw=1/(chdse^2)] if sel1==1, orient(3)\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n MVMR-Egger model oriented wrt: tgbeta\n Number of genotypes = 73\n Number of phenotypes = 3\n Residual standard error = 1.499\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\nchdbeta |\n ldlcbeta | .4203073 .0660026 6.37 0.000 .2909447 .54967\n hdlcbeta | -.1903089 .1321536 -1.44 0.150 -.4493252 .0687075\n tgbeta | .2065651 .1365427 1.51 0.130 -.0610537 .474184\n _cons | .0013499 .003951 0.34 0.733 -.0063939 .0090936\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\n## References\n\n::: {#refs}\n:::\n",
+ "supporting": [],
+ "filters": [
+ "rmarkdown/pagebreak.lua"
+ ],
+ "includes": {},
+ "engineDependencies": {},
+ "preserve": {},
+ "postProcess": true
+ }
+}
\ No newline at end of file
diff --git a/site/_freeze/examples/rmarkdown-call-stata-example/index/execute-results/html.json b/site/_freeze/examples/rmarkdown-call-stata-example/index/execute-results/html.json
new file mode 100644
index 0000000..c194fd6
--- /dev/null
+++ b/site/_freeze/examples/rmarkdown-call-stata-example/index/execute-results/html.json
@@ -0,0 +1,15 @@
+{
+ "hash": "8e44a4ece6e1ddb188b3f86a5751751a",
+ "result": {
+ "engine": "knitr",
+ "markdown": "---\nengine: knitr\n---\n\n\n\n\n# How to include mrrobust Stata code in an R Markdown or Quarto document using the Statamarkdown R package\n\n## Introduction\n\nThis example shows how to run R and Stata code within the same R Markdown (_.Rmd_) or Quarto (_.qmd_) file using the **Statamarkdown** R package. More information about this package is available [here](https://github.com/Hemken/Statamarkdown) and [here](https://www.ssc.wisc.edu/~hemken/Stataworkshops/Statamarkdown/stata-and-r-markdown.html). To install this package run the following in R.\n\n```r\ninstall.packages(\"Statamarkdown\")\n```\n\nNote when writing our Stata code chunks we need to be careful when we specify the `collectcode=TRUE` code chunk option, because each Stata code chunk is run as a separate batch job. For example, we include this chunk option in a chunk which reads in a dataset which we wish to use in subsequent chunks.\n\nUsing R and Stata code in the same script means that we can use the functions provided by the [**TwoSampleMR**](https://github.com/MRCIEU/TwoSampleMR) package to obtain data from the [OpenGWAS API](https://api.opengwas.io/), which is the successor to [MR-Base](https://www.mrbase.org/) [@mrbase].\n\nThe OpenGWAS API requires authentication. You must place an `OPENGWAS_JWT` token (by creating a free account on ) in your _.Renviron_ file before running the code below. See the [**ieugwasr** website](https://mrcieu.github.io/ieugwasr/articles/guide.html#authentication) for more information.\n\nNext we install the other required packages in R.\n\n```r\ninstall.packages(\n \"TwoSampleMR\",\n repos = c(\n \"https://mrcieu.r-universe.dev\",\n \"https://cloud.r-project.org\"\n ),\n dependencies = TRUE\n)\ninstall.packages(\"foreign\")\n```\n\n## Example R Markdown or Quarto document\n\nSave the following code chunk as an _.Rmd_ or _.qmd_ file, e.g. _myanalysis.Rmd_.\n\n\n\n\n\n````{.markdown}\n---\ntitle: Using mrrobust in an R Markdown or Quarto document\n---\n\n## Extracting data from MR-Base\n\nWe will be running the script from the MR-Base paper \n([Hemani et al., 2018](https://doi.org/10.7554/eLife.34408)).\nThe R code we will use is from\n[here](https://raw.githubusercontent.com/explodecomputer/mr-base-methods-paper/master/scripts/ldl-chd.R).\n\nWe load the packages into our R session.\nNote that the **foreign** package provides the `write.dta()` function\nwhich we will use to save the data in Stata format.\n\n```{r}\nlibrary(TwoSampleMR)\nlibrary(MRInstruments)\nlibrary(foreign)\nlibrary(Statamarkdown)\n```\n\nWe can access the data using the **MRInstruments** package.\n\n```{r}\ndata(gwas_catalog)\n\n# Get published SNPs for LDL cholesterol\nldl_snps <-\n subset(gwas_catalog,\n grepl(\"LDL choles\", Phenotype) & Author == \"Willer CJ\")$SNP\n\n# Extract from GLGC dataset\nexposure <-\n convert_outcome_to_exposure(\n extract_outcome_data(ldl_snps, \"ieu-a-300\"))\n\n# Get outcome data from Cardiogram 2015\noutcome <- extract_outcome_data(exposure$SNP, \"ieu-a-7\")\n\n# Harmonise exposure and outcome datasets\n# Assume alleles are on the forward strand\ndat <- harmonise_data(exposure, outcome, action = 1)\n```\n\nAt this point we have our harmonised genotype-exposure and genotype-outcome\nassociation data saved in an object in our R session called `dat`.\n\nThe next two code chunks perform the analysis in R.\n\n```{r}\n# Perform MR analysis\nmr(dat)\nmr_heterogeneity(dat)\ndat$exposure <- \"LDL cholesterol\"\ndat$outcome <- \"Coronary heart disease\"\n\n# Label outliers and create plots\ndat$labels <- dat$SNP\ndat$labels[! dat$SNP %in% c(\"rs11065987\", \"rs1250229\", \"rs4530754\")] <- NA\n```\n\nTo proceed in Stata we can save our `dat` object as a Stata dataset\n\n```{r}\nwrite.dta(dat, file = \"dat.dta\")\n```\n\n## Analysis in Stata using the mrrobust package\n\nAt this point in Stata install the **mrrobust** package and its\ndependencies if you have not done so previously.\n\n```stata\nnet install github, from(\"https://haghish.github.io/github/\")\ngitget mrrobust\n```\n\nWe now read the dataset into Stata and look at the variable names\nand the number of observations.\n\n```{stata, collectcode=TRUE}\nqui use dat, clear\n```\n\n```{stata}\nds, v(28)\n```\n\n```{stata}\ndi _N\n```\n\nWe can then run the IVW model using `mregger` with fixed effect standard errors.\n\n```{stata}\nmregger beta_outcome beta_exposure [aw=1/(se_outcome^2)], ivw fe\n```\n\nWe then fit the MR-Egger, median, and modal based estimators.\n\n```{stata}\nmregger beta_outcome beta_exposure [aw=1/(se_outcome^2)]\n```\n\n```{stata}\nmrmedian beta_outcome se_outcome beta_exposure se_exposure, weighted\n```\n\n```{stata}\nmrmodal beta_outcome se_outcome beta_exposure se_exposure, weighted\n```\n\nAnd we could continue with additional Stata code (or indeed R code) as we like.\n````\n\n\n\n\nTo render your R Markdown file, either; open it in RStudio and click the `Knit` button in the toolbar of the Source code window, or run\n\n```r\nrmarkdown::render('myanalysis.Rmd')\n```\n\nor to render a Quarto file run the following in your Terminal\n\n```sh\nquarto render myanalysis.qmd\n```\n\n## References\n\n::: {#refs}\n:::\n",
+ "supporting": [],
+ "filters": [
+ "rmarkdown/pagebreak.lua"
+ ],
+ "includes": {},
+ "engineDependencies": {},
+ "preserve": {},
+ "postProcess": true
+ }
+}
\ No newline at end of file
diff --git a/site/_freeze/examples/save-estimates/index/execute-results/html.json b/site/_freeze/examples/save-estimates/index/execute-results/html.json
new file mode 100644
index 0000000..9d5b08a
--- /dev/null
+++ b/site/_freeze/examples/save-estimates/index/execute-results/html.json
@@ -0,0 +1,15 @@
+{
+ "hash": "dc3591ba19561ad0bbaf9ca6feab1cfc",
+ "result": {
+ "engine": "knitr",
+ "markdown": "---\n---\n\n\n\n\n\n\n\n\n\n\n# How to collect and export results\n\nThis example shows how to conveniently save and export your estimates using the `r(table)` matrix \nthat is now returned by each command.\n\n## Setup example data\n\n\n\n\n::: {.cell layout-align=\"center\" collectcode='true'}\n\n```{.stata .cell-code}\nuse https://raw.github.com/remlapmot/mrrobust/master/dodata, clear\n```\n:::\n\n\n\n\nSelect observations (p-value with exposure < 10^-8^)\n\n\n\n\n::: {.cell layout-align=\"center\" collectcode='true'}\n\n```{.stata .cell-code}\ngen byte sel1 = (ldlcp2 < 1e-8)\n```\n:::\n\n\n\n\n## Fit estimators - collecting results using `r(table)` matrix {#fit}\n\nIVW (with fixed effect standard errors)\n\n\n\n\n::: {.cell layout-align=\"center\" collectcode='true'}\n\n```{.stata .cell-code}\nmregger chdbeta ldlcbeta [aw=1/(chdse^2)] if sel1==1, ivw fe\nmat ivw = r(table)\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 73\n Residual standard error constrained at 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\nchdbeta |\n ldlcbeta | .4815055 .038221 12.60 0.000 .4065938 .5564173\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\nMR-Egger (with SEs using an unconstrained residual variance)\n\n\n\n\n::: {.cell layout-align=\"center\" collectcode='true'}\n\n```{.stata .cell-code}\nmregger chdbeta ldlcbeta [aw=1/(chdse^2)] if sel1==1\nmat mregger = r(table)\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 73\n Residual standard error = 1.548\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\nchdbeta |\n slope | .6173131 .1034573 5.97 0.000 .4145405 .8200858\n _cons | -.0087706 .0054812 -1.60 0.110 -.0195136 .0019723\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\nMR-Egger using the radial formulation\n\n\n\n\n::: {.cell layout-align=\"center\" collectcode='true'}\n\n```{.stata .cell-code}\nmregger chdbeta ldlcbeta [aw=1/(chdse^2)] if sel1==1, radial\nmat radial = r(table)\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 73\n Residual standard error = 1.547\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\nradialGD |\n radialGP | .642582 .1157871 5.55 0.000 .4156434 .8695205\n _cons | -.5737301 .3545658 -1.62 0.106 -1.268666 .1212062\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\nWeighted mode estimator\n\n\n\n\n::: {.cell layout-align=\"center\" collectcode='true'}\n\n```{.stata .cell-code}\nmrmodal chdbeta chdse ldlcbeta ldlcse if sel1==1, weighted\nmat mode = r(table)\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 73\n Replications = 1000\n Phi = 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4789702 .0663145 7.22 0.000 .3489963 .6089441\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\nWeighted median estimator\n\n\n\n\n::: {.cell layout-align=\"center\" collectcode='true'}\n\n```{.stata .cell-code}\nmrmedian chdbeta chdse ldlcbeta ldlcse if sel1==1, weighted\nmat median = r(table)\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 73\n Replications = 1000\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .4582573 .0653722 7.01 0.000 .3301302 .5863845\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\n## Combine and export results\n\nCheck our matrices\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmat dir\nmat list ivw\nmat list mregger\nmat list radial\nmat list mode\nmat list median\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n median[9,1]\n mode[9,1]\n radial[9,2]\n mregger[9,2]\n ivw[9,1]\n\n\nivw[9,1]\n chdbeta:\n ldlcbeta\n b .48150551\n se .03822098\n z 12.597937\npvalue 2.167e-36\n ll .40659377\n ul .55641726\n df .\n crit 1.959964\n eform 0\n\n\nmregger[9,2]\n chdbeta: chdbeta:\n slope _cons\n b .61731315 -.00877065\n se .10345735 .00548118\n z 5.9668371 -1.60014\npvalue 2.419e-09 .10956752\n ll .41454047 -.01951356\n ul .82008582 .00197226\n df . .\n crit 1.959964 1.959964\n eform 0 0\n\n\nradial[9,2]\n radialGD: radialGD:\n radialGP _cons\n b .64258196 -.57373006\n se .11578709 .35456584\n z 5.5496858 -1.61812\npvalue 2.862e-08 .10563675\n ll .41564344 -1.2686663\n ul .86952048 .12120621\n df . .\n crit 1.959964 1.959964\n eform 0 0\n\n\nmode[9,1]\n beta\n b .4789702\n se .06631445\n z 7.222712\npvalue 5.096e-13\n ll .34899626\n ul .60894415\n df .\n crit 1.959964\n eform 0\n\n\nmedian[9,1]\n beta\n b .45825733\n se .0653722\n z 7.0099725\npvalue 2.384e-12\n ll .33013017\n ul .58638448\n df .\n crit 1.959964\n eform 0\n```\n\n\n:::\n:::\n\n\n\n\nCombined into single matrix\n\n\n\n\n::: {.cell layout-align=\"center\" collectcode='true'}\n\n```{.stata .cell-code}\nmat output = (ivw, mregger, radial, mode, median)\nmat colnames output = ivw_beta mregger_beta mregger_cons ///\n\tradial_beta radial_cons mode_beta median_beta\nmat coleq output = \"\" \"\" \"\" \"\" \"\" \"\" \"\"\nmat output = output'\nmat list output, format(%4.3f)\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\noutput[7,9]\n b se z pvalue ll ul df crit eform\n ivw_beta 0.482 0.038 12.598 0.000 0.407 0.556 . 1.960 0.000\nmregger_beta 0.617 0.103 5.967 0.000 0.415 0.820 . 1.960 0.000\nmregger_cons -0.009 0.005 -1.600 0.110 -0.020 0.002 . 1.960 0.000\n radial_beta 0.643 0.116 5.550 0.000 0.416 0.870 . 1.960 0.000\n radial_cons -0.574 0.355 -1.618 0.106 -1.269 0.121 . 1.960 0.000\n mode_beta 0.479 0.066 7.223 0.000 0.349 0.609 . 1.960 0.000\n median_beta 0.458 0.065 7.010 0.000 0.330 0.586 . 1.960 0.000\n```\n\n\n:::\n:::\n\n\n\n\nExport matrix to dataset\n\n\n\n\n::: {.cell layout-align=\"center\" collectcode='true'}\n\n```{.stata .cell-code}\ndrop _all\nsvmat output, names(col)\nlocal rownames : rownames output\ndi \"`rownames'\"\ntokenize `rownames'\ngen str15 estimate = \"\"\nforvalues i = 1/7 {\n\treplace estimate = \"``i''\" in `i'\n}\n```\n:::\n\n\n\n\nShow dataset\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nlist estimate b se z pvalue ll ul, clean noobs\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n estimate b se z pvalue ll ul \n ivw_beta .4815055 .038221 12.59794 2.17e-36 .4065938 .5564172 \n mregger_beta .6173131 .1034573 5.966837 2.42e-09 .4145405 .8200858 \n mregger_cons -.0087707 .0054812 -1.60014 .1095675 -.0195136 .0019723 \n radial_beta .6425819 .1157871 5.549686 2.86e-08 .4156434 .8695205 \n radial_cons -.5737301 .3545658 -1.61812 .1056367 -1.268666 .1212062 \n mode_beta .4789702 .0663145 7.222712 5.10e-13 .3489963 .6089441 \n median_beta .4582573 .0653722 7.009973 2.38e-12 .3301302 .5863845 \n```\n\n\n:::\n:::\n\n\n\n\nSave dataset\n\n```stata\nsave myestimates, replace\n```\n\nExport as tab-delimited textfile\n\n```stata\nexport delimited using myestimates.txt, delimiter(tab) replace\n```\n",
+ "supporting": [],
+ "filters": [
+ "rmarkdown/pagebreak.lua"
+ ],
+ "includes": {},
+ "engineDependencies": {},
+ "preserve": {},
+ "postProcess": true
+ }
+}
\ No newline at end of file
diff --git a/site/_freeze/examples/spiller-ije-2018-examples/index/execute-results/html.json b/site/_freeze/examples/spiller-ije-2018-examples/index/execute-results/html.json
new file mode 100644
index 0000000..a092720
--- /dev/null
+++ b/site/_freeze/examples/spiller-ije-2018-examples/index/execute-results/html.json
@@ -0,0 +1,17 @@
+{
+ "hash": "22d57059eeb59ebb628567d4ab22dee1",
+ "result": {
+ "engine": "knitr",
+ "markdown": "---\ntitle: \"Examples from our IJE paper\"\n#author: \"Wes Spiller, Neil Davies, Tom Palmer\"\n#date: \"30 August 2018\"\nengine: knitr\n---\n\n\n\n\n\n\n\n\n\n\nThe paper is available [here](https://doi.org/10.1093/ije/dyy195) [@spiller-ije-2018].\n\n## mrrobust set-up\n\nInstall the `mrrobust` package using the user-written `github` package.\n\n```stata\nnet install github, from(\"https://haghish.github.io/github/\")\ngitget mrrobust\n```\n\nIf you have Stata 12 or earlier you will need to install some of these manually \n(see [here](https://remlapmot.github.io/mrrobust/#installing-and-updating-mrrobust) \nfor instructions).\n\n## Summary data description and overview\n\nAccompanying this paper are two sets of data _BMI.csv_, and _Height.csv_, containing the set of \nsummary estimates required for performing the BMI-serum glucose and height-serum glucose analyses \nrespectively. Each dataset is organised into 5 columns under the following headings:\n\n* `SNP`: A set of identifying numbers (rsids) for each genetic variant\n* `beta.exposure`: a set of values representing the coefficient from regressing the exposure upon \nthe genetic variant within a GWAS\n* `beta.outcome`: a set of values representing the coefficient from regressing the outcome upon \nthe genetic variant within a GWAS\n* `se.exposure`: a set of values representing the standard error corresponding to the coefficient \nin beta.exposure\n* `se.outcome`: a set of values representing the standard error corresponding to the coefficient \nin beta.outcome.\n\nNote Stata removes the `.` in the variable names when the data is imported.\n\nIn _BMI.csv_ the exposure is standardised body mass index (BMI), and is therefore interpreted on a\nstandard deviation scale. The summary statistics are reported by @locke-nat-2015.\nIn _Height.csv_ the exposure is standardised height in meters and also interpreted on a standard\ndeviation scale. The summary statistics are reported by @wood-natgen-2014.\n\nFor both analyses log transformed serum glucose was used as an outcome, reported by @shin-natgen-2014.\nAll the data was obtained from the MRBase GWAS catalogue available at [@mrbase] which has now been superseeded by the [OpenGWAS API](https://api.opengwas.io/).\nGenetic variants were pruned so as to be independent ($R^2$ = 0.0001), and the effect alleles were \naligned between the exposure and outcome datasets using the MRBase web application, prior to \nimplementing `mrrobust`.\n\n## Stata output for each estimation method using mrrobust: BMI-Serum Glucose {#estimation}\n\n### Read in data\n\n\n\n\n::: {.cell layout-align=\"center\" collectcode='true'}\n\n```{.stata .cell-code}\nimport delimited using BMI.csv, clear\n```\n:::\n\n\n\n\n### IVW\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmregger betaoutcome betaexposure [aw=1/(seoutcome^2)], ivw\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 79\n Residual standard error = 1.039\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\nbetaoutcome |\nbetaexposure | .0231866 .0079957 2.90 0.004 .0075154 .0388578\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\n### MR-Egger\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmregger betaoutcome betaexposure [aw=1/(seoutcome^2)]\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 79\n Residual standard error = 1.046\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\nbetaoutcome |\n slope | .0218507 .0221852 0.98 0.325 -.0216315 .0653329\n _cons | .000038 .0005877 0.06 0.948 -.0011138 .0011897\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\n### Plot of the MR-Egger model\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmreggerplot betaoutcome seoutcome betaexposure seexposure\nqui gr export mreggerplot-bmi.svg, width(600) replace\n```\n:::\n\n::: {.cell layout-align=\"center\"}\n::: {.cell-output-display}\n![Plot of the MR-Egger model for the BMI data.](mreggerplot-bmi.svg){fig-align='center' fig-alt='Plot of the MR-Egger model for the BMI data.'}\n:::\n:::\n\n\n\n\t\n### Weighted median\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmrmedian betaoutcome seoutcome betaexposure seexposure, weighted seed(300818)\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 79\n Replications = 1000\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .0339256 .0120248 2.82 0.005 .0103576 .0574937\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\n## Stata output using the mode-based estimator using mrrobust: BMI-Serum Glucose {#mode}\n\nUsing the `mrmodalplot` command, modal estimates are calculated using bandwidths of 0.25,\n0.5, and 1 respectively. This command also produces three overlaid density plots for each\nvalue, as shown in the Figure.\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmrmodalplot betaoutcome seoutcome betaexposure seexposure, lc(gs10 gs5 gs0) seed(300818) legend(pos(6))\nqui gr export mrmodalplot-bmi.svg, width(600) replace\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 79\n Replications = 1000\n Phi = .25\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .0374507 .0424036 0.88 0.377 -.0456588 .1205602\n------------------------------------------------------------------------------\n\n Number of genotypes = 79\n Replications = 1000\n Phi = .5\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .0416424 .0369758 1.13 0.260 -.0308289 .1141137\n------------------------------------------------------------------------------\n\n Number of genotypes = 79\n Replications = 1000\n Phi = 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .0431816 .0281684 1.53 0.125 -.0120274 .0983906\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n::: {.cell layout-align=\"center\"}\n::: {.cell-output-display}\n![Densities of the IV estimates using different values of phi.](mrmodalplot-bmi.svg){fig-align='center' fig-alt='Densities of the IV estimates using different values of phi.'}\n:::\n:::\n\n\n\n\n## Stata output for each estimation method using mrrobust: Height-Serum Glucose {#height}\n\n### Read in data\n\n\n\n\n::: {.cell layout-align=\"center\" collectcode='true'}\n\n```{.stata .cell-code}\nimport delimited using Height.csv, clear\n```\n:::\n\n\n\n\n### IVW\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmregger betaoutcome betaexposure [aw=1/(seoutcome^2)], ivw\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 367\n Residual standard error = 1.044\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\nbetaoutcome |\nbetaexposure | .0015412 .0033017 0.47 0.641 -.00493 .0080124\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\n### MR-Egger\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmregger betaoutcome betaexposure [aw=1/(seoutcome^2)]\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 367\n Residual standard error = 1.045\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\nbetaoutcome |\n slope | -.0025878 .0091178 -0.28 0.777 -.0204584 .0152828\n _cons | .0001338 .0002754 0.49 0.627 -.000406 .0006736\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\n### Plot of the MR-Egger model\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmreggerplot betaoutcome seoutcome betaexposure seexposure\nqui gr export mreggerplot-height.svg, width(600) replace\n```\n:::\n\n::: {.cell layout-align=\"center\"}\n::: {.cell-output-display}\n![Plot of the MR-Egger model for the Height data.](mreggerplot-height.svg){fig-align='center' fig-alt='Plot of the MR-Egger model for the Height data.'}\n:::\n:::\n\n\n\n\n### Weighted median\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmrmedian betaoutcome seoutcome betaexposure seexposure, weighted seed(300818)\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 367\n Replications = 1000\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | 0 .0052323 0.00 1.000 -.0102551 .0102551\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n\n\n\n## Stata output using the mode-based estimator using mrrobust: Height-Serum Glucose {#height-mode}\n\n\n\n\n::: {.cell layout-align=\"center\"}\n\n```{.stata .cell-code}\nmrmodalplot betaoutcome seoutcome betaexposure seexposure, lc(gs10 gs5 gs0) seed(300818) legend(pos(6))\nqui gr export mrmodalplot-height.svg, width(600) replace\n```\n\n\n::: {.cell-output .cell-output-stdout}\n\n```\n Number of genotypes = 367\n Replications = 1000\n Phi = .25\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .0061368 .0245472 0.25 0.803 -.0419748 .0542484\n------------------------------------------------------------------------------\n\n Number of genotypes = 367\n Replications = 1000\n Phi = .5\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | .0015595 .0212232 0.07 0.941 -.0400372 .0431561\n------------------------------------------------------------------------------\n\n Number of genotypes = 367\n Replications = 1000\n Phi = 1\n------------------------------------------------------------------------------\n | Coefficient Std. err. z P>|z| [95% conf. interval]\n-------------+----------------------------------------------------------------\n beta | -.0054772 .0149074 -0.37 0.713 -.0346952 .0237408\n------------------------------------------------------------------------------\n```\n\n\n:::\n:::\n\n::: {.cell layout-align=\"center\"}\n::: {.cell-output-display}\n![Densities of the IV estimates using different values of phi.](mrmodalplot-height.svg){fig-align='center' fig-alt='Densities of the IV estimates using different values of phi.'}\n:::\n:::\n\n\n\n\n## References\n\n::: {#refs}\n:::\n",
+ "supporting": [
+ "index_files"
+ ],
+ "filters": [
+ "rmarkdown/pagebreak.lua"
+ ],
+ "includes": {},
+ "engineDependencies": {},
+ "preserve": {},
+ "postProcess": true
+ }
+}
\ No newline at end of file
diff --git a/site/_freeze/index/execute-results/html.json b/site/_freeze/index/execute-results/html.json
new file mode 100644
index 0000000..ce07674
--- /dev/null
+++ b/site/_freeze/index/execute-results/html.json
@@ -0,0 +1,15 @@
+{
+ "hash": "791429dde30447654b1b042492b6e44b",
+ "result": {
+ "engine": "knitr",
+ "markdown": "---\n#title: \"mrrobust\"\n---\n\n\n# 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* July 2024:\n - Updated website to mention [OpenGWAS](https://api.opengwas.io/) instead of MR-Base\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 QA statistic for \n instrument validity in `e(Qa)` ([Sanderson et al. 2019](#references))\n - The `gxse()` option additionally returns the Qx 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\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 \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 , Wesley Spiller, Neil Davies\n\n## How to cite the mrrobust package\nSpiller W, Davies NM, Palmer TM. Software Application Profile: mrrobust — A tool for performing \ntwo-sample summary Mendelian randomization analyses. International Journal of Epidemiology, 2019, \n48, 3, 684–690. .\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 .\n\n## References\n\n\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–525. .\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–314. .\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–1998. .\n\nHemani G et al. The MR-Base platform supports systematic causal inference across the human\nphenome. eLife, 2018, 7:e34408. .\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–727. .\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–5452.\n.\n \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\n\n\n\n\n\n\n\n\n\n\n",
+ "supporting": [],
+ "filters": [
+ "rmarkdown/pagebreak.lua"
+ ],
+ "includes": {},
+ "engineDependencies": {},
+ "preserve": {},
+ "postProcess": true
+ }
+}
\ No newline at end of file
diff --git a/site/examples/mrrobust-examples/mreggerplot.svg b/site/examples/mrrobust-examples/mreggerplot.svg
index 0edd61b..0663f3d 100644
--- a/site/examples/mrrobust-examples/mreggerplot.svg
+++ b/site/examples/mrrobust-examples/mreggerplot.svg
@@ -243,15 +243,15 @@
-
+
-
-
+
+
-
-
+
+
diff --git a/site/examples/mrrobust-examples/mrfunnel.svg b/site/examples/mrrobust-examples/mrfunnel.svg
index d418bd8..8bec352 100644
--- a/site/examples/mrrobust-examples/mrfunnel.svg
+++ b/site/examples/mrrobust-examples/mrfunnel.svg
@@ -6,123 +6,253 @@
-
-
-
-
-
-
-
-
-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
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
- 0
-
- 2
-
- 4
-
- 6
-
- 8
+
+
+ 0
+
+ 2
+
+ 4
+
+ 6
+
+ 8
10
-
+
Instrument strength (abs(
γ
j
@@ -910,29 +1050,29 @@
Yj
)
-
-
- -4
-
- -2
-
- 0
-
- 2
-
+
+
+ -4
+
+ -2
+
+ 0
+
+ 2
+
β
IV
-
-
-
-
-
-
-
-
-
- Genotypes
- IVW
- MR-Egger
+
+
+
+
+
+
+
+
+
+ Genotypes
+ IVW
+ MR-Egger
diff --git a/site/examples/mrrobust-examples/mrmodalplot.svg b/site/examples/mrrobust-examples/mrmodalplot.svg
index bbba705..70da4ef 100644
--- a/site/examples/mrrobust-examples/mrmodalplot.svg
+++ b/site/examples/mrrobust-examples/mrmodalplot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+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+ .5
+
+ 1
1.5
- Density
-
-
- -4
-
- -2
-
- 0
-
- 2
-
- 4
- IV estimates
-
-
-
-
-
- φ = .25
- φ = .5
- φ = 1
+ Density
+
+
+ -4
+
+ -2
+
+ 0
+
+ 2
+
+ 4
+ IV estimates
+
+
+
+
+
+ φ = .25
+ φ = .5
+ φ = 1
diff --git a/site/examples/spiller-ije-2018-examples/mreggerplot-bmi.svg b/site/examples/spiller-ije-2018-examples/mreggerplot-bmi.svg
index df53919..00f0213 100644
--- a/site/examples/spiller-ije-2018-examples/mreggerplot-bmi.svg
+++ b/site/examples/spiller-ije-2018-examples/mreggerplot-bmi.svg
@@ -175,15 +175,15 @@
-
+
-
-
+
+
-
-
+
+
diff --git a/site/examples/spiller-ije-2018-examples/mreggerplot-height.svg b/site/examples/spiller-ije-2018-examples/mreggerplot-height.svg
index 992a588..1cfbc3c 100644
--- a/site/examples/spiller-ije-2018-examples/mreggerplot-height.svg
+++ b/site/examples/spiller-ije-2018-examples/mreggerplot-height.svg
@@ -227,15 +227,15 @@
-
+
-
-
+
+
-
-
+
+
diff --git a/site/examples/spiller-ije-2018-examples/mrmodalplot-bmi.svg b/site/examples/spiller-ije-2018-examples/mrmodalplot-bmi.svg
index c29803d..3ceedb6 100644
--- a/site/examples/spiller-ije-2018-examples/mrmodalplot-bmi.svg
+++ b/site/examples/spiller-ije-2018-examples/mrmodalplot-bmi.svg
@@ -6,276 +6,389 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-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+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+ 2
+
+ 4
+
+ 6
+
+ 8
+ Density
+
+
+ -.2
+
+ 0
+
+ .2
+
+ .4
+ IV estimates
+
+
+
+
+
+ φ = .25
+ φ = .5
+ φ = 1
diff --git a/site/examples/spiller-ije-2018-examples/mrmodalplot-height.svg b/site/examples/spiller-ije-2018-examples/mrmodalplot-height.svg
index 13b76de..5f72628 100644
--- a/site/examples/spiller-ije-2018-examples/mrmodalplot-height.svg
+++ b/site/examples/spiller-ije-2018-examples/mrmodalplot-height.svg
@@ -6,83 +6,158 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -107,178 +182,188 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
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