RIC: R Package for the Relative Impact Characteristic (RIC) Curve
RIC is an R Package for the Relative Impact Characteristic (RIC) Curve: a novel graphical tool that visualizes and quantifies the population-level consequences of implementing diagnostic and prognostic biomarkers. RIC can be installed through GitHub.
If you use the R Package or RIC functions, please cite:
#' Calculates the relevant RIC statistics (p(x), q(x), and AUCi) given a random sample of marker and corresponding treatment benefit.
#' In clinical trials and observational studies the net treatment benefit is rarely available for each individual, as
#' the same person is either a control or a treatment case, and rarely both. However, if this information is available, ric_empirical can be used to calculate relevant RIC statistics.
#' @param xb_data nx2 matrix with first column being the random draws from marker values and the second being an unbiased estimate of treatment benefit at that marker value
#' @param b_bar expected benefit of treating all eligible patients vs. treating no one. Should be populated with expected benefit of treatment without testing ONLY when the outcome is a policy-relevant metric that includes the consequence of testing, otherwise the sample mean of benefits will be used;
#' @return p(x), q(x), and AUCi
if(is.null(b_bar)) sum_b<-sum(b) else sum_b<-b_bar*n
for(i in 1:n)
#' Returns RIC statistics p(x), q(x, AUCi, and local slope when a parametric distribution for the joint distribution of marker value and expected treatment benefit is assumed.
#' Note that this function does not need any data. Equations are provided in Appendix II of the paper.
#' @param p_x points on the x-axis of ric (p(x)): can be scalar or vector
#' @param mu_x mean of marker value
#' @param mu_b mean of expected treatment benefit
#' @param sd_x SD of marker value
#' @param sd_b SD of expected treatment benefit
#' @param rho correlation coefficient between marker and benefit. Note: do not use negative value as the underlying assumption (without loss of generality) is that higher marker value is associated with higher treatment benefit;
#' @param type normal or lognormal
#' @return p(x), q(x), and AUCi
#Recover marker values associated with x-axis;
#' GLM-based RIC estimator. Needs a GLM regression object and data to use for G-computation.
#' In real world clinical trials and observational studies, net treatment effect is generally not available at the indivdiaul level.
#' However, G-Computation can be used to estimate net benefit by fitting a regression. ric_regression calculates relevant RIC statistics using the appropriate
#' regression object and dataset.
#' @param reg_object a glm regression object (results of model fitting)
#' @param pred_data data for G-computation. It must have a marker column named x and a treatment column named tx. Note that if there is variable follow-up time they should all be set to a unique value (e.g., one unit of time) in the prediction dataset to estimate rate
#' @return RIC estimates
#Containing estimates of expected outcomes (event count) if no one is treated
#Containing estimates of expected outcomes (event count) if everyone is treated
#Expected benefit of treating all
#the first column is biomarker value(x), the second is treatment benefit (b)
#' Calculating AUCi using the method of forced choice as explained in the text (Appendix I); loops over all possible pairs and estimates the expected benefit of treating only the one with higher biomarker value
#' @param xb_data xb_data. Please refer to the paper
#' @return the expected benefit of treating with higher biomarker value
auci_mfc <- function(xb_data)
for(i in 1:(n-1))
for(j in (i+1):n)