Description Usage Arguments Value Examples
A Negative Control Outcome Regression for Eliminating Unobserved Confounding in Time-series Studies
1 2 3 4 5 6 7 8 9 |
data |
an optional data frame containing the variables in the model. |
pre_outc_name |
the name of pre-exposure outcome |
expo_namem |
the name of exposure |
post_outc_name |
the name of post-exposure outcome |
centre |
the number of reacher centre or time series fragments |
method |
method of estimation |
boots_no |
the number of bootstrap for IVW estimation |
causal
the casual effect estimation
lag
the lag causal effect estimation
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 | NN <- 10
data_total <- NULL
for(i in 1:NN){
c0 <- 0.5
dia <- 0.5
diff_c1 <- 0
r <- 0.5
c1 <- rnorm(1,0.5,1)
c2 <- rnorm(1,0.5,1)
N <- 100
Sigma <- matrix(c(1,r,r^2,r,1,r,r^2,r,1),3,3)
u <- MASS::mvrnorm(n=N, mu=rep(0,3), Sigma=Sigma)
colnames(u) <- c('u1','u2','u3')
u <- data.frame(u)
u1 <- u$u1
u2 <- u$u2
u3 <- u$u3
eps_y1 <- rnorm(N,0,0.1)
eps_y3 <- rnorm(N,0,0.1)
eps_x2 <- rnorm(N,0,0.1)
y1 <- c1*u1 + eps_y1
x2 <- c2*u2 + eps_x2
y3 <- c0*x2 + c1*u3+diff_c1*u3 + dia*y1 + eps_y3
data_cenre <- data.frame(x2,u1,u2,u3,y1,y3,i)
data_total <- rbind(data_total,data_cenre)
}
model <- ncor_ind (data=data_total, pre_outc_name='y1',expo_namem = 'x2',
post_outc_name='y3',centre='i',method='IVW',boot_no=1000)
model
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.