Skip to contents

[Deprecated]

This is a deprecated function. Use fit_coxreg_univar function instead.

Fit cox (proportional hazard) regression models including the treatment and a single covariate. Starting from a univariate model (e.g. survival model including an two-level arm predictor), a list of candidate alternative models including an additional covariate (optionally including the interaction terms) is tested.

Usage

s_cox_univariate(
  formula,
  data,
  covariates,
  interactions = FALSE,
  conf_level = 0.95,
  pval_method = c("wald", "likelihood"),
  increments = NULL,
  ...
)

Arguments

formula

(formula)
Specifies survival model. The arm variable needs to be wrapped in study_arm. The strata special will only be used for the stratified analysis. If there is not strata specification then the stratified analysis is omitted.

data

A data.frame which includes the variable in formula and covariate

covariates

a list of single right-hand-term formulas, if named, named will be used in the output

interactions

The interaction term should be included, default is FALSE.

conf_level

The level of confidence for the hazard ration interval estimations. Default is 0.95.

pval_method

The method used for estimation of p.values, should be one of "wald" (default) or "likelihood".

increments

If a quantitative variable is included, it is possible to provide the expected level of estimation for the interaction. Should then be list, item are vector specifying levels, the item are named after the covariate name as it appears in covariate formula.

...

parameters passed down to coxph()

  • ties a character string specifying the method for tie handling, one of exact (default), efron, breslow.

Value

A list with items:

n

the number of observations used for cox regression fit.

hr

hazard ratios of the arm.

ci

confidence interval of the estimated arm hazard ratio.

pval

p.value of the arm depending on the covariate included in the model.

lrt

p.value of the likelihood ratio test testing the interaction with the covariate.

covariates

the names of the covariate as provided or derived from variable name.

tstr

the strata term if included in the model.

Details

The estimation of the coefficient and confidence interval follows four methods depending on the inclusion of the interaction terms and specified level of a quantitative variable and follows. Four case are therefore discriminated: no interaction with the covariate (i), interaction with a qualitative variable (ii), interaction with a quantitative variable without (iii) or with a specified level (iv) for the estimation.

Warning

Note that s_cox_univariate() function is deprecated and will be removed in the coming releases. Please use the function fit_coxreg_univar() instead.

Examples

library(scda)
library(survival)

ADTTE <- synthetic_cdisc_data("latest")$adtte
ADTTE_f <- subset(ADTTE, PARAMCD == "OS") # _f: filtered
ADTTE_f <- within( # nolint
  data = subset(
    ADTTE_f,
    PARAMCD == "OS" &
      ARMCD %in% c("ARM A", "ARM B") &
      SEX %in% c("F", "M") &
      RACE %in% c("ASIAN", "BLACK OR AFRICAN AMERICAN", "WHITE")
  ),
  expr = { # nolint start
    set.seed(1)
    ARMCD <- droplevels(ARMCD)
    ARMCD <- relevel(ARMCD, "ARM B")
    SEX <- droplevels(SEX)
    RACE <- droplevels(RACE)
    X <- rnorm(n = length(ARM))
  } # nolint end
)
if (FALSE) {
s_cox_univariate(
  formula = Surv(time = AVAL, event = 1 - CNSR) ~ study_arm(ARMCD),
  data = ADTTE_f,
  covariates = list(~SEX)
)

s_cox_univariate(
  formula = Surv(time = AVAL, event = 1 - CNSR) ~ study_arm(ARMCD),
  data = ADTTE_f,
  covariates = list("Race" = ~RACE, ~AGE, "a rand. quant var with increments" = ~X),
  interactions = TRUE,
  increments = list(X = c(-1, 1)),
  conf_level = 0.95,
  pval_method = c("wald", "log-rank", "likelihood")[1]
)
}