estimate_coef | R Documentation |
This function estimates the hazard ratios between arms when an interaction variable is given with specific values.
estimate_coef(
variable,
given,
lvl_var,
lvl_given,
coef,
mmat,
vcov,
conf_level = 0.95
)
variable , given |
( |
lvl_var , lvl_given |
( |
coef |
( |
mmat |
(named |
vcov |
( |
conf_level |
( |
Given the cox regression investigating the effect of Arm (A, B, C; reference A) and Sex (F, M; reference Female). The model is abbreviated: y ~ Arm + Sex + Arm x Sex. The cox regression estimates the coefficients along with a variance-covariance matrix for:
b1 (arm b), b2 (arm c)
b3 (sex m)
b4 (arm b: sex m), b5 (arm c: sex m)
Given that I want an estimation of the Hazard Ratio for arm C/sex M, the estimation will be given in reference to arm A/Sex M by exp(b2 + b3 + b5)/ exp(b3) = exp(b2 + b5), therefore the interaction coefficient is given by b2 + b5 while the standard error is obtained as $1.96 * sqrt(Var b2 + Var b5 + 2 * covariance (b2,b5))$ for a confidence level of 0.95.
A list of matrices (one per level of variable) with rows corresponding to the combinations of
variable
and given
, with columns:
coef_hat
: Estimation of the coefficient.
coef_se
: Standard error of the estimation.
hr
: Hazard ratio.
lcl, ucl
: Lower/upper confidence limit of the hazard ratio.
s_cox_multivariate()
.
library(dplyr)
library(survival)
ADSL <- tern_ex_adsl %>%
filter(SEX %in% c("F", "M"))
adtte <- tern_ex_adtte %>% filter(PARAMCD == "PFS")
adtte$ARMCD <- droplevels(adtte$ARMCD)
adtte$SEX <- droplevels(adtte$SEX)
mod <- coxph(
formula = Surv(time = AVAL, event = 1 - CNSR) ~ (SEX + ARMCD)^2,
data = adtte
)
mmat <- stats::model.matrix(mod)[1, ]
mmat[!mmat == 0] <- 0
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.