Skip to contents

Compute the number of patients, the number of events, and the hazard ratio of treatment versus control in each level of each subgroup variable of a patient-level dataset.

Usage

group_analysis_summary(
  patient,
  variables = setdiff(colnames(patient), c("treatment", "time", "event"))
)

Arguments

patient

Patient-level survival data with subgroup columns, usually the output of group_sample_unconstrained(), group_sample_constrained(), group_optimize_unconstrained(), or group_optimize_constrained(). Must have the columns of the output of group_data_patient() and the subgroup columns named in variables.

variables

Character vector of unique names of subgroup columns in patient. Each subgroup column must be character or factor with no missing values. Defaults to every column of patient other than treatment, time, and event.

Value

A tibble with one row per subgroup level, ordered by subgroup variable as in variables and then by level, and the following columns:

  • variable: character, name of the subgroup variable.

  • level: character, level of the subgroup variable.

  • patients: integer, number of patients in the subgroup level.

  • events: integer, number of events in the subgroup level.

  • hazard_ratio: numeric, estimated hazard ratio of treatment versus control in the subgroup level, or NA if the model cannot be fit.

Details

For each level of each subgroup variable, group_analysis_summary() counts the patients and events in that level. These are the quantities \(n_k\) and \(e_k\) of vignette("framing", package = "retrogroup"), computed from the subgroup assignments in patient instead of assumed.

group_analysis_summary() also fits a Cox proportional hazards model by partial likelihood to the patients in each level, with treatment as the only covariate and the Efron method for ties. The fit uses a compiled Newton solver specialized to one binary covariate, and its estimate agrees with survival::coxph(ties = "efron") up to rounding error whenever the partial likelihood has a finite maximum. The hazard ratio is the exponential of the estimated coefficient of treatment versus control, the estimate of \(\exp(\beta_k)\) of vignette("framing", package = "retrogroup"). The log hazard ratio is the observed statistic \(\hat\beta_k(x)\) of the "Loss function" section of vignette("optimization", package = "retrogroup").

If the partial likelihood of some subgroup level has no finite maximum, for example because one of its arms has no patients or no events, the hazard_ratio of that level is NA. In those cases, survival::coxph() instead stops at a large finite estimate with a warning.

The levels of a factor subgroup column are its factor levels, in order, excluding levels with no patients. The levels of a character subgroup column are its sorted unique values.

See also

Examples

  patient <- group_data_patient(
    group_example_patient(),
    arm = "arm",
    treatment = "Lev+5FU",
    time = "time",
    event = "event"
  )
  summary <- group_data_summary(
    group_example_summary(),
    variable = "variable",
    level = "level",
    patients = "patients",
    events = "events",
    hazard_ratio = "hazard_ratio"
  )
  set.seed(0)
  sample <- group_sample_constrained(patient, summary)
  group_analysis_summary(sample)
#> # A tibble: 6 × 5
#>   variable level      patients events hazard_ratio
#>   <chr>    <chr>         <int>  <int>        <dbl>
#> 1 age      under 60        280    125        0.844
#> 2 age      60 or over      339    166        0.583
#> 3 node4    no              453    174        0.678
#> 4 node4    yes             166    117        0.701
#> 5 sex      female          312    151        0.829
#> 6 sex      male            307    140        0.563
  summary
#> # A tibble: 6 × 5
#>   variable level      patients events hazard_ratio
#>   <chr>    <chr>         <int>  <int>        <dbl>
#> 1 age      under 60        280    129        0.844
#> 2 age      60 or over      339    162        0.579
#> 3 node4    no              453    177        0.659
#> 4 node4    yes             166    114        0.732
#> 5 sex      female          312    152        0.863
#> 6 sex      male            307    139        0.519