The subtee subbuild function

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

In addition to the modelling functions, the package includes the subbuild function that may be useful when defining the subgroup covariates to use in the analysis.

Obtaining the data

We use the prca data that was used in Rosenkranz (2016) https://onlinelibrary.wiley.com/doi/abs/10.1002/bimj.201500147

library(subtee)
################################################################################
# The data comes from a clinical trial of an prostate cancer 
# treatment
# Data is loaded from Royston, Patrick, and Willi Sauerbrei. 
# Multivariable model-building: a pragmatic approach to 
# regression anaylsis based on fractional polynomials for 
# modelling continuous variables. Vol. 777. John Wiley & Sons, 2008. 
# https://www.imbi.uni-freiburg.de/Royston-Sauerbrei-book
prca = get_prca_data()

Building subgroups

The subbuild function basically creates binary subgroup indicator variables. For example, if we need to create the subgroup indicator for the group of subjects older than 65 years old, we simply specify this expression in the function

subgroups <- subbuild(data = prca, AGE > 65)
head(subgroups)

When a continuous covariate is given with no cutoff, the functions will then create n.cuts + 1 subgroups with approximately equal sample sizes.

subgroups <- subbuild(data = prca, AGE, n.cuts = 4)
head(subgroups)

The indicator variable that the subject had bone metastasis at baseline, BM, contains only 0s and 1s but it is possible to create the indicator using subbuild.

subgroups <- subbuild(data = prca, BM == 1)
head(subgroups)

Doing this may be useful for consistency as the subbuild may take several expressions to define all the candidate subgroups to be analysed at once.

cand.groups <- subbuild(prca, 
                        BM == 1, PF == 1, HX == 1,
                        STAGE == 4, AGE > 65, WT > 100)
head(cand.groups)

If no expressions are given subbuild generates the binary subgroup indicators based on all covariates in the data set (here restrict to columns 2 to 7) and default settings

cand.groups <- subbuild(prca[,2:7])
head(cand.groups)

Equivalent to the above statement, subgroup indicators are created for the named covariates based on default settings

cand.groups <- subbuild(prca, AGE, WT, SBP, DBP, SZ, AP)
head(cand.groups)

The matrix with all the candidate subgroups will still need to be concatenated with the original data.frame (or at least the response and treatment variables) to be used in the fitting functions unadj, modav, and bagged.

fitdat <- cbind(prca[, c("SURVTIME", "CENS", "RX")], cand.groups)
head(fitdat)

Note that the names for the subgroup defining variables are not standard R names. This can be modified using the option make.valid.names = TRUE.

cand.groups <- subbuild(prca, 
                        BM == 1, PF == 1, HX == 1,
                        STAGE == 4, AGE > 65, WT > 100, make.valid.names = TRUE)
head(cand.groups)

However, the fitting functions in the package allow to use expressions as variable names and this will lead to more informative plots and summary tables.



Try the subtee package in your browser

Any scripts or data that you put into this service are public.

subtee documentation built on March 22, 2022, 5:07 p.m.