require(beanz);
In patient-centered outcomes research, it is vital to assess the heterogeneity of treatment effects (HTE) when making health care decisions for an individual patient or a group of patients. Nevertheless, it remains challenging to evaluate HTE based on information collected from clinical studies that are often designed and conducted to evaluate the efficacy of a treatment for the overall population. The Bayesian framework offers a principled and flexible approach to estimate and compare treatment effects across subgroups of patients defined by their characteristics.
R package beanz provides functions to facilitate the conduct of Bayesian analysis of HTE and a web-based graphical user interface for users to conduct such Bayesian analysis in an interactive and user-friendly manner.
There are two types of data structures that beanz recognizes:
Summary treatment effect data: Each row should represent a subgroup with covariates that define the subgroup, estimated treatment effect in the subgroup and variance for the estimation.
Patient level raw data: Each row should represent a patient with covariates that define the subgroup in which the patient belongs to, treatment indicator and outcome. The outcome can be binary, continuous, or time to event.
The beanz package provides dataset solvd.sub from the SOLVD trial as an example Patient level raw data dataset.
If Patient level raw data is provided, the package provides function bzGetSubgrpRaw for estimating subgroup effect for each subgroup. The return value from bzGetSubgrpRaw is a data frame with the format of Summary treatment effect data.
The example is as follows:
var.cov <- c("lvef", "sodium", "any.vasodilator.use"); var.resp <- "y"; var.trt <- "trt"; var.censor <- "censor"; resptype <- "survival"; subgrp.effect <- bzGetSubgrpRaw(solvd.sub, var.resp = var.resp, var.trt = var.trt, var.cov = var.cov, var.censor = var.censor, resptype = resptype); print(subgrp.effect);
The function bzCallStan calls rstan::sampling to draw samples for different Bayesian models. The following models are available in the current version of beanz:
The following examples show how No subgroup effect model (nse), Simple regression model (sr) and Basic shrinkage model (bs*) are called:
var.estvar <- c("Estimate", "Variance"); rst.nse <- bzCallStan("nse", dat.sub=subgrp.effect, var.estvar = var.estvar, var.cov = var.cov, par.pri = c(B=1000), chains=4, iter=4000, warmup=2000, seed=1000, cores=1); rst.sr <- bzCallStan("sr", dat.sub=subgrp.effect, var.estvar = var.estvar, var.cov = var.cov, par.pri = c(B=1000, C=1000), chains=4, iter=4000, warmup=2000, seed=1000, cores=1); rst.bs <- bzCallStan("bs", dat.sub=subgrp.effect, var.estvar = var.estvar, var.cov = var.cov, par.pri = c(B=1000, D=1), chains=4, iter=4000, warmup=2000, seed=1000, cores=1);
Posterior subgroup treatment effect can be summarized and presented by functions bzSummary, bzPlot and bzForest. These functions allows to include a subgroup from another model (i.e. No subgroup effect model) as a reference in the results.
sel.grps <- c(1,4,5); tbl.sub <- bzSummary(rst.sr, ref.stan.rst=rst.nse, ref.sel.grps=1); print(tbl.sub); bzPlot(rst.sr, sel.grps = sel.grps, ref.stan.rst=rst.nse, ref.sel.grps=1); bzForest(rst.sr, sel.grps = sel.grps, ref.stan.rst=rst.nse, ref.sel.grps=1);
tbl.sub <- bzSummary(rst.bs, ref.stan.rst=rst.nse, ref.sel.grps=1); print(tbl.sub); bzPlot(rst.bs, sel.grps = sel.grps, ref.stan.rst=rst.nse, ref.sel.grps=1); bzForest(rst.bs, sel.grps = sel.grps, ref.stan.rst=rst.nse, ref.sel.grps=1);
Posterior subgroup treatment effect can be compared between subgroups by functions bzSummaryComp, bzPlotComp and bzForestComp.
tbl.sub <- bzSummaryComp(rst.sr, sel.grps=sel.grps); print(tbl.sub); bzPlot(rst.sr, sel.grps = sel.grps); bzForest(rst.sr, sel.grps = sel.grps);
tbl.sub <- bzSummaryComp(rst.bs, sel.grps=sel.grps); print(tbl.sub); bzPlotComp(rst.bs, sel.grps = sel.grps); bzForestComp(rst.bs, sel.grps = sel.grps);
beanz provides function bzRptTbl to generate the summary posterior subgroup treatment effect table from the model selected by DIC (i.e. the model with the smallest DIC):
lst.rst <- list(nse=rst.nse, sr=rst.sr, bs=rst.bs); tbl.summary <- bzRptTbl(lst.rst, dat.sub = subgrp.effect, var.cov = var.cov); print(tbl.summary);
Function bzPredSubgrp generates the predictive distribution of the subgrooup treatment effects.
pred.dist <- bzPredSubgrp(rst.sr, dat.sub=subgrp.effect, var.estvar = var.estvar); head(pred.dist);
With package shiny installed, beaz provides a web-based graphical user interface (GUI) for conducting the HTE analysis in an user-friendly interactive manner. The GUI can be started by
bzShiny();
Package beanz provides function bzGailSimon that implements the Gail-Simon test for qualitative interactions:
gs.pval <- bzGailSimon(subgrp.effect$Estimate, sqrt(subgrp.effect$Variance)); print(gs.pval);
The result show that there is no significant qualitative interactions according to the Gail-Simon test.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.