View source: R/logistic_regression.R
fit_logistic | R Documentation |
Fit a (conditional) logistic regression model.
fit_logistic(
data,
variables = list(response = "Response", arm = "ARMCD", covariates = NULL, interaction =
NULL, strata = NULL),
response_definition = "response"
)
data |
( |
variables |
(named |
response_definition |
( |
A fitted logistic regression model.
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 either NULL
(no covariates) or a character vector of covariate variable names.
interaction
: This is either NULL
(no interaction) or a string of a single covariate variable name already
included in covariates
. Then the interaction with the treatment arm is included in the model.
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"
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.