Package 'mr.genius'

Title: GENIUS-MAWII: For Robust Mendelian Randomization with Many Weak Invalid Instruments
Description: Mendelian randomization (MR) has become a popular approach to study causal effects by using genetic variants as instrumental variables. This package implements GENIUS-MAWII. Reference: Ting Ye, Zhonghua Liu, Baoluo Sun, and Eric Tchetgen Tchetgen (2021). GENIUS-MAWII: For Robust Mendelian Randomization with Many Weak Invalid Instruments. Available at https://arxiv.org/abs/2107.06238.
Authors: Ting Ye [aut, cre]
Maintainer: Ting Ye <[email protected]>
License: GPL (>= 2)
Version: 0.1.0
Built: 2026-05-19 09:04:40 UTC
Source: https://github.com/remlapmot/mr.genius

Help Index


Simulate dataset

Description

Simulate dataset

Usage

data_gen(m, n, beta0, gamma, case = "case2")

Arguments

m

Number of SNPs

n

Sample size

beta0

True causal effect

gamma

A parameter that controls the magnitude of heteroscedasticity, i.e., the identification strength

case

Simulation scenarios used in Table 1 in Ye et al., (2021)

Value

A list

z

A n*m matrix of SNPs.

a

A n-dimentional vector for the exposure.

y

A n-dimentional vector for the outcome.

References

Ting Ye, Zhonghua Liu, Baoluo Sun, and Eric Tchetgen Tchetgen (2021). GENIUS-MAWII: For Robust Mendelian Randomization with Many Weak Invalid Instruments.https://arxiv.org/abs/2107.06238.

Examples

df<-data_gen(m=100,n=1e5,beta=0.4,gamma=0.1)

Simulate a dataset with covariates

Description

Simulate a dataset with covariates

Usage

data_gen_x(m, n, beta0, gamma)

Arguments

m

Number of SNPs

n

Sample size

beta0

True causal effect

gamma

A parameter that controls the magnitude of heteroscedasticity, i.e., the identification strength

Value

A list

z

A n*m matrix of SNPs.

a

A n-dimentional vector for the exposure.

y

A n-dimentional vector for the outcome.

x

A n*2 matrix for the covariate.

References

Ting Ye, Zhonghua Liu, Baoluo Sun, and Eric Tchetgen Tchetgen (2021). GENIUS-MAWII: For Robust Mendelian Randomization with Many Weak Invalid Instruments.https://arxiv.org/abs/2107.06238.

Examples

df<-data_gen_x(m=100,n=1e5,beta=0.4,gamma=0.1)

Main function for GENIUS-MAWII

Description

Main function for GENIUS-MAWII

Usage

mr.genius(z, a, y, x = NULL, alpha = 0.05, diagnostics = FALSE)

Arguments

z

A n*m matrix of SNPs, where n is the sample size, m is the number of SNPs

a

A n-dimentional vector for the exposure

y

A n-dimentional vector for the outcome

x

A n*p matrix for the covariate, where p is the number of covariates. Default is NULL, when there is no covariates

alpha

Confidence interval has level 1-alpha. Default is 0.05

diagnostics

Should the function returns the residual plot for assumption diagnosis. Default is FALSE

Value

A list

beta.hat

Estimated causal effect

beta.se

Standard error of beta.hat

ci

A 1-alpha confidence interval

J

J statistic, which is often used to test overidentification. J statistic larger than 1-alpha quantile of chi-square distribution (df=dim(Z)-1) indicates that not all SNPs satisfy our assumptions.

f.statistic

F-statistic as a measure of weak identification. It is recommended to be larger than 2.

References

Ting Ye, Zhonghua Liu, Baoluo Sun, and Eric Tchetgen Tchetgen (2021). GENIUS-MAWII: For Robust Mendelian Randomization with Many Weak Invalid Instruments.https://arxiv.org/abs/2107.06238.

Examples

df<-data_gen(m=20,n=1e5,beta=0.4,gamma=0.1)
mr.genius(df$z,df$a,df$y,diagnostics=TRUE)

  df<-data_gen_x(m=10,n=2e3,beta=0.4,gamma=1)
  mr.genius(df$z,df$a,df$y,df$x)