fit_logistic {tern} | R Documentation |
Fit for logistic regression
Description
Fit a (conditional) logistic regression model.
Usage
fit_logistic(
data,
variables = list(response = "Response", arm = "ARMCD", covariates = NULL, interaction =
NULL, strata = NULL),
response_definition = "response"
)
Arguments
data |
( |
variables |
(named |
response_definition |
( |
Value
A fitted logistic regression model.
Model Specification
The variables
list needs to include the following elements:
-
arm
: Treatment arm variable name. -
response
: The response arm variable name. Usually this is a 0/1 variable. -
covariates
: This is eitherNULL
(no covariates) or a character vector of covariate variable names. -
interaction
: This is eitherNULL
(no interaction) or a string of a single covariate variable name already included incovariates
. Then the interaction with the treatment arm is included in the model.
Examples
library(dplyr)
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"
)
)