| h_cox_regression {tern} | R Documentation |
Helper functions for Cox proportional hazards regression
Description
Helper functions used in fit_coxreg_univar() and fit_coxreg_multivar().
Usage
h_coxreg_univar_formulas(variables, interaction = FALSE)
h_coxreg_multivar_formula(variables)
h_coxreg_univar_extract(effect, covar, data, mod, control = control_coxreg())
h_coxreg_multivar_extract(var, data, mod, control = control_coxreg())
Arguments
variables |
(named |
interaction |
( |
effect |
( |
covar |
( |
data |
( |
mod |
( |
control |
( |
var |
( |
Value
-
h_coxreg_univar_formulas()returns acharactervector coercible into formulas (e.gstats::as.formula()).
-
h_coxreg_multivar_formula()returns astringcoercible into a formula (e.gstats::as.formula()).
-
h_coxreg_univar_extract()returns adata.framewith variableseffect,term,term_label,level,n,hr,lcl,ucl, andpval.
-
h_coxreg_multivar_extract()returns adata.framewith variablespval,hr,lcl,ucl,level,n,term, andterm_label.
Functions
-
h_coxreg_univar_formulas(): Helper for Cox regression formula. Creates a list of formulas. It is used internally byfit_coxreg_univar()for the comparison of univariate Cox regression models. -
h_coxreg_multivar_formula(): Helper for multivariate Cox regression formula. Creates a formulas string. It is used internally byfit_coxreg_multivar()for the comparison of multivariate Cox regression models. Interactions will not be included in multivariate Cox regression model. -
h_coxreg_univar_extract(): Utility function to help tabulate the result of a univariate Cox regression model. -
h_coxreg_multivar_extract(): Tabulation of multivariate Cox regressions. Utility function to help tabulate the result of a multivariate Cox regression model for a treatment/covariate variable.
See Also
Examples
# `h_coxreg_univar_formulas`
## Simple formulas.
h_coxreg_univar_formulas(
variables = list(
time = "time", event = "status", arm = "armcd", covariates = c("X", "y")
)
)
## Addition of an optional strata.
h_coxreg_univar_formulas(
variables = list(
time = "time", event = "status", arm = "armcd", covariates = c("X", "y"),
strata = "SITE"
)
)
## Inclusion of the interaction term.
h_coxreg_univar_formulas(
variables = list(
time = "time", event = "status", arm = "armcd", covariates = c("X", "y"),
strata = "SITE"
),
interaction = TRUE
)
## Only covariates fitted in separate models.
h_coxreg_univar_formulas(
variables = list(
time = "time", event = "status", covariates = c("X", "y")
)
)
# `h_coxreg_multivar_formula`
h_coxreg_multivar_formula(
variables = list(
time = "AVAL", event = "event", arm = "ARMCD", covariates = c("RACE", "AGE")
)
)
# Addition of an optional strata.
h_coxreg_multivar_formula(
variables = list(
time = "AVAL", event = "event", arm = "ARMCD", covariates = c("RACE", "AGE"),
strata = "SITE"
)
)
# Example without treatment arm.
h_coxreg_multivar_formula(
variables = list(
time = "AVAL", event = "event", covariates = c("RACE", "AGE"),
strata = "SITE"
)
)
library(survival)
dta_simple <- data.frame(
time = c(5, 5, 10, 10, 5, 5, 10, 10),
status = c(0, 0, 1, 0, 0, 1, 1, 1),
armcd = factor(LETTERS[c(1, 1, 1, 1, 2, 2, 2, 2)], levels = c("A", "B")),
var1 = c(45, 55, 65, 75, 55, 65, 85, 75),
var2 = c("F", "M", "F", "M", "F", "M", "F", "U")
)
mod <- coxph(Surv(time, status) ~ armcd + var1, data = dta_simple)
result <- h_coxreg_univar_extract(
effect = "armcd", covar = "armcd", mod = mod, data = dta_simple
)
result
mod <- coxph(Surv(time, status) ~ armcd + var1, data = dta_simple)
result <- h_coxreg_multivar_extract(
var = "var1", mod = mod, data = dta_simple
)
result