if (FALSE) {
data(EFV)
gf1 <- gformula(
X = EFV, Anodes = c("efv.0", "efv.1", "efv.2", "efv.3", "efv.4"),
Ynodes = c("VL.0", "VL.1", "VL.2", "VL.3", "VL.4"),
Lnodes = c("adherence.1", "weight.1", "adherence.2", "weight.2",
"adherence.3", "weight.3", "adherence.4", "weight.4"),
abar = seq(1, 5), B = 10, ret = TRUE
)
# compare outcomes at last time point under (1,...,1) and (5,...,5)
contrast(gf1, abar = c(1, 5), nodes = "VL.4")
# compare outcomes at different time points, for same intervention (2,...)
contrast(gf1, abar = 2, nodes = c("VL.3", "VL.2"))
# compare own measure (rel. risk reduction) instead of mean
# ... and conditional on subset
relativeRiskReduction <- function(k, l){(k - l) / k}
contrast(
gf1, abar = c(1, 2), nodes = "VL.4",
contrastType = relativeRiskReduction,
cond = quote(sex == 1)
)
# Instead of the mean, any other measure can be taken,
# and - of course - applied also to counterfactual Lnodes
contrast(
gf1, abar = 2, nodes = c("weight.3", "weight.2"),
measure = median
)
}
Run the code above in your browser using DataLab