Description Usage Arguments Details Value References Examples
Implements MR GENIUS under a multiplicative outcome model.
1 2 | genius_mulY(Y, A, G, formula = A ~ G, alpha = 0.05, lower = -10,
upper = 10)
|
Y |
A numeric vector of outcomes. |
A |
A numeric vector of exposures (binary values should be coded in 0/1). |
G |
A numeric matrix of instruments; each column stores values for one instrument (a numeric vector if only a single instrument is available). |
formula |
An object of class "formula" describing the linear predictor of the model for E(A|G) (default A~G, main effects of all available instruments). |
alpha |
Significance level for confidence interval (default value=0.05). |
lower |
The lower end point of the causal effect interval to be searched (default value=-10). |
upper |
The upper end point of the causal effect interval to be searched (default value=10). |
This function implements MR GENIUS as the solution to the empirical version of equation (14) in Tchetgen Tchetgen et al (2017). The term E(A|G) is modelled under the logit and identity links for binary and continuous exposure respectively, with a default linear predictor consisting of the main effects of all available instruments.
A "genius" object containing the following items:
beta.est |
The point estimate of the causal effect (on the multiplicative scale) of the exposure on the outcome. |
beta.var |
The corresponding estimated variance. |
ci |
The corresponding Wald-type confidence interval at specified significance level. |
pval |
The p-value for two-sided Wald test of null causal effect (on the multiplicative scale) of the exposure on the outcome. |
Tchetgen Tchetgen, E., Sun, B. and Walter, S. (2017). The GENIUS Approach to Robust Mendelian Randomization Inference. arXiv e-prints.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #the following packages are needed to simulate data
library("msm")
library("MASS")
### examples under multiplicative outcome model, all instruments invalid ###
# true causal effect, beta = 1.5
# Number of instruments, nIV = 10
# Y: vector of outcomes
# A: vector of exposures
# G: matrix of instruments, one column per instrument
### binary exposure
nIV=10; N=2000; beta=1.5;
phi=rep(-0.02,nIV); gamma=rep(-0.15,nIV); alpha=rep(-0.5,nIV);
Gn = mvrnorm(N,rep(0,nIV),diag(rep(1,nIV)))
G = (Gn>0)*1;
U= as.vector(phi%*%t(G))+ rtnorm(n=N,mean=0.35,lower=0.2,upper=0.5);
A = rbinom(N,1,expit(as.vector(gamma%*%t(G)))+U-0.35-as.vector(phi%*%t(G)));
Y = exp(beta*A)*(as.vector(alpha%*%t(G)) + U) + rnorm(N);
genius_mulY(Y,A,G);
### specify a more richly parameterized linear predictor for the model of E[A|G]
### containing all main effects and pairwise interactions of instruments
colnames(G)=paste("g",1:10,sep="")
genius_mulY(Y,A,G,A~(g1+g2+g3+g4+g5+g6+g7+g8+g9+g10)^2);
### continuous exposure
nIV=10; N=2000; beta=0.25;
phi=rep(0.2,nIV); gamma=rep(0.5,nIV); alpha=rep(0.5,nIV);
lambda0=0.5; lambda1=rep(0.5,nIV);
Gn = mvrnorm(N,rep(0,nIV),diag(rep(1,nIV)))
G = (Gn>0)*1;
U = as.vector(phi%*%t(G))+rnorm(N);
A = as.vector(gamma%*%t(G)) +U + rnorm(N,mean=0,sd=abs(lambda0+as.vector(lambda1%*%t(G))));
Y = exp(beta*A)*(as.vector(alpha%*%t(G)) + U) + rnorm(N);
genius_mulY(Y,A,G);
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.