dat <- data.frame(group1 = c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2),
group2 = c(1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2),
x1 = c(0, 1, 0, 0, 1, 1, 0, 1, NA, 0, 1, 0),
x2 = c(0, NA, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1),
x3 = c(1, 1, 1, 0, 1, NA, 1, NA, 0, 0, 0, 1))
# Two-Sided 95% CI for x1
ci.prop(dat$x1)
# Two-Sided 95% CI for x1 using Wald method
ci.prop(dat$x1, method = "wald")
# One-Sided 95% CI for x1
ci.prop(dat$x1, alternative = "less")
# Two-Sided 99% CI
ci.prop(dat$x1, conf.level = 0.99)
# Two-Sided 95% CI, print results with 4 digits
ci.prop(dat$x1, digits = 4)
# Two-Sided 95% CI for x1, x2, and x3,
# listwise deletion for missing data
ci.prop(dat[, c("x1", "x2", "x3")], na.omit = TRUE)
# Two-Sided 95% CI for x1, x2, and x3,
# analysis by group1 separately
ci.prop(dat[, c("x1", "x2", "x3")], group = dat$group1)
# Two-Sided 95% CI for x1, x2, and x3,
# analysis by group1 separately, sort by variables
ci.prop(dat[, c("x1", "x2", "x3")], group = dat$group1, sort.var = TRUE)
# Two-Sided 95% CI for x1, x2, and x3,
# split analysis by group1
ci.prop(dat[, c("x1", "x2", "x3")], split = dat$group1)
# Two-Sided 95% CI for x1, x2, and x3,
# analysis by group1 separately, split analysis by group2
ci.prop(dat[, c("x1", "x2", "x3")],
group = dat$group1, split = dat$group2)
Run the code above in your browser using DataLab