Reputation: 1
I've used the glm function to perform an univariate regression:
data_glm<-data.frame(c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),c("ctl","ctl","ctl","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt","ctl","ctl","ctl","ctl","ctl","ctl","ctl","ctl","ctl","ctl","ctl","ctl","trt","trt","trt","trt","trt","trt","trt","trt","trt","trt"))
colnames(data_glm) <- c("response", "arm")
glm.fit <- glm(response ~ arm, data = data_glm, family = binomial(link = "logit"))
summary(glm.fit)
R Output
Call:
glm(formula = response ~ arm, family = binomial(link = "logit"),
data = data_glm)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -1.3863 0.6455 -2.148 0.031742 *
arm trt 2.6391 0.7384 3.574 0.000352 ***
I would like to use tbl_regression to summarize these results. Unfortunately the resulting CI are not the Wald CI, for example for ARM: trt 14.0 (3.65 to 71.0) with the following code:
tbl_regression(glm.fit, exponentiate = TRUE)
Is there an option to get the Wald CI?
Thanks, LM
Upvotes: 0
Views: 842
Reputation: 4370
If you want the wald CI you can use the example on the gtsummary help page to walk you through this. Extra help here: https://www.danieldsjoberg.com/gtsummary/articles/gallery.html#wald-ci.
here is the code on how to get wald ci.
my_tidy <- function(x, exponentiate = FALSE, conf.level = 0.95, ...) {
dplyr::bind_cols(
broom::tidy(x, exponentiate = exponentiate, conf.int = FALSE),
# calculate the confidence intervals, and save them in a tibble
stats::confint.default(x) %>%
tibble::as_tibble() %>%
rlang::set_names(c("conf.low", "conf.high")) )
}
lm(age ~ grade + marker, trial) %>%
tbl_regression(tidy_fun = my_tidy)
Upvotes: 1