Description Usage Arguments Details Value References Examples
Implements MR GENIUS under an additive outcome model.
1 2 | genius_addY(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 the estimators given in equations (6) and (12) of Tchetgen Tchetgen et al (2017) for single and multiple instruments, respectively. 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 additive 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 additive 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 41 42 43 44 45 46 | # the following packages are needed to simulate data
library("msm")
library("MASS")
expit <- function(x) {
exp(x)/(1+exp(x))
}
### example with binary exposure, all instruments invalid ###
# true causal effect, beta = 1.0
# Number of instruments, nIV = 10
# Y: vector of outcomes
# A: vector of exposures
# G: matrix of instruments, one column per instrument
nIV=10; N=5000; beta=1;
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 = as.vector(alpha%*%t(G)) + beta*A + U + rnorm(N);
genius_addY(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_addY(Y,A,G,A~(g1+g2+g3+g4+g5+g6+g7+g8+g9+g10)^2);
### example with continous exposure, all instruments invalid ###
nIV=10; N=500; beta=1;
phi=rep(-0.5,nIV); gamma=rep(-2,nIV); alpha=rep(-0.5,nIV);
lambda0=1; 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 = as.vector(alpha%*%t(G)) + beta*A + U + rnorm(N);
genius_addY(Y,A,G);
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.