| tidy.glm {tern} | R Documentation | 
Custom tidy method for binomial GLM results
Description
Helper method (for broom::tidy()) to prepare a data frame from a glm object
with binomial family.
Usage
## S3 method for class 'glm'
tidy(x, conf_level = 0.95, at = NULL, ...)
Arguments
x | 
 (  | 
conf_level | 
 (  | 
at | 
 (  | 
... | 
 additional arguments for the lower level functions.  | 
Value
A data.frame containing the tidied model.
See Also
h_logistic_regression for relevant helper functions.
Examples
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)
[Package tern version 0.9.5 Index]