mrct_four_sets: The four patient sets of a regional-consistency analysis

View source: R/mrct_four_sets.R

mrct_four_setsR Documentation

The four patient sets of a regional-consistency analysis

Description

Fits the unadjusted two-sample Cox model on each set of the regional-consistency analysis, from columns you name: all patients, the region, region(G^*) (the region without the true harmed subgroup, when truth.name is given) and region(\hat G) (the region without the subgroup \hat H). The sets and their labels are those of mrct_case_study() and mrct_trial_analysis(), and print() and plot() draw on the same code.

Usage

mrct_four_sets(
  df,
  outcome.name,
  event.name,
  treat.name,
  region.name,
  in_Hhat = NULL,
  truth.name = NULL
)

## S3 method for class 'mrct_four_sets'
print(x, digits = 3, ...)

## S3 method for class 'mrct_four_sets'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

## S3 method for class 'mrct_four_sets'
plot(
  x,
  which = c("forest", "km"),
  xlim = c(0.3, 2),
  time_unit = NULL,
  analysis_time = NULL,
  ...
)

Arguments

df

A data frame with one row per patient.

outcome.name, event.name, treat.name

Columns: the time, the event indicator (1 = event) and the treatment (1 = experimental).

region.name

The region column (1 = in the region, 0 = not).

in_Hhat

Logical, one value per row: membership of \hat H, for instance get_dfpred(df, sg.harm = fit$sg.harm, version = 2)$treat.recommend == 0. NULL (the default) means nothing is declared: region(\hat G) is the whole region.

truth.name

Optional column of the true harmed subgroup (1 = in H^*). It adds the region(G^*) row and the 2 x 2 tables of \hat H against H^*; without it neither appears.

x

An mrct_four_sets object.

digits

Digits for hazard ratios. Default 3.

...

Unused.

row.names, optional

Unused, as in as.data.frame().

which

Any of "forest", "km". Default both.

xlim

Hazard-ratio range of the forest plot. Default c(0.3, 2); intervals are clipped to it.

time_unit

Character. The label of the Kaplan-Meier time axis; NULL (the default) labels it "time".

analysis_time

The Kaplan-Meier axis's upper limit. NULL (the default) uses the longest follow-up in the trial.

Value

An object of class mrct_four_sets, a list with

  • sets: the table, also returned by as.data.frame(): set, label, n, n_exp, n_ctl, events_exp, events_ctl, and the Cox fit on the set: hr, lo, hi (Wald 95%), se_loghr. The rows are itt_all, itt_region, region_Gstar (with truth.name) and region_Ghat.

  • confusion: with truth.name, a list of two integer vectors c(TP, FP, FN, TN) of \hat H against H^*, nonregion and region; else NULL.

  • trial, in_Hhat, and call_args, the column names.

See Also

mrct_trial_analysis() for the whole pipeline on an observed trial; mrct_case_study() for a simulated trial.

Examples

set.seed(1)
n <- 400
d <- data.frame(time = rexp(n, 0.1), event = rbinom(n, 1, 0.8),
                treat = rbinom(n, 1, 0.5), region = rbinom(n, 1, 0.25),
                x = rbinom(n, 1, 0.3))
fs4 <- mrct_four_sets(d, "time", "event", "treat", region.name = "region",
                      in_Hhat = d$x == 1)
fs4
as.data.frame(fs4)[, c("set", "n", "hr", "lo", "hi")]
plot(fs4, which = "forest")


forestsearch documentation built on Nov. 15, 2026, 9:06 a.m.