| Title: | PS-Integrated Methods for Incorporating RWE in Clinical Studies |
|---|---|
| Description: | High-quality real-world data can be transformed into scientific real-world evidence (RWE) for regulatory and healthcare decision-making using proven analytical methods and techniques. For example, propensity score (PS) methodology can be applied to pre-select a subset of real-world data containing patients that are similar to those in the current clinical study in terms of covariates, and to stratify the selected patients together with those in the current study into more homogeneous strata. Then, methods such as the power prior approach or composite likelihood approach can be applied in each stratum to draw inference for the parameters of interest. This package provides functions that implement the PS-integrated RWE analysis methods proposed in Wang et al. (2019) <doi:10.1080/10543406.2019.1657133>, Wang et al. (2020) <doi:10.1080/10543406.2019.1684309> and Chen et al. (2020) <doi:10.1080/10543406.2020.1730877>. |
| Authors: | Chenguang Wang [aut, cre], Trustees of Columbia University [cph] (tools/make_cpp.R, R/stanmodels.R), Wei-Chen Chen [aut] |
| Maintainer: | Chenguang Wang <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 3.2 |
| Built: | 2026-05-16 06:57:55 UTC |
| Source: | https://github.com/olssol/psrwe |
This package provide R functions for conducting clinical studies with real-world evidence (RWE) incorporated in the study design and analysis.
We extend the Bayesian power prior approach for a single-arm study (the current study) to leverage external real-world data (RWD). We use propensity score methodology to pre-select a subset of real-world data containing patients that are similar to those in the current study in terms of covariates, and to stratify the selected patients together with those in the current study into more homogeneous strata. The power prior approach is then applied in each stratum to obtain stratum-specific posterior distributions, which are combined to complete the Bayesian inference for the parameters of interest.
A propensity score-integrated composite likelihood (PSCL) approach is developed for cases in which the control arm of a two-arm randomized controlled trial (RCT) (treated vs. control) is augmented with patients from real-world data (RWD) containing both clinical outcomes and covariates at the patient-level. The PSCL approach first estimates the propensity score for every patient as the probability of the patient being in the RCT rather than the RWD, and then stratifies all patients into strata based on the estimated propensity scores. Within each propensity score stratum, a composite likelihood function is specified and utilized to down-weight the information contributed by the RWD source. Estimates of the stratum-specific parameters are obtained by maximizing the composite likelihood function. These stratum-specific estimates are then combined to obtain an overall population-level estimate of the parameter of interest.
Chen WC, Wang C, Li H, Lu N, Tiwari R, Xu Y, Yue LQ. Propensity score-integrated composite likelihood approach for augmenting the control arm of a randomized controlled trial by incorporating real-world data. *Journal of Biopharmaceutical Statistics*. 2020; 30(3):508-520.
Wang C, Lu N, Chen WC, Li H, Tiwari R, Xu Y, Yue LQ. Propensity score-integrated composite likelihood approach for incorporating real-world evidence in single-arm clinical studies. *Journal of Biopharmaceutical Statistics*. 2020; 30(3):495-507.
Wang C, Li H, Chen WC, Lu N, Tiwari R, Xu Y, Yue LQ. Propensity score-integrated power prior approach for incorporating real-world evidence in single-arm clinical studies. *Journal of Biopharmaceutical Statistics*. 2019; 29(5):731-748.
Example dataset of a single arm study.
data(ex_dta)data(ex_dta)
A data frame with the following variables:
current, rwd
Binary outcome
Continuous outcome
Survival outcome in days
Event status (0=alive, 1=dead)
Covariates
Example dataset of a randomized study.
data(ex_dta_rct)data(ex_dta_rct)
A data frame with the following variables:
current, rwd
control, treatment
Continuous outcome
Covariates
Calculate difference measures using different metrics.
get_distance( cov0, cov1, metric = c("ovl", "ksd", "astd", "std", "abd", "ley", "mhb", "omkss") )get_distance( cov0, cov1, metric = c("ovl", "ksd", "astd", "std", "abd", "ley", "mhb", "omkss") )
cov0 |
Vector (or matrix for |
cov1 |
Vector (or matrix for |
metric |
Metric to use for calculating the distance with options:
(default)
|
A real value of the distance.
x <- rnorm(100, mean = 0, sd = 1) y <- rnorm(1000, mean = 1, sd = 2) get_distance(x, y, "ovl") get_distance(x, y, "abd")x <- rnorm(100, mean = 0, sd = 1) y <- rnorm(1000, mean = 1, sd = 2) get_distance(x, y, "ovl") get_distance(x, y, "abd")
S3 method for visualizing PS adjustment
## S3 method for class 'PSRWE_DTA' plot(x, plot_type = c("ps", "balance", "diff"), ...)## S3 method for class 'PSRWE_DTA' plot(x, plot_type = c("ps", "balance", "diff"), ...)
x |
Class |
plot_type |
Types of plots.
|
... |
Additional parameter for the plot |
S3 method for visualizing PS adjustment based on matching.
## S3 method for class 'PSRWE_DTA_MAT' plot(x, ...)## S3 method for class 'PSRWE_DTA_MAT' plot(x, ...)
x |
A list of class |
... |
Parameters for |
S3 method plotting estimation results
## S3 method for class 'PSRWE_RST' plot(x, ...)## S3 method for class 'PSRWE_RST' plot(x, ...)
x |
A list of class |
... |
Additional parameters. |
Print summary information of borrowing
## S3 method for class 'PSRWE_BOR' print(x, ...)## S3 method for class 'PSRWE_BOR' print(x, ...)
x |
A list of class |
... |
Additional parameters |
Print summary information of PS estimation results
## S3 method for class 'PSRWE_DTA' print(x, ...)## S3 method for class 'PSRWE_DTA' print(x, ...)
x |
A list of class |
... |
Parameters for |
Print summary information of PS estimation results
## S3 method for class 'PSRWE_DTA_MAT' print(x, ...)## S3 method for class 'PSRWE_DTA_MAT' print(x, ...)
x |
A list of class |
... |
Additional parameters |
Print summary information of outcome mean estimation results
## S3 method for class 'PSRWE_RST' print(x, ...)## S3 method for class 'PSRWE_RST' print(x, ...)
x |
A list of class |
... |
Additional parameters |
Print detail information of outcome analysis results
## S3 method for class 'PSRWE_RST_OUTANA' print(x, show_details = FALSE, show_rct = FALSE, show_pred_tps = NULL, ...)## S3 method for class 'PSRWE_RST_OUTANA' print(x, show_details = FALSE, show_rct = FALSE, show_pred_tps = NULL, ...)
x |
A list of class |
show_details |
Print out more observed summary |
show_rct |
Print out more analysis summary for RCT arms |
show_pred_tps |
Specified time points to be shown |
... |
Additional parameters |
Based on PS distances or number of current control subjects, split the total number of subjects to be borrowed from the external data source to each stratum
psrwe_borrow( dtaps, total_borrow, method = c("distance", "inverse_distance", "n_current", "n_external"), .drop_arg_fml = FALSE, ... )psrwe_borrow( dtaps, total_borrow, method = c("distance", "inverse_distance", "n_current", "n_external"), .drop_arg_fml = FALSE, ... )
dtaps |
A class |
total_borrow |
Total number of subjects to be borrowed |
method |
Method to split |
.drop_arg_fml |
internal use to drop arguments and call, this is only used in cjk. |
... |
Additional parameters for |
A class PSRWE_BORR list. It appends the following items to
the dtaps:
Proportion splitting the number of total borrow among strata.
The number of to be borrowed subjects in each stratum.
Weight parameter value in each stratum.
data(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current") ps_borrow <- psrwe_borrow(total_borrow = 20, dta_ps) ps_borrow ## Use different similarity metric ps_borrow_omkss <- psrwe_borrow(total_borrow = 20, dta_ps, metric = "omkss") ps_borrow_omkssdata(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current") ps_borrow <- psrwe_borrow(total_borrow = 20, dta_ps) ps_borrow ## Use different similarity metric ps_borrow_omkss <- psrwe_borrow(total_borrow = 20, dta_ps, metric = "omkss") ps_borrow_omkss
Estimate the confidence/credible interval for the PS-integrated approach.
psrwe_ci( dta_psrst, method_ci = c("wald", "wilson"), conf_int = 0.95, conf_type = c("log_log", "plain"), ... )psrwe_ci( dta_psrst, method_ci = c("wald", "wilson"), conf_int = 0.95, conf_type = c("log_log", "plain"), ... )
dta_psrst |
A returned object with class |
method_ci |
A method name for confidence interval (default wald) |
conf_int |
A two-sided level of confidence/credible limits (default 0.95) |
conf_type |
A type name of transformation for the confidence interval of PSKM approach |
... |
Other options |
method_ci = "wilson" is for binary outcomes only.
conf_type = "log_log" is for ps_km only.
A list with class name PSRWE_EST.
data(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current") ps_borrow <- psrwe_borrow(total_borrow = 30, dta_ps) ps_rst <- psrwe_compl(ps_borrow, v_outcome = "Y_Con") rst <- psrwe_ci(ps_rst) rstdata(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current") ps_borrow <- psrwe_borrow(total_borrow = 30, dta_ps) ps_rst <- psrwe_compl(ps_borrow, v_outcome = "Y_Con") rst <- psrwe_ci(ps_rst) rst
Estimate the mean of the outcome based on PS-integrated composite likelihood approach. Variance is estimated by Jack-Knife method. Applies to the case when there is only one external data source.
psrwe_compl( dta_psbor, v_outcome = "Y", outcome_type = c("continuous", "binary"), stderr_method = c("jk", "sjk", "cjk", "sbs", "cbs", "none"), n_bootstrap = 200, ... )psrwe_compl( dta_psbor, v_outcome = "Y", outcome_type = c("continuous", "binary"), stderr_method = c("jk", "sjk", "cjk", "sbs", "cbs", "none"), n_bootstrap = 200, ... )
dta_psbor |
A class |
v_outcome |
Column name corresponding to the outcome. |
outcome_type |
Type of outcomes: |
stderr_method |
Method for computing StdErr, see Details |
n_bootstrap |
Number of bootstrap samples (for bootstrap stderr) |
... |
Parameters for |
stderr_method include jk as default
using Jackknife method within each stratum,
sjk for simple Jackknife method for combined estimates
such as point estimates in single arm or treatment effects in RCT, or
cjk for complex Jackknife method including refitting PS model,
matching, trimming, calculating borrowing parameters, and
combining overall estimates.
Note that sjk may take a while longer to finish and
cjk will take even much longer to finish.
The sbs and cbs is for simple and complex Bootstrap
methods.
A data frame with class name PSRWE_RST. It contains the
composite estimation of the mean for each stratum as well as the
jackknife estimation for each subject. The results can be further
summarized by its S3 method summary.
The results can be also analyzed by psrwe_outana for outcome
analysis and inference.
data(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current") ps_borrow <- psrwe_borrow(total_borrow = 30, dta_ps) rst <- psrwe_compl(ps_borrow, v_outcome = "Y_Con") rstdata(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current") ps_borrow <- psrwe_borrow(total_borrow = 30, dta_ps) rst <- psrwe_compl(ps_borrow, v_outcome = "Y_Con") rst
Estimate the mean of the outcome based on PS-integrated composite likelihood approach with weights of ATT (WATT). Variance is estimated by Jack-Knife method. Applies to the case when there is only one external data source.
psrwe_compl_watt( dta_psbor, v_outcome = "Y", outcome_type = c("continuous", "binary"), stderr_method = c("jk", "sjk", "cjk", "sbs", "cbs", "none"), n_bootstrap = 200, ... )psrwe_compl_watt( dta_psbor, v_outcome = "Y", outcome_type = c("continuous", "binary"), stderr_method = c("jk", "sjk", "cjk", "sbs", "cbs", "none"), n_bootstrap = 200, ... )
dta_psbor |
A class |
v_outcome |
Column name corresponding to the outcome. |
outcome_type |
Type of outcomes: |
stderr_method |
Method for computing StdErr, see Details |
n_bootstrap |
Number of bootstrap samples (for bootstrap stderr) |
... |
Parameters for |
stderr_method include jk as default
using Jackknife method within each stratum,
sjk for simple Jackknife method for combined estimates
such as point estimates in single arm or treatment effects in RCT, or
cjk for complex Jackknife method including refitting PS model,
matching, trimming, calculating borrowing parameters, and
combining overall estimates.
Note that sjk may take a while longer to finish and
cjk will take even much longer to finish.
The sbs and cbs is for simple and complex Bootstrap
methods.
A data frame with class name PSRWE_RST. It contains the
composite estimation of the mean for each stratum as well as the
jackknife estimation for each subject. The results can be further
summarized by its S3 method summary.
The results can be also analyzed by psrwe_outana for outcome
analysis and inference.
data(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current", nstrata = 1) ps_borrow <- psrwe_borrow(total_borrow = 30, dta_ps) rst <- psrwe_compl_watt(ps_borrow, v_outcome = "Y_Bin") rstdata(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current", nstrata = 1) ps_borrow <- psrwe_borrow(total_borrow = 30, dta_ps) rst <- psrwe_compl_watt(ps_borrow, v_outcome = "Y_Bin") rst
Estimate propensity scores using logistic regression or random forest model.
psrwe_est( data, ps_fml = NULL, ps_method = c("logistic", "randomforest"), v_covs = "V1", v_grp = "Group", cur_grp_level = 1, v_arm = NULL, ctl_arm_level = NULL, stra_ctl_only = TRUE, nstrata = 5, trim_ab = c("both", "above", "below", "none"), .drop_arg_fml = FALSE, ... )psrwe_est( data, ps_fml = NULL, ps_method = c("logistic", "randomforest"), v_covs = "V1", v_grp = "Group", cur_grp_level = 1, v_arm = NULL, ctl_arm_level = NULL, stra_ctl_only = TRUE, nstrata = 5, trim_ab = c("both", "above", "below", "none"), .drop_arg_fml = FALSE, ... )
data |
Data frame with group assignment and covariates. |
ps_fml |
Propensity score (PS) formula. If |
ps_method |
Method to calculate propensity scores. Can be set to
|
v_covs |
Column names corresponding to covariates. |
v_grp |
Column name corresponding to group assignment. |
cur_grp_level |
Group level for the current study. Default is
|
v_arm |
Column name corresponding to arm assignment. |
ctl_arm_level |
Arm level for the control arm. Ignored for single-arm studies. |
stra_ctl_only |
Create strata by control arm patients only. Default
|
nstrata |
Number of PS strata to be created. |
trim_ab |
Trim external subjects who are above or below the
range of current study. Default |
.drop_arg_fml |
internal use to drop arguments and call, this is only used in cjk. |
... |
Additional parameters for calculating the propensity score to be
used in |
A list of class PSRWE_DAT with items:
Original data with column _ps_ for estimated PS scores
and _strata_ for PS stratum added.
PS formula for estimated PS scores.
Whether the current study is a randomized study.
Number of strata.
data(ex_dta) psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current")data(ex_dta) psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current")
Inference for the PS-integrated approach.
psrwe_infer( dta_psrst, alternative = c("less", "greater", "two_sided"), mu = 0, method_pval = c("wald", "score", "score_weighted"), ... )psrwe_infer( dta_psrst, alternative = c("less", "greater", "two_sided"), mu = 0, method_pval = c("wald", "score", "score_weighted"), ... )
dta_psrst |
A returned object with class |
alternative |
A character string for the alternative hypothesis that
must be one of |
mu |
A number indicating the true value of the parameter of interest
(or the difference in means for two arms),
|
method_pval |
A method name for p-value (default wald),
no impact for Bayesian method, and
|
... |
Other options |
A list with class name PSRWE_EST.
data(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current") ps_borrow <- psrwe_borrow(total_borrow = 30, dta_ps) ps_rst <- psrwe_compl(ps_borrow, v_outcome = "Y_Con") rst <- psrwe_infer(ps_rst) rstdata(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current") ps_borrow <- psrwe_borrow(total_borrow = 30, dta_ps) ps_rst <- psrwe_compl(ps_borrow, v_outcome = "Y_Con") rst <- psrwe_infer(ps_rst) rst
Match patients in external data source with patients in current study based on PS using nearest neighbor method.
psrwe_match( dta_ps, ratio = 3, strata_covs = NULL, caliper = 1, seed = NULL, method = c("nnwor", "optm"), .drop_arg_fml = FALSE, ... )psrwe_match( dta_ps, ratio = 3, strata_covs = NULL, caliper = 1, seed = NULL, method = c("nnwor", "optm"), .drop_arg_fml = FALSE, ... )
dta_ps |
A list of class |
ratio |
Matching ratio (RWD : Current) with default value 3 meaning 3:1 matching. |
strata_covs |
Stratification covariates for matching. |
caliper |
PS matching caliper width. Default 1. This specifies a width (euclidean distance) on the probability scale. |
seed |
Random seed. |
method |
matching algorithm for PS matching. |
.drop_arg_fml |
internal use to drop arguments and call, this is only used in cjk. |
... |
Additional parameters for matching |
A list of class PSRWE_DTA_MAT with items:
Original data with column _ps_ for estimated PS scores,
match_id for matched current study subject ID, and _strata_
for PS stratum added.
PS formula for estimated PS scores.
Number of strata.
Matching ratio.
data(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current") ## With neighest neighbor .remark_nnmatch <- function() { dta_ps_mat <- psrwe_match(dta_ps, ratio = 2, strata_covs = "V1", seed = 123) dta_ps_mat } ## Unmark below to run # .remark_nnmatch() ## With optmatch .remark_optmatch <- function() { warning("The optmatch package may restrict use (academic license).") dta_ps_opt <- psrwe_match(dta_ps, ratio = 2, strata_covs = "V1", method = "optm", seed = 123) dta_ps_opt } ## Unmark below to run if optmatch is available. # .remark_optmatch()data(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current") ## With neighest neighbor .remark_nnmatch <- function() { dta_ps_mat <- psrwe_match(dta_ps, ratio = 2, strata_covs = "V1", seed = 123) dta_ps_mat } ## Unmark below to run # .remark_nnmatch() ## With optmatch .remark_optmatch <- function() { warning("The optmatch package may restrict use (academic license).") dta_ps_opt <- psrwe_match(dta_ps, ratio = 2, strata_covs = "V1", method = "optm", seed = 123) dta_ps_opt } ## Unmark below to run if optmatch is available. # .remark_optmatch()
Report outcome analysis for the PS-integrated approach.
psrwe_outana( dta_psrst, method_ci = c("wald", "wilson"), conf_type = c("log_log", "plain"), conf_int = 0.95, alternative = c("less", "greater", "two_sided"), mu = 0, method_pval = c("wald", "score", "score_weighted"), ... )psrwe_outana( dta_psrst, method_ci = c("wald", "wilson"), conf_type = c("log_log", "plain"), conf_int = 0.95, alternative = c("less", "greater", "two_sided"), mu = 0, method_pval = c("wald", "score", "score_weighted"), ... )
dta_psrst |
A returned object with class |
method_ci |
A method name for confidence interval (default wald) |
conf_type |
A type name of transformation for the confidence interval of PSKM approach (default log_log) |
conf_int |
A two-sided level of confidence/credible limits (default 0.95) |
alternative |
A character string for the alternative hypothesis that
must be one of |
mu |
A number indicating the true value of the parameter of interest
(or the difference in means for two arms),
|
method_pval |
A method name for p-value (default wald),
no impact for Bayesian method, and
|
... |
Other options |
This function is mainly for summarizing and reporting the
outcome analysis for the PS-integrated estimation.
The input dta_psrst can be generated from the functions
psrwe_powerp, psrwe_compl, and
psrwe_survkm.
See the functions psrwe_ci and psrwe_infer
for the options of outcome analyses.
A list with class name PSRWE_EST_OUTANA.
data(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current") ps_borrow <- psrwe_borrow(total_borrow = 30, dta_ps) ps_rst <- psrwe_compl(ps_borrow, v_outcome = "Y_Con") rst <- psrwe_outana(ps_rst) rstdata(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current") ps_borrow <- psrwe_borrow(total_borrow = 30, dta_ps) ps_rst <- psrwe_compl(ps_borrow, v_outcome = "Y_Con") rst <- psrwe_outana(ps_rst) rst
Draw posterior samples of the parameters of interest for the PS-power prior approach
psrwe_powerp( dta_psbor, v_outcome = "Y", outcome_type = c("continuous", "binary"), prior_type = c("fixed", "random"), ..., seed = NULL )psrwe_powerp( dta_psbor, v_outcome = "Y", outcome_type = c("continuous", "binary"), prior_type = c("fixed", "random"), ..., seed = NULL )
dta_psbor |
A class |
v_outcome |
Column name corresponding to the outcome. |
outcome_type |
Type of outcomes: |
prior_type |
Whether treat power parameter as fixed ( |
... |
extra parameters for calling function |
seed |
Random seed. |
A class PSRWE_RST list with the following objects
Observed mean and SD of the outcome by group, arm and stratum
A list of estimated mean and SD of the outcome by stratum in the control arm
A list of estimated mean and SD of the outcome by stratum in the treatment arm for RCT
A list of estimated mean and SD of the treatment effect by stratum for RCT
Borrowing information from dta_psbor
Result from STAN sampling
data(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current") ps_borrow <- psrwe_borrow(total_borrow = 30, dta_ps) rst <- psrwe_powerp(ps_borrow, v_outcome = "Y_Con", seed = 123)data(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current") ps_borrow <- psrwe_borrow(total_borrow = 30, dta_ps) rst <- psrwe_powerp(ps_borrow, v_outcome = "Y_Con", seed = 123)
Draw posterior samples of the parameters of interest for the PS-power prior approach with weights of ATT (WATT)
psrwe_powerp_watt( dta_psbor, v_outcome = "Y", outcome_type = c("continuous", "binary"), prior_type = c("fixed", "random"), ..., seed = NULL )psrwe_powerp_watt( dta_psbor, v_outcome = "Y", outcome_type = c("continuous", "binary"), prior_type = c("fixed", "random"), ..., seed = NULL )
dta_psbor |
A class |
v_outcome |
Column name corresponding to the outcome. |
outcome_type |
Type of outcomes: |
prior_type |
Whether treat power parameter as fixed ( |
... |
extra parameters for calling function |
seed |
Random seed. |
A class PSRWE_RST list with the following objects
Observed mean and SD of the outcome by group, arm and stratum
A list of estimated mean and SD of the outcome by stratum in the control arm
A list of estimated mean and SD of the outcome by stratum in the treatment arm for RCT
A list of estimated mean and SD of the treatment effect by stratum for RCT
Borrowing information from dta_psbor
Result from STAN sampling
data(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current", nstrata = 1) ps_borrow <- psrwe_borrow(total_borrow = 30, dta_ps) rst <- psrwe_powerp_watt(ps_borrow, v_outcome = "Y_Bin", seed = 123)data(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current", nstrata = 1) ps_borrow <- psrwe_borrow(total_borrow = 30, dta_ps) rst <- psrwe_powerp_watt(ps_borrow, v_outcome = "Y_Bin", seed = 123)
Estimate the mean of a survival outcome at a given time point based on PS-integrated Kaplan-Meier approach. Variance can be estimated by Jackknife methods. Apply to the case when there is only one external data source.
psrwe_survkm( dta_psbor, pred_tp, v_time = "time", v_event = "event", stderr_method = c("naive", "jk", "sjk", "cjk", "sbs", "cbs", "none"), n_bootstrap = 200, ... )psrwe_survkm( dta_psbor, pred_tp, v_time = "time", v_event = "event", stderr_method = c("naive", "jk", "sjk", "cjk", "sbs", "cbs", "none"), n_bootstrap = 200, ... )
dta_psbor |
A class |
pred_tp |
A numeric value corresponding to time of interest (e.g., 365 days or 1 year) |
v_time |
Column name corresponding to event time |
v_event |
Column name corresponding to event status |
stderr_method |
Method for computing StdErr, see Details |
n_bootstrap |
Number of bootstrap samples (for bootstrap stderr) |
... |
Additional Parameters |
stderr_method includes naive as default which
mostly follows Greenwood formula,
jk using Jackknife method within each stratum,
sjk using simple Jackknife method for combined estimates
such as point estimates in single arm or treatment effects in RCT, or
cjk for complex Jackknife method including refitting PS model,
matching, trimming, calculating borrowing parameters, and
combining overall estimates.
Note that sjk may take a while longer to finish and
cjk will take even much longer to finish.
The sbs and cbs is for simple and complex Bootstrap
methods.
A data frame with class name PSRWE_RST. It contains the
composite estimation of the mean for each stratum as well as the
Jackknife estimation. The results can be further
summarized by its S3 method summary.
The results can be also analyzed by psrwe_outana for outcome
analysis and inference.
data(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current") ps_borrow <- psrwe_borrow(total_borrow = 30, dta_ps) rst <- psrwe_survkm(ps_borrow, pred_tp = 365, v_time = "Y_Surv", v_event = "Status") rstdata(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current") ps_borrow <- psrwe_borrow(total_borrow = 30, dta_ps) rst <- psrwe_survkm(ps_borrow, pred_tp = 365, v_time = "Y_Surv", v_event = "Status") rst
Log-rank test evaluates two-arm RCT for up to a given time point. Variance can be estimated by Jackknife methods. Apply to the case when there is only one external data source and two-arm RCT.
psrwe_survlrk( dta_psbor, pred_tp, v_time = "time", v_event = "event", stderr_method = c("naive", "jk", "sjk", "cjk", "sbs", "cbs", "none"), n_bootstrap = 200, ... )psrwe_survlrk( dta_psbor, pred_tp, v_time = "time", v_event = "event", stderr_method = c("naive", "jk", "sjk", "cjk", "sbs", "cbs", "none"), n_bootstrap = 200, ... )
dta_psbor |
A class |
pred_tp |
A numeric value corresponding to time of interest (e.g., 365 days or 1 year) |
v_time |
Column name corresponding to event time |
v_event |
Column name corresponding to event status |
stderr_method |
Method for computing StdErr (see Details) |
n_bootstrap |
Number of bootstrap samples (for bootstrap stderr) |
... |
Additional Parameters |
stderr_method includes naive as default which
mostly follows Greenwood formula,
jk using Jackknife method within each stratum,
sjk using simple Jackknife method for combined estimates
such as point estimates in single arm or treatment effects in RCT, or
cjk for complex Jackknife method including refitting PS model,
matching, trimming, calculating borrowing parameters, and
combining overall estimates.
Note that sjk may take a while longer to finish and
cjk will take even much longer to finish.
The sbs and cbs is for simple and complex Bootstrap
methods.
A data frame with class name PSRWE_RST_TESTANA.
It contains the test statistics of each stratum as well as the
Jackknife estimation. The results can be further
summarized by its S3 method summary.
The results can be also analyzed by psrwe_outana for outcome
analysis and inference.
data(ex_dta_rct) dta_ps_rct <- psrwe_est(ex_dta_rct, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current", v_arm = "Arm", ctl_arm_level = "control", ps_method = "logistic", nstrata = 5, stra_ctl_only = FALSE) ps_bor_rct <- psrwe_borrow(dta_ps_rct, total_borrow = 30) rst_lrk <- psrwe_survlrk(ps_bor_rct, pred_tp = 365, v_time = "Y_Surv", v_event = "Status") rst_lrkdata(ex_dta_rct) dta_ps_rct <- psrwe_est(ex_dta_rct, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current", v_arm = "Arm", ctl_arm_level = "control", ps_method = "logistic", nstrata = 5, stra_ctl_only = FALSE) ps_bor_rct <- psrwe_borrow(dta_ps_rct, total_borrow = 30) rst_lrk <- psrwe_survlrk(ps_bor_rct, pred_tp = 365, v_time = "Y_Surv", v_event = "Status") rst_lrk
RMST test evaluates two-arm RCT for up to a given time point. Variance can be estimated by Jackknife methods. Apply to the case when there is only one external data source and two-arm RCT.
psrwe_survrmst( dta_psbor, pred_tp, v_time = "time", v_event = "event", stderr_method = c("naive", "jk", "sjk", "cjk", "sbs", "cbs", "none"), n_bootstrap = 200, ... )psrwe_survrmst( dta_psbor, pred_tp, v_time = "time", v_event = "event", stderr_method = c("naive", "jk", "sjk", "cjk", "sbs", "cbs", "none"), n_bootstrap = 200, ... )
dta_psbor |
A class |
pred_tp |
A numeric value corresponding to time of interest (e.g., 365 days or 1 year) |
v_time |
Column name corresponding to event time |
v_event |
Column name corresponding to event status |
stderr_method |
Method for computing StdErr, see Details |
n_bootstrap |
Number of bootstrap samples (for bootstrap stderr) |
... |
Additional Parameters |
stderr_method includes naive as default which
mostly follows Greenwood formula,
jk using Jackknife method within each stratum,
sjk using simple Jackknife method for combined estimates
such as point estimates in single arm or treatment effects in RCT, or
cjk for complex Jackknife method including refitting PS model,
matching, trimming, calculating borrowing parameters, and
combining overall estimates.
Note that sjk may take a while longer to finish and
cjk will take even much longer to finish.
The sbs and cbs is for simple and complex Bootstrap
methods.
A data frame with class name PSRWE_RST_TESTANA.
It contains the test statistics of each stratum as well as the
Jackknife estimation. The results can be further
summarized by its S3 method summary.
The results can be also analyzed by psrwe_outana for outcome
analysis and inference.
data(ex_dta_rct) dta_ps_rct <- psrwe_est(ex_dta_rct, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current", v_arm = "Arm", ctl_arm_level = "control", ps_method = "logistic", nstrata = 5, stra_ctl_only = FALSE) ps_bor_rct <- psrwe_borrow(dta_ps_rct, total_borrow = 30) rst_rmst <- psrwe_survrmst(ps_bor_rct, pred_tp = 365, v_time = "Y_Surv", v_event = "Status") rst_rmstdata(ex_dta_rct) dta_ps_rct <- psrwe_est(ex_dta_rct, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current", v_arm = "Arm", ctl_arm_level = "control", ps_method = "logistic", nstrata = 5, stra_ctl_only = FALSE) ps_bor_rct <- psrwe_borrow(dta_ps_rct, total_borrow = 30) rst_rmst <- psrwe_survrmst(ps_bor_rct, pred_tp = 365, v_time = "Y_Surv", v_event = "Status") rst_rmst
Estimate parameter of interest based composite likelihood for a single PS stratum
rwe_cl( dta_cur, dta_ext, n_borrow = 0, outcome_type = c("continuous", "binary"), equal_sd = TRUE )rwe_cl( dta_cur, dta_ext, n_borrow = 0, outcome_type = c("continuous", "binary"), equal_sd = TRUE )
dta_cur |
Vector of outcome from a PS stratum in current study |
dta_ext |
Vector of outcome from a PS stratum in external data source |
n_borrow |
Number of subjects to be borrowed |
outcome_type |
Type of outcomes: |
equal_sd |
Boolean. whether sd is the same between the current study and external data source |
Maximum composite likelihood estimator of the mean
x <- rnorm(100, mean = 0, sd = 1) y <- rnorm(1000, mean = 1, sd = 2) rwe_cl(x, y, n_borrow = 20, equal_sd = FALSE)x <- rnorm(100, mean = 0, sd = 1) y <- rnorm(1000, mean = 1, sd = 2) rwe_cl(x, y, n_borrow = 20, equal_sd = FALSE)
Estimate parameter of interest based composite likelihood for a single PS stratum with weights of ATT (WATT).
rwe_cl_watt( dta_cur, dta_ext, n_borrow = 0, dta_ext_watt_di = NULL, outcome_type = c("continuous", "binary"), equal_sd = TRUE )rwe_cl_watt( dta_cur, dta_ext, n_borrow = 0, dta_ext_watt_di = NULL, outcome_type = c("continuous", "binary"), equal_sd = TRUE )
dta_cur |
Vector of outcome from a PS stratum in current study |
dta_ext |
Vector of outcome from a PS stratum in external data source |
n_borrow |
Number of subjects to be borrowed |
dta_ext_watt_di |
Weights of ATT for subjects in external data source |
outcome_type |
Type of outcomes: |
equal_sd |
Boolean. whether sd is the same between the current study and external data source |
Maximum composite likelihood estimator of the mean
x <- rnorm(100, mean = 0, sd = 1) y <- rnorm(1000, mean = 1, sd = 2) rwe_cl_watt(x, y, n_borrow = 20, equal_sd = FALSE)x <- rnorm(100, mean = 0, sd = 1) y <- rnorm(1000, mean = 1, sd = 2) rwe_cl_watt(x, y, n_borrow = 20, equal_sd = FALSE)
Cut a sequence of numbers into bins.
The cut points are chosen such that there will with equal numbers in each bin
for x. By default, values of y that are outside the range of
x will be excluded from the bins, unless they are in the
keep_inx.
rwe_cut( x, y = x, breaks = 5, keep_inx = NULL, trim_ab = c("both", "above", "below", "none") )rwe_cut( x, y = x, breaks = 5, keep_inx = NULL, trim_ab = c("both", "above", "below", "none") )
x |
Vector of values based on which cut points will be determined |
y |
Vector of values to be cut, default to be the same as |
breaks |
Number of cut points |
keep_inx |
Indices of y that will be categorized as 1 or the largest bin even if their values are out of range of x, i.e. the y's that will not be trimmed |
trim_ab |
Trim external subjects who are above or below the
range of current study. Default |
A vector of stratum assignment for y. The y's that are outside
the range of x and not in keep_inx are assigned NA
in the result.
x <- rnorm(100, mean = 0, sd = 1) y <- rnorm(1000, mean = 1, sd = 2) rwe_cut(x, y, breaks = 5)x <- rnorm(100, mean = 0, sd = 1) y <- rnorm(1000, mean = 1, sd = 2) rwe_cut(x, y, breaks = 5)
Estimate survival probability based on Kaplan-Meier estimator for a single PS stratum
rwe_km( dta_cur, dta_ext = NULL, n_borrow = 0, pred_tps = NULL, stderr_method = "naive" )rwe_km( dta_cur, dta_ext = NULL, n_borrow = 0, pred_tps = NULL, stderr_method = "naive" )
dta_cur |
Matrix of time and event from a PS stratum in current study |
dta_ext |
Matrix of time and event from a PS stratum in external data source |
n_borrow |
Number of subjects to be borrowed |
pred_tps |
Time points to be estimated (unique and sorted) |
stderr_method |
Method for computing StdErr (available for naive only) |
Estimation of survival probabilities at time pred_tps
Estimate log-rank estimates for a single PS stratum
rwe_lrk( dta_cur, dta_ext, dta_cur_trt, n_borrow = 0, pred_tps = NULL, stderr_method = "naive" )rwe_lrk( dta_cur, dta_ext, dta_cur_trt, n_borrow = 0, pred_tps = NULL, stderr_method = "naive" )
dta_cur |
Matrix of time and event from a PS stratum in current study (control arm only) |
dta_ext |
Matrix of time and event from a PS stratum in external data source (control arm only) |
dta_cur_trt |
Matrix of time and event from a PS stratum in current study (treatment arm only) |
n_borrow |
Number of subjects to be borrowed |
pred_tps |
All time points of events (unique and sorted) |
stderr_method |
Method for computing StdErr (available for naive only) |
Estimation of log-rank estimates at time pred_tps
Estimate RMST estimates for a single PS stratum
rwe_rmst( dta_cur, dta_ext, dta_cur_trt, n_borrow = 0, pred_tps = NULL, stderr_method = "naive" )rwe_rmst( dta_cur, dta_ext, dta_cur_trt, n_borrow = 0, pred_tps = NULL, stderr_method = "naive" )
dta_cur |
Matrix of time and event from a PS stratum in current study (control arm only) |
dta_ext |
Matrix of time and event from a PS stratum in external data source (control arm only) |
dta_cur_trt |
Matrix of time and event from a PS stratum in current study (treatment arm only) |
n_borrow |
Number of subjects to be borrowed |
pred_tps |
All time points of events (unique and sorted) |
stderr_method |
Method for computing StdErr (available for naive only) |
Estimation of RMST estimates at time pred_tps
Call STAN models. Called by psrwe_powerp.
rwe_stan( lst_data, stan_mdl = c("powerps", "powerpsbinary", "powerp"), chains = 4, iter = 2000, warmup = 1000, control = list(adapt_delta = 0.95), ... )rwe_stan( lst_data, stan_mdl = c("powerps", "powerpsbinary", "powerp"), chains = 4, iter = 2000, warmup = 1000, control = list(adapt_delta = 0.95), ... )
lst_data |
List of study data to be passed to STAN |
stan_mdl |
STAN model including
|
chains |
STAN parameter. Number of Markov chainsm |
iter |
STAN parameter. Number of iterations |
warmup |
STAN parameter. Number of burnin. |
control |
STAN parameter. See |
... |
other options to call STAN sampling such as |
Result from STAN sampling
Get number of subjects and the distances of PS distributions for each PS stratum.
## S3 method for class 'PSRWE_DTA' summary( object, metric = c("ovl", "ksd", "std", "abd", "ley", "mhb", "omkss"), min_n0 = 10, ... )## S3 method for class 'PSRWE_DTA' summary( object, metric = c("ovl", "ksd", "std", "abd", "ley", "mhb", "omkss"), min_n0 = 10, ... )
object |
A list of class |
metric |
Metric to use for calculating the distance with options:
(default)
|
min_n0 |
threshold for number of external subjects, below which the external data in the current stratum will be ignored by setting the PS distance to 0. Default value 10. |
... |
Additional parameters. |
A list with columns:
A data frame with Stratum, number of subjects in RWD, current study, number of subjects in control and treatment arms for RCT studies, and distance in PS distributions.
A data frame with overall number of not-trimmed subjects in RWD, number of patients in current study, number of subjects in control and treatment arms for RCT studies, and distance in PS distributions.
Vector of total number of total RWD patients, number of trimmed RWD patients, and total number of current study patients.
PS model.
Metric used for calculating the distance.
data(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current") dta_ps ## With different similarity metric print(dta_ps, metric = "omkss") dta_ps_sum <- summary(dta_ps, metric = "omkss")data(ex_dta) dta_ps <- psrwe_est(ex_dta, v_covs = paste("V", 1:7, sep = ""), v_grp = "Group", cur_grp_level = "current") dta_ps ## With different similarity metric print(dta_ps, metric = "omkss") dta_ps_sum <- summary(dta_ps, metric = "omkss")
Get number of subjects for each PS stratum.
## S3 method for class 'PSRWE_DTA_MAT' summary(object, ...)## S3 method for class 'PSRWE_DTA_MAT' summary(object, ...)
object |
A list of class |
... |
Additional parameters. |
A list with columns:
A data frame with Stratum (defined by covariates), number of subjects in RWD, current study, number of subjects in control and treatment arms for RCT studies.
A data frame with overall number of not-trimmed subjects in RWD, number of patients in current study, number of subjects in control and treatment arms for RCT studies.
Vector of total number of total RWD patients, number of trimmed
RWD patients, total number of current study patients, number of current
control patients with less than ratio matched RWD subjects.
PS model.
Number of current control subjects matched with
ratio, 0 and other number of RWD subjects.
Matching ratio.
S3 method summarizing overall estimation results
## S3 method for class 'PSRWE_RST' summary(object, ...)## S3 method for class 'PSRWE_RST' summary(object, ...)
object |
A list of class |
... |
Additional parameters. |
A list with data frames for the borrowing and estimation results.
Summary information of outcome analysis results
## S3 method for class 'PSRWE_RST_OUTANA' summary(object, pred_tps = NULL, ...)## S3 method for class 'PSRWE_RST_OUTANA' summary(object, pred_tps = NULL, ...)
object |
A list of class |
pred_tps |
Specified time points |
... |
Additional parameters |