Title: | Shrinkage Based Forest Plots |
---|---|
Description: | Subgroup analyses are routinely performed in clinical trial analyses. From a methodological perspective, two key issues of subgroup analyses are multiplicity (even if only predefined subgroups are investigated) and the low sample sizes of subgroups which lead to highly variable estimates, see e.g. Yusuf et al (1991) <doi:10.1001/jama.1991.03470010097038>. This package implements subgroup estimates based on Bayesian shrinkage priors, see Carvalho et al (2019) <https://proceedings.mlr.press/v5/carvalho09a.html>. In addition, estimates based on penalized likelihood inference are available, based on Simon et al (2011) <doi:10.18637/jss.v039.i05>. The corresponding shrinkage based forest plots address the aforementioned issues and can complement standard forest plots in practical clinical trial analyses. |
Authors: | Mar Vazquez Rabunal [aut], Daniel Sabanés Bové [aut], Marcel Wolbers [aut], Isaac Gravestock [cre], F. Hoffmann-La Roche AG [cph, fnd] |
Maintainer: | Isaac Gravestock <[email protected]> |
License: | Apache License 2.0 |
Version: | 0.1.1 |
Built: | 2024-11-27 06:35:19 UTC |
Source: | CRAN |
Function to obtain the average hazard ratio.
ahr_estimation(x_subg, dummy_subg, est_coef, h0, gamma = 1)
ahr_estimation(x_subg, dummy_subg, est_coef, h0, gamma = 1)
x_subg |
( |
dummy_subg |
( |
est_coef |
( |
h0 |
( |
gamma |
( |
Average hazard ratio
ahr_estimation( elastic_net_surv$design1, elastic_net_surv$dummy1, elastic_net_surv$est_coef, elastic_net_surv$h0 )
ahr_estimation( elastic_net_surv$design1, elastic_net_surv$dummy1, elastic_net_surv$est_coef, elastic_net_surv$h0 )
Average Hazard Estimation based on Kaplan-Meier Estimates
ahr_from_km(resp, trt, data, status, t_quantile = 0.99)
ahr_from_km(resp, trt, data, status, t_quantile = 0.99)
resp |
( |
trt |
( |
data |
( |
status |
( |
t_quantile |
( |
Estimates can be unstable due to the variability of the Kaplan-Meier estimates
in the tails. The t_quantile
argument can address this, e.g. by setting it to
0.95, the 5% highest times will be discarded. By default, the 1% highest times
are discarded.
The estimated average hazard ratio of the treatment (second level of trt
)
versus the control (first level of trt
).
ahr_from_km("tt_pfs", "arm", example_data, "ev_pfs") ahr_from_km("tt_pfs", "arm", example_data, "ev_pfs", t_quantile = 0.95)
ahr_from_km("tt_pfs", "arm", example_data, "ev_pfs") ahr_from_km("tt_pfs", "arm", example_data, "ev_pfs", t_quantile = 0.95)
Function to create a data set with the results for all the methods in order to compare them.
compare(...)
compare(...)
... |
Objects of class |
List with a data.frame
of the estimated subgroup treatment effects,
with the overall treatment effect and with the response type of our data.
compare(naivepop_fit_surv, naive_fit_surv, elastic_net_fit_surv)
compare(naivepop_fit_surv, naive_fit_surv, elastic_net_fit_surv)
The dummy design matrix from example_data
considering just observations
from subgroup x_1a.
design_dummy1
design_dummy1
A matrix
with 0 and 1 indicating the subgroups of each of the observations.
This is an artificial example.
The design matrix from example_data
considering just observations
from subgroup x_1a.
design_matrix1
design_matrix1
A matrix
with 0 and 1 indicating the subgroups of each of the observations
and their interactions with the treatment variable.
This is an artificial example.
Function to fit the elastic net penalization model to the data. This model penalizes the interaction between the covariates and the treatment but leaves unpenalized the main effects.
elastic_net( resp, trt, subgr, covars, data, resptype = c("survival", "binary"), alpha, status = NULL )
elastic_net( resp, trt, subgr, covars, data, resptype = c("survival", "binary"), alpha, status = NULL )
resp |
( |
trt |
( |
subgr |
( |
covars |
( |
data |
( |
resptype |
( |
alpha |
( |
status |
( |
List with fit
, model
, resptype
, data
, alpha
,
design_matrix
, design_dummy
, y
, subgr_names
.
elastic_net( "tt_pfs", "arm", c("x_1", "x_2"), c("x_1", "x_2", "x_3"), example_data, "survival", 1, "ev_pfs" )
elastic_net( "tt_pfs", "arm", c("x_1", "x_2"), c("x_1", "x_2", "x_3"), example_data, "survival", 1, "ev_pfs" )
A fitted model with the elastic_net function and binary data.
elastic_net_fit_bin
elastic_net_fit_bin
A elastic_net
object fitted with example_data
, considering as subgroup
variables all the covariates x_1, ..., x_10 and binary
response type.
This is an artificial example.
A fitted model with the elastic_net function and survival data.
elastic_net_fit_surv
elastic_net_fit_surv
A elastic_net
object fitted with example_data
, considering as subgroup
variables all the covariates x_1, ..., x_10 and survival
response type.
This is an artificial example.
List with the cumulative baseline hazard, with the estimated coefficients of the model fitted with an elastic net and survival data, with the general design matrix and with the design and dummy matrices for subgroup x_1a.
elastic_net_surv
elastic_net_surv
A list
with three elements:
h0
: the cumulative baseline hazard.
est_coef
: the estimated coefficients of the fitted model.
x
: the design matrix of the model.
dummy1
: the dummy matrix of the model for subgroup x_1a.
design1
: the design matrix of the model for subgroup x_1a.
This is an artificial example.
The coefficients of the model elastic_net_fit_bin
when lambda takes the
value that leads to minimal cross validation error.
est_coef_bin1
est_coef_bin1
A matrix
with the coefficients of the elastic net model.
This is an artificial example.
A simulated data set for a realistic scenario of a clinical trial.
example_data
example_data
A data.frame
with 1000 rows and 14 columns:
id
: Integer variable with the id of the patient.
arm
: Factor variable with 2 levels: control and treatment.
x_1
, x_2
, x_3
, x_4
, x_5
, x_6
, x_7
, x_8
, x_9
, x_10
:
Factor variables that represent covariates of the patients
(e.g. sex, region, race, etc.).
tt_pfs
: Continuous variable with the progression free survival time
of each patient.
ev_pfs
: Binary variable with the progression free survival status
of each patient. 0 indicates that the event of interest did not happen
and 1 indicates that it did.
This is an artificial dataset.
Function to generate stacked data by the subgroups considered in the model.
generate_stacked_data( base_model, subgroup_model, data, resptype = c("survival", "binary") )
generate_stacked_data( base_model, subgroup_model, data, resptype = c("survival", "binary") )
base_model |
( |
subgroup_model |
( |
data |
( |
resptype |
( |
Data frame of the stacked data.
generate_stacked_data(Surv(tt_pfs, ev_pfs) ~ arm, ~ x_1 + x_2, example_data, "survival")
generate_stacked_data(Surv(tt_pfs, ev_pfs) ~ arm, ~ x_1 + x_2, example_data, "survival")
Function to fit a bayesian shrinkage model with a regularized horseshoe prior on the interaction coefficients between the subgrouping covariates and the treatment.
horseshoe( resp, trt, subgr, covars, data, resptype = c("survival", "binary"), status = NULL, ... )
horseshoe( resp, trt, subgr, covars, data, resptype = c("survival", "binary"), status = NULL, ... )
resp |
( |
trt |
( |
subgr |
( |
covars |
( |
data |
( |
resptype |
( |
status |
( |
... |
Additional arguments from the |
List with fit
, model
, resptype
, data
, alpha
,
design_matrix
, design_dummy
, y
, subgr_names
.
horseshoe("ev_pfs", "arm", c("x_1", "x_2"), c("x_1", "x_2", "x_3"), example_data, "binary", chains = 1, seed = 0, control = list(adapt_delta = 0.95), iter = 50 # In practice, you need to omit this or set it much higher! )
horseshoe("ev_pfs", "arm", c("x_1", "x_2"), c("x_1", "x_2", "x_3"), example_data, "binary", chains = 1, seed = 0, control = list(adapt_delta = 0.95), iter = 50 # In practice, you need to omit this or set it much higher! )
A fitted model with the horseshoe function and binary data.
horseshoe_fit_bin
horseshoe_fit_bin
A horseshoe
object fitted with example_data
, considering as subgroup
variables just the covariates x_1 and x_2 and binary
response type.
This is an artificial example.
A fitted model with the horseshoe function and survival data.
horseshoe_fit_surv
horseshoe_fit_surv
A horseshoe
object fitted with example_data
, considering as subgroup
variables just the covariates x_1 and x_2 and survival
response type.
This is an artificial example.
Function to estimate the subgroup log-odds ratio for binary data.
lor_estimation(x_subg, dummy_subg, est_coef)
lor_estimation(x_subg, dummy_subg, est_coef)
x_subg |
( |
dummy_subg |
( |
est_coef |
( |
Log-odds ratio of the studied subgroup.
lor_estimation(design_matrix1, design_dummy1, est_coef_bin1)
lor_estimation(design_matrix1, design_dummy1, est_coef_bin1)
Function to fit the naive models to the data of each one of the subgroups.
naive( resp, trt, subgr, data, resptype = c("survival", "binary"), status = NULL )
naive( resp, trt, subgr, data, resptype = c("survival", "binary"), status = NULL )
resp |
( |
trt |
( |
subgr |
( |
data |
( |
resptype |
( |
status |
( |
List with fit
, estimates
, model
, resptype
, data
.
naive("tt_pfs", "arm", c("x_1", "x_2"), example_data, "survival", "ev_pfs")
naive("tt_pfs", "arm", c("x_1", "x_2"), example_data, "survival", "ev_pfs")
A fitted model with the naive function and binary data.
naive_fit_bin
naive_fit_bin
A naive
object fitted with example_data
, considering as subgroup
variables all the covariates x_1, ..., x_10 and binary
response type.
This is an artificial example.
A fitted model with the naive function and survival data.
naive_fit_surv
naive_fit_surv
A naive
object fitted with example_data
, considering as subgroup
variables all the covariates x_1, ..., x_10 and survival
response type.
This is an artificial example.
Function to fit the naive overall population model to the data. This model is going to estimate the subgroup treatment effects with the overall population treatment effect.
naivepop(resp, trt, data, resptype = c("survival", "binary"), status = NULL)
naivepop(resp, trt, data, resptype = c("survival", "binary"), status = NULL)
resp |
( |
trt |
( |
data |
( |
resptype |
( |
status |
( |
List with fit
, model
, resptype
, data
.
naivepop("tt_pfs", "arm", example_data, "survival", "ev_pfs")
naivepop("tt_pfs", "arm", example_data, "survival", "ev_pfs")
A fitted model with the naivepop function and binary data.
naivepop_fit_bin
naivepop_fit_bin
A naivepop
object fitted with example_data
, considering as subgroup
variables all the covariates x_1, ..., x_10 and binary
response type.
This is an artificial example.
A fitted model with the naivepop function and survival data.
naivepop_fit_surv
naivepop_fit_surv
A naivepop
object fitted with example_data
, considering as subgroup
variables all the covariates x_1, ..., x_10 and survival
response type.
This is an artificial example.
Function to obtain a forest plot with all the different fitted models in order to compare their performance.
## S3 method for class 'compare.data' plot(x, ...)
## S3 method for class 'compare.data' plot(x, ...)
x |
( |
... |
Additional arguments to plot. |
Forest plot with all the methods that are compared.
plot(compare(naivepop_fit_surv, naive_fit_surv, elastic_net_fit_surv))
plot(compare(naivepop_fit_surv, naive_fit_surv, elastic_net_fit_surv))
Plot the forest plot of the summary of a elastic_net
object.
## S3 method for class 'summary.elastic_net' plot(x, ...)
## S3 method for class 'summary.elastic_net' plot(x, ...)
x |
( |
... |
Additional arguments to plot. |
Forest plot
plot(summary(elastic_net_fit_surv))
plot(summary(elastic_net_fit_surv))
Plot the forest plot of the summary of a horseshoe
object.
## S3 method for class 'summary.horseshoe' plot(x, ...)
## S3 method for class 'summary.horseshoe' plot(x, ...)
x |
( |
... |
Additional arguments to plot. |
Forest plot
plot(summary(horseshoe_fit_bin))
plot(summary(horseshoe_fit_bin))
Plot the forest plot of the summary of a naive
object.
## S3 method for class 'summary.naive' plot(x, ...)
## S3 method for class 'summary.naive' plot(x, ...)
x |
( |
... |
Additional arguments to plot. |
Forest plot
plot(summary(naive_fit_surv))
plot(summary(naive_fit_surv))
Function to preprocess the data and obtain the design matrices corresponding to a model with just interaction of the covariates with the treatment, to a model with just the main effects and to a model just with the covariates and one-hot encoding.
preprocess(trt, subgr, covars, data)
preprocess(trt, subgr, covars, data)
trt |
( |
subgr |
( |
covars |
( |
data |
( |
List with design_ia
, design_main
, design_dummy
, subgr_names
.
preprocess("arm", c("x_1", "x_2"), c("x_1", "x_2", "x_3"), example_data)
preprocess("arm", c("x_1", "x_2"), c("x_1", "x_2", "x_3"), example_data)
Function that prints the summary of a elastic_net object
## S3 method for class 'summary.elastic_net' print(x, ...)
## S3 method for class 'summary.elastic_net' print(x, ...)
x |
( |
... |
Other arguments of print. |
The summary of the object.
print(summary(elastic_net_fit_bin))
print(summary(elastic_net_fit_bin))
Function that prints the summary of a horseshoe object
## S3 method for class 'summary.horseshoe' print(x, ...)
## S3 method for class 'summary.horseshoe' print(x, ...)
x |
( |
... |
Other arguments of print. |
The summary of the object.
print(summary(horseshoe_fit_bin))
print(summary(horseshoe_fit_bin))
Function that prints the summary of a naive object
## S3 method for class 'summary.naive' print(x, ...)
## S3 method for class 'summary.naive' print(x, ...)
x |
( |
... |
Other arguments of print. |
The summary of the object.
print(summary(naive_fit_bin))
print(summary(naive_fit_bin))
Function that prints the summary of a naivepop object
## S3 method for class 'summary.naivepop' print(x, ...)
## S3 method for class 'summary.naivepop' print(x, ...)
x |
( |
... |
Other arguments of print. |
The summary of the object.
print(summary(naivepop_fit_bin))
print(summary(naivepop_fit_bin))
This function uses a block diagonal covariance matrix for the underlying multivariate normal data to create the design matrix in blocks of 10, see the details.
simul_covariates(n, p_catvar = 10, add_contvars = FALSE, arm_factor = FALSE)
simul_covariates(n, p_catvar = 10, add_contvars = FALSE, arm_factor = FALSE)
n |
( |
p_catvar |
( |
add_contvars |
( |
arm_factor |
( |
The following pattern is repeated for the covariate blocks:
The first 5 covariates are uncorrelated with everything.
The covariates 6 to 8 have "moderate" correlation (0.25) between each other.
The covariates 9 and 10 have "high" correlation (0.5).
By default, only the resulting categorical covariates obtained by thresholding are included. Optionally also the original continuous covariates are included in the returned design matrix.
The design matrix.
simul_covariates(n = 10, p_catvar = 3, add_contvars = FALSE) simul_covariates(n = 10, p_catvar = 3, add_contvars = TRUE) simul_covariates(n = 10, p_catvar = 3, add_contvars = TRUE, arm_factor = TRUE)
simul_covariates(n = 10, p_catvar = 3, add_contvars = FALSE) simul_covariates(n = 10, p_catvar = 3, add_contvars = TRUE) simul_covariates(n = 10, p_catvar = 3, add_contvars = TRUE, arm_factor = TRUE)
This combines the covariates simulation via simul_covariates()
with 10
categorical covariates, and the PFS simulation via simul_pfs()
.
simul_data(n, add_interaction = FALSE, coefs, ...)
simul_data(n, add_interaction = FALSE, coefs, ...)
n |
( |
add_interaction |
( |
coefs |
( |
... |
additional parameters apart from the linear predictor values
needed for |
Regression coefficients are for an AFT with over-parametrized dummy coding for arm-subgroup interactions.
A combined data.frame
with the id
column, the design matrix and the
PFS outcomes.
set.seed(321) simul_data( n = 100, coefs = c(arm1 = 1), sigma_aft = 1, recr_duration = 0.2, rate_cens = 2, n_events = 20 )
set.seed(321) simul_data( n = 100, coefs = c(arm1 = 1), sigma_aft = 1, recr_duration = 0.2, rate_cens = 2, n_events = 20 )
Simulation of Progression Free Survival Times
simul_pfs( lp_aft, sigma_aft, recr_duration, rate_cens, n_events, add_uncensored_pfs = FALSE )
simul_pfs( lp_aft, sigma_aft, recr_duration, rate_cens, n_events, add_uncensored_pfs = FALSE )
lp_aft |
( |
sigma_aft |
( |
recr_duration |
( |
rate_cens |
( |
n_events |
( |
add_uncensored_pfs |
( |
A data.frame
with columns tt_pfs
(PFS time) and ev_pfs
(corresponding
event indicator with 1 for an event and 0 for censored), and optionally
tt_pfs_uncens
.
set.seed(123) simul_pfs( lp_aft = rnorm(100), sigma_aft = 1, recr_duration = 0.2, rate_cens = 2, n_events = 20 )
set.seed(123) simul_pfs( lp_aft = rnorm(100), sigma_aft = 1, recr_duration = 0.2, rate_cens = 2, n_events = 20 )
Function to obtain the estimated treatment effect in each one of the considered subgroups.
subgroups(object, est_coef, h0 = NULL, gamma = 1)
subgroups(object, est_coef, h0 = NULL, gamma = 1)
object |
( |
est_coef |
( |
h0 |
( |
gamma |
( |
data.frame
with the subgroup names and with the estimated subgroup
treatment effects.
subgroups( elastic_net_fit_surv, elastic_net_surv$est_coef, elastic_net_surv$h0 )
subgroups( elastic_net_fit_surv, elastic_net_surv$est_coef, elastic_net_surv$h0 )
Function to obtain the naive subgroup treatment effects of an object fitted
with the elastic_net
function.
## S3 method for class 'elastic_net' summary(object, gamma = 1, l = NULL, lambda = NULL, ...)
## S3 method for class 'elastic_net' summary(object, gamma = 1, l = NULL, lambda = NULL, ...)
object |
( |
gamma |
( |
l |
( |
lambda |
( |
... |
Arguments of summary |
Object of class summary.elastic_net
which is a list
with the
estimated subgroup treatment effects, the resptype
, the confidence level
and the value of alpha
.
summary(elastic_net_fit_surv)
summary(elastic_net_fit_surv)
Function to obtain the estimated subgroup treatment effects from a horseshoe
model and a credible interval for them.
## S3 method for class 'horseshoe' summary(object, conf = 0.95, gamma = 1, l = NULL, m = 50, ...)
## S3 method for class 'horseshoe' summary(object, conf = 0.95, gamma = 1, l = NULL, m = 50, ...)
object |
( |
conf |
( |
gamma |
( |
l |
( |
m |
( |
... |
Arguments of summary. |
Object of class summary.horseshoe
which is a list
with the
approximated posterior distribution of the treatment
effects, a data.frame
with the estimated subgroup treatment effect
(with the median) and the bounds of the credible intervals, the resptype
and the confidence level.
summary(horseshoe_fit_bin)
summary(horseshoe_fit_bin)
Function to obtain the naive subgroup treatment effects of an object fitted
with the naive
function.
## S3 method for class 'naive' summary(object, conf = 0.95, ...)
## S3 method for class 'naive' summary(object, conf = 0.95, ...)
object |
( |
conf |
( |
... |
Arguments of summary. |
Object of class summary.elastic_net
which is a list
with a
data.frame
with 4 columns (the subgroup variables, the estimated
treatment effect and the low and high bounds of the confidence interval of the
treatment effect), the resptype
and the confidence level.
summary(naive_fit_surv)
summary(naive_fit_surv)
Function to obtain the overall subgroup treatment effect of a naivepop object.
## S3 method for class 'naivepop' summary(object, ...)
## S3 method for class 'naivepop' summary(object, ...)
object |
( |
... |
Arguments of summary. |
Object of class summary.naivepop
which is a list
with the
estimated subgroup treatment effects and the resptype
.
summary(naivepop_fit_surv)
summary(naivepop_fit_surv)
Function to obtain the average survival curve from all individual survival curves.
survival_curves(x, h0, est_coef)
survival_curves(x, h0, est_coef)
x |
( |
h0 |
( |
est_coef |
( |
The survival probabilities at the sorted event times.
survival_curves( elastic_net_surv$x, elastic_net_surv$h0, elastic_net_surv$est_coef )
survival_curves( elastic_net_surv$x, elastic_net_surv$h0, elastic_net_surv$est_coef )
Function to obtain the estimated posterior distribution of the subgroup treatment effects considering a horseshoe fitted model.
trt_horseshoe(object, gamma = 1, l = NULL, m = 50)
trt_horseshoe(object, gamma = 1, l = NULL, m = 50)
object |
( |
gamma |
( |
l |
( |
m |
( |
Approximated posterior distribution of the subgroup treatment effects.
trt_horseshoe(horseshoe_fit_surv, m = 1)
trt_horseshoe(horseshoe_fit_surv, m = 1)