View source: R/logistic_regression.R
tidy.glm | R Documentation |
Helper method (for broom::tidy()
) to prepare a data frame from a glm
object
with binomial
family.
## S3 method for class 'glm'
tidy(x, conf_level = 0.95, at = NULL, ...)
x |
( |
conf_level |
( |
at |
( |
... |
additional arguments for the lower level functions. |
A data.frame
containing the tidied model.
h_logistic_regression for relevant helper functions.
library(dplyr)
library(broom)
adrs_f <- tern_ex_adrs %>%
filter(PARAMCD == "BESRSPI") %>%
filter(RACE %in% c("ASIAN", "WHITE", "BLACK OR AFRICAN AMERICAN")) %>%
mutate(
Response = case_when(AVALC %in% c("PR", "CR") ~ 1, TRUE ~ 0),
RACE = factor(RACE),
SEX = factor(SEX)
)
formatters::var_labels(adrs_f) <- c(formatters::var_labels(tern_ex_adrs), Response = "Response")
mod1 <- fit_logistic(
data = adrs_f,
variables = list(
response = "Response",
arm = "ARMCD",
covariates = c("AGE", "RACE")
)
)
mod2 <- fit_logistic(
data = adrs_f,
variables = list(
response = "Response",
arm = "ARMCD",
covariates = c("AGE", "RACE"),
interaction = "AGE"
)
)
df <- tidy(mod1, conf_level = 0.99)
df2 <- tidy(mod2, conf_level = 0.99)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.