tidy_coxreg {tern} | R Documentation |
Custom tidy methods for Cox regression
Description
Usage
## S3 method for class 'summary.coxph'
tidy(x, ...)
## S3 method for class 'coxreg.univar'
tidy(x, ...)
## S3 method for class 'coxreg.multivar'
tidy(x, ...)
Arguments
x |
( |
... |
additional arguments for the lower level functions. |
Value
broom::tidy()
returns:
For
summary.coxph
objects, adata.frame
with columns:Pr(>|z|)
,exp(coef)
,exp(-coef)
,lower .95
,upper .95
,level
, andn
.For
coxreg.univar
objects, adata.frame
with columns:effect
,term
,term_label
,level
,n
,hr
,lcl
,ucl
,pval
, andci
.For
coxreg.multivar
objects, adata.frame
with columns:term
,pval
,term_label
,hr
,lcl
,ucl
,level
, andci
.
Functions
-
tidy(summary.coxph)
: Custom tidy method forsurvival::coxph()
summary results.Tidy the
survival::coxph()
results into adata.frame
to extract model results. -
tidy(coxreg.univar)
: Custom tidy method for a univariate Cox regression.Tidy up the result of a Cox regression model fitted by
fit_coxreg_univar()
. -
tidy(coxreg.multivar)
: Custom tidy method for a multivariate Cox regression.Tidy up the result of a Cox regression model fitted by
fit_coxreg_multivar()
.
See Also
Examples
library(survival)
library(broom)
set.seed(1, kind = "Mersenne-Twister")
dta_bladder <- with(
data = bladder[bladder$enum < 5, ],
data.frame(
time = stop,
status = event,
armcd = as.factor(rx),
covar1 = as.factor(enum),
covar2 = factor(
sample(as.factor(enum)),
levels = 1:4, labels = c("F", "F", "M", "M")
)
)
)
labels <- c("armcd" = "ARM", "covar1" = "A Covariate Label", "covar2" = "Sex (F/M)")
formatters::var_labels(dta_bladder)[names(labels)] <- labels
dta_bladder$age <- sample(20:60, size = nrow(dta_bladder), replace = TRUE)
formula <- "survival::Surv(time, status) ~ armcd + covar1"
msum <- summary(coxph(stats::as.formula(formula), data = dta_bladder))
tidy(msum)
## Cox regression: arm + 1 covariate.
mod1 <- fit_coxreg_univar(
variables = list(
time = "time", event = "status", arm = "armcd",
covariates = "covar1"
),
data = dta_bladder,
control = control_coxreg(conf_level = 0.91)
)
## Cox regression: arm + 1 covariate + interaction, 2 candidate covariates.
mod2 <- fit_coxreg_univar(
variables = list(
time = "time", event = "status", arm = "armcd",
covariates = c("covar1", "covar2")
),
data = dta_bladder,
control = control_coxreg(conf_level = 0.91, interaction = TRUE)
)
tidy(mod1)
tidy(mod2)
multivar_model <- fit_coxreg_multivar(
variables = list(
time = "time", event = "status", arm = "armcd",
covariates = c("covar1", "covar2")
),
data = dta_bladder
)
broom::tidy(multivar_model)