Fits a Cox model for a subgroup and returns estimate and standard error.
Usage
get_Cox_sg(
df_sg,
cox.formula,
est.loghr = TRUE,
cox_initial = log(1),
treat.name = NULL
)Arguments
- df_sg
Data frame for subgroup.
- cox.formula
Cox model formula.
- est.loghr
Logical. Is estimate on log(HR) scale?
- cox_initial
Numeric. Starting value for the treatment coefficient, passed to
coxph()asinitwhen the formula has a single term. Defaultlog(1)- treat.name
Character or
NULL. Name of the treatment term whose coefficient is the effect of interest. When the formula is adjusted for covariates the fit has multiple coefficients; supplyingtreat.nameextracts only that term's estimate and SE.NULL(default) preserves the historical behaviour of returning every coefficient (correct for the treatment-only formula).
Examples
if (FALSE) { # \dontrun{
library(survival)
df <- data.frame(
tte = gbsg$rfstime / 30.4375,
event = gbsg$status,
treat = gbsg$hormon
)
formula <- build_cox_formula("tte", "event", "treat")
result <- get_Cox_sg(df, cox.formula = formula)
exp(result$est_obs) # hazard ratio
} # }