Last chance! 50% off unlimited learning
Sale ends in
# NOT RUN {
### Letenneur et al. (2000) example data
# this is the example given in Mathur et al. (2021)
# Z: sex (w = women, m = male; males are the reference category)
# Y: dementia (1 = developed dementia, 0 = did not develop dementia )
# X: low education (1 = up to 7 years, 0 = at least 12 years)
# n: sample size
# data for women
nw_1 = 2988
nw_0 = 364
dw = data.frame( Y = c(1, 1, 0, 0),
X = c(1, 0, 1, 0),
n = c( 158, 6, nw_1-158, nw_0-6 ) )
# data for men
nm_1 = 1790
nm_0 = 605
dm = data.frame( Y = c(1, 1, 0, 0),
X = c(1, 0, 1, 0),
n = c( 64, 17, nm_1-64, nm_0-17 ) )
# P(Y = 1 | X = 1) and P(Y = 1 | X = 0) for women and for men
( pw_1 = dw$n[ dw$X == 1 & dw$Y == 1 ] / sum(dw$n[ dw$X == 1 ]) )
( pw_0 = dw$n[ dw$X == 0 & dw$Y == 1 ] / sum(dw$n[ dw$X == 0 ]) )
( pm_1 = dm$n[ dm$X == 1 & dm$Y == 1 ] / sum(dm$n[ dm$X == 1 ]) )
( pm_0 = dm$n[ dm$X == 0 & dm$Y == 1 ] / sum(dm$n[ dm$X == 0 ]) )
# prevalence of low education among women and among men
fw = nw_1 / (nw_1 + nw_0)
fm = nm_1 / (nm_1 + nm_0)
# confounded interaction contrast estimate
( pw_1 - pw_0 ) - ( pm_1 - pm_0 )
### E-values without making assumptions on direction of confounding bias
# for interaction contrast point estimate
evalues.IC( stat = "est",
p1_1 = pw_1,
p1_0 = pw_0,
n1_1 = nw_1,
n1_0 = nw_0,
f1 = fw,
p0_1 = pm_1,
p0_0 = pm_0,
n0_1 = nm_1,
n0_0 = nm_0,
f0 = fm )
# and for its lower CI limit
evalues.IC( stat = "CI",
p1_1 = pw_1,
p1_0 = pw_0,
n1_1 = nw_1,
n1_0 = nw_0,
f1 = fw,
p0_1 = pm_1,
p0_0 = pm_0,
n0_1 = nm_1,
n0_0 = nm_0,
f0 = fm )
### E-values assuming unidirectonal confounding of unknown direction
# for interaction contrast point estimate
evalues.IC( stat = "est",
unidirBias = TRUE,
unidirBiasDirection = "unknown",
p1_1 = pw_1,
p1_0 = pw_0,
n1_1 = nw_1,
n1_0 = nw_0,
f1 = fw,
p0_1 = pm_1,
p0_0 = pm_0,
n0_1 = nm_1,
n0_0 = nm_0,
f0 = fm )
# and for its lower CI limit
evalues.IC( stat = "CI",
unidirBias = TRUE,
unidirBiasDirection = "unknown",
p1_1 = pw_1,
p1_0 = pw_0,
n1_1 = nw_1,
n1_0 = nw_0,
f1 = fw,
p0_1 = pm_1,
p0_0 = pm_0,
n0_1 = nm_1,
n0_0 = nm_0,
f0 = fm )
# }
Run the code above in your browser using DataLab