# NOT RUN {
df <- Titanic %>%
dplyr::as_tibble() %>%
dplyr::mutate(dplyr::across(where(is.character), factor))
df %>%
glm(
Survived ~ Class + Age + Sex,
data = ., weights = .$n, family = binomial,
contrasts = list(Age = contr.sum, Class = "contr.SAS")
) %>%
tidy_and_attach(exponentiate = TRUE) %>%
tidy_add_reference_rows() %>%
tidy_add_estimate_to_reference_rows(exponentiate = TRUE)
if (requireNamespace("gtsummary")) {
glm(
response ~ stage + grade * trt,
gtsummary::trial,
family = binomial,
contrasts = list(
stage = contr.treatment(4, base = 3),
grade = contr.treatment(3, base = 2),
trt = contr.treatment(2, base = 2)
)
) %>%
tidy_and_attach() %>%
tidy_add_reference_rows() %>%
tidy_add_estimate_to_reference_rows()
}
# }
Run the code above in your browser using DataCamp Workspace