h_cox_regression | R Documentation |
Helper functions used in fit_coxreg_univar()
and fit_coxreg_multivar()
.
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())
variables |
(named |
interaction |
( |
effect |
( |
covar |
( |
data |
( |
mod |
( |
control |
( |
var |
( |
h_coxreg_univar_formulas()
returns a character
vector coercible into formulas (e.g stats::as.formula()
).
h_coxreg_multivar_formula()
returns a string
coercible into a formula (e.g stats::as.formula()
).
h_coxreg_univar_extract()
returns a data.frame
with variables effect
, term
, term_label
, level
,
n
, hr
, lcl
, ucl
, and pval
.
h_coxreg_multivar_extract()
returns a data.frame
with variables pval
, hr
, lcl
, ucl
, level
,
n
, term
, and term_label
.
h_coxreg_univar_formulas()
: Helper for Cox regression formula. Creates a list of formulas. It is used
internally by fit_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 by fit_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.
cox_regression
# `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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.