-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6d18c9e
Showing
64 changed files
with
10,306 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Package: EventPredInCure | ||
Title: Event Prediction Including Cured Population | ||
Version: 1.0 | ||
Date: 2023-12-19 | ||
Authors@R: | ||
c(person("Bo", "Wei", , "bowei1990@gmail.com", role = c("aut", "cre"), | ||
comment = c(ORCID = "0000-0002-4430-2882")), | ||
person("Kaifeng", "Lu", , "kaifenglu@gmail.com", role = c("aut"), | ||
comment = c(ORCID = "0000-0002-6160-7119")), | ||
person("Brent", "McHenry", , "brent.mchenry@beigene.com", role = c("aut"))) | ||
Description: Predicts enrollment and events assumed enrollment and treatment-specific time-to-event models, and calculates test statistics for time-to-event data with cured population based on the simulation.Methods for prediction event in the existence of cured population are as described in : Chen, Tai-Tsang(2016) <doi:10.1186/s12874-016-0117-3>. | ||
License: GPL (>= 2) | ||
Encoding: UTF-8 | ||
RoxygenNote: 7.2.3 | ||
Imports: perm (>= 1.0.0.2), msm (>= 1.7.0), MLEcens (>= 0.1.7), KMsurv | ||
(>= 0.1.5), dplyr (>= 1.1.0), rlang (>= 1.0.6), plotly (>= | ||
4.10.1), survival (>= 2.41-3), splines (>= 3.5.0), Matrix (>= | ||
1.2-14), mvtnorm (>= 1.1-3), rstpm2 (>= 1.6.1), numDeriv (>= | ||
2016.8-1.1), tmvtnsim (>= 0.1.3), erify (>= 0.4.0), stats (>= | ||
3.5.0), utils (>= 4.1.2), lubridate (>= 1.9.2), flexsurv (>= | ||
2.2.2), MASS (>= 7.3.54) | ||
Depends: R (>= 3.5.0) | ||
LazyData: true | ||
NeedsCompilation: no | ||
Packaged: 2024-01-11 21:53:14 UTC; bo1.wei@beigenecorp.net | ||
Author: Bo Wei [aut, cre] (<https://orcid.org/0000-0002-4430-2882>), | ||
Kaifeng Lu [aut] (<https://orcid.org/0000-0002-6160-7119>), | ||
Brent McHenry [aut] | ||
Maintainer: Bo Wei <bowei1990@gmail.com> | ||
Repository: CRAN | ||
Date/Publication: 2024-01-12 10:00:05 UTC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
c77dcfc0a1bd659dc98d2f05c717c463 *DESCRIPTION | ||
31b0d6c6c517e64082981d6f8946d3b2 *NAMESPACE | ||
6acd3d7c2933bf5b429f9d2ce41e5a74 *R/Chen_2016_event_time.R | ||
bda73999aec27f1fad418c104ddcab30 *R/Chen_2016_event_time_abovetime0.R | ||
e64b4b85e89df8865534873467fceedd *R/Chen_2016_event_time_piecewise_exp_abovetime0.R | ||
8b9644f21356989aa7fc667a7e1ccd39 *R/EventPredInCure-package.R | ||
8d5d9398313b95da524a0823f351f7ec *R/FH_test.R | ||
932bc6d6c300226d1c5185c1bed69bc9 *R/SP_Chen_exponential.R | ||
ddac2d52e445825635ed20aedd6e1b0e *R/SP_Chen_log_logistic.R | ||
866472a0afbc0ef6fbc502b18eb3c99b *R/SP_Chen_log_normal.R | ||
47d6c9ec4b66af996683c09b54b9d692 *R/SP_Chen_piecewise_exponential.R | ||
7c44b80b966b41f1977ade86011a2ac7 *R/SP_Chen_weibull.R | ||
1cb9e8c93d7ec6c878a5a77151a9ae74 *R/b4pst.R | ||
e590cab346562c5c2339d11790bfb300 *R/data.R | ||
cc252ef67d68e74fee526a323029ab4d *R/fitDropout.R | ||
d3cea18e4ebf333c5c4c7f95a67e1c31 *R/fitEnrollment.R | ||
1c9a9e284e46ae5d00f40204f8ff2f3f *R/fitEvent.R | ||
59ac7e63776e022bb03cd7756fef8d7e *R/getPrediction.R | ||
fe7b938475479f047cd64eca6152ac89 *R/loglik_Chen_exponential.R | ||
2aa10c61b869864d183abbaf3115287a *R/loglik_Chen_log_logistic.R | ||
3455362faf308b45b708bc530d162b0b *R/loglik_Chen_log_normal.R | ||
b77df62f4aa9df69fbcf50015ae25479 *R/loglik_Chen_piecewise_exponential.R | ||
3a745f5f3bb7b0393bb25aee5ee7a12f *R/loglik_Chen_weibull.R | ||
88b7aa41422f1587ed04993ca731ca2a *R/predictEnrollment.R | ||
dfd594cd22f4e223f6ae92f0cb078e2b *R/predictEvent.R | ||
3e84b82654198df6042ae864ec59aa04 *R/smed.R | ||
201b321d9fb40df5108cf48d08c22b79 *R/summarizeObserved.R | ||
44e0b552a28ee6534c295b3be8e7c9f2 *R/test_plot.R | ||
90101bdc447f005ddf1b42302fd2d96d *R/test_procedure.R | ||
7af23bdd28c417e82d903de2a12fbdd5 *R/tte.R | ||
4c9acf70a69934f0cf80ffcc01c8162b *data/finalData.rda | ||
d1d8f7e6018867873ec9b19910c19758 *data/interimData1.rda | ||
6fcceffb1322ded2359b32bda1147c03 *data/interimData2.rda | ||
cb53f817f25558dc00303d14b77d29db *man/Chen_2016_event_time.Rd | ||
646de7df21ca1403c71f5c6421d596ff *man/Chen_2016_event_time_abovetime0.Rd | ||
6adef9bb2064203552578587a726187f *man/Chen_2016_event_time_piecewise_exp_abovetime0.Rd | ||
a46b62cd46d71bb82541a3a4ce8ea2ff *man/EventPredInCure-package.Rd | ||
c8fc31196be7e3ddced342223bbe96d6 *man/FH_test.Rd | ||
36d24cdf540663cd93ba3274f5130526 *man/SP_Chen_exponential.Rd | ||
feef7a0b7cbe1b6192b7cfe481673aba *man/SP_Chen_log_logistic.Rd | ||
39d8a0046b2e04b364bdb6bd8af1fb2d *man/SP_Chen_log_normal.Rd | ||
5da9bbf764960a6f4f26486a98eebcf4 *man/SP_Chen_piecewise_exponential.Rd | ||
90e636d65af9b7fed7d811aeaa463e09 *man/SP_Chen_weibull.Rd | ||
743a396b942b85a210872bb43019282e *man/b4pst.Rd | ||
6466d7cfb2fda493f8eea7832a84a783 *man/finalData.Rd | ||
61f458a925ebc393051784111d6d0b0b *man/fitDropout.Rd | ||
7dfd71fdea5fe7829398ee802d6196cf *man/fitEnrollment.Rd | ||
b2df3acbc437701eee5dfb80941222f8 *man/fitEvent.Rd | ||
b0ae032b80b1658fe3c417b577dece08 *man/getPrediction.Rd | ||
9de229720633e784f155bb7a37c7c155 *man/interimData1.Rd | ||
ef237d5c0fc12c4942464243365df0be *man/interimData2.Rd | ||
44a781c67c812c653ad41fc405e69704 *man/loglik_Chen_exponential.Rd | ||
220ed0f2739c13dfb427a679eb80ce87 *man/loglik_Chen_log_logistic.Rd | ||
d1e6dc96d080a35590fbb7ef5bacb558 *man/loglik_Chen_log_normal.Rd | ||
20ff2347c7883aed08ee168461d792ab *man/loglik_Chen_piecewise_exponential.Rd | ||
97783b4baf3ee88aa2ff58d87ee206e3 *man/loglik_Chen_weibull.Rd | ||
d79050f1ed3bb3d154d612810024f518 *man/predictEnrollment.Rd | ||
8d5b426e9d5dc5e9d13792f396982e8d *man/predictEvent.Rd | ||
dede2b8e608b0f64dc13e9aaf92451fd *man/smed.Rd | ||
3552f0f10515b0635090764d49774430 *man/summarizeObserved.Rd | ||
11491c90b376a4b0cd6c59cceaf85886 *man/test_plot.Rd | ||
8d22d4491a7bb17b160a06723ff41201 *man/test_procedure.Rd | ||
3190926402321cc543f63900a29e614b *man/tte.Rd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(Chen_2016_event_time) | ||
export(Chen_2016_event_time_abovetime0) | ||
export(Chen_2016_event_time_piecewise_exp_abovetime0) | ||
export(FH_test) | ||
export(SP_Chen_exponential) | ||
export(SP_Chen_log_logistic) | ||
export(SP_Chen_log_normal) | ||
export(SP_Chen_piecewise_exponential) | ||
export(SP_Chen_weibull) | ||
export(b4pst) | ||
export(fitDropout) | ||
export(fitEnrollment) | ||
export(fitEvent) | ||
export(getPrediction) | ||
export(loglik_Chen_exponential) | ||
export(loglik_Chen_log_logistic) | ||
export(loglik_Chen_log_normal) | ||
export(loglik_Chen_piecewise_exponential) | ||
export(loglik_Chen_weibull) | ||
export(predictEnrollment) | ||
export(predictEvent) | ||
export(smed) | ||
export(summarizeObserved) | ||
export(test_plot) | ||
export(test_procedure) | ||
export(tte) | ||
importFrom(Matrix,bdiag) | ||
importFrom(dplyr,"%>%") | ||
importFrom(dplyr,arrange) | ||
importFrom(dplyr,as_tibble) | ||
importFrom(dplyr,bind_rows) | ||
importFrom(dplyr,cross_join) | ||
importFrom(dplyr,filter) | ||
importFrom(dplyr,group_by) | ||
importFrom(dplyr,mutate) | ||
importFrom(dplyr,n) | ||
importFrom(dplyr,rename) | ||
importFrom(dplyr,rename_all) | ||
importFrom(dplyr,row_number) | ||
importFrom(dplyr,select) | ||
importFrom(dplyr,slice) | ||
importFrom(dplyr,summarize) | ||
importFrom(dplyr,tibble) | ||
importFrom(erify,check_bool) | ||
importFrom(erify,check_class) | ||
importFrom(erify,check_content) | ||
importFrom(erify,check_n) | ||
importFrom(erify,check_positive) | ||
importFrom(flexsurv,dllogis) | ||
importFrom(flexsurv,flexsurvspline) | ||
importFrom(flexsurv,pllogis) | ||
importFrom(flexsurv,psurvspline) | ||
importFrom(flexsurv,qsurvspline) | ||
importFrom(flexsurv,rsurvspline) | ||
importFrom(mvtnorm,rmvnorm) | ||
importFrom(numDeriv,grad) | ||
importFrom(plotly,add_lines) | ||
importFrom(plotly,add_ribbons) | ||
importFrom(plotly,hide_legend) | ||
importFrom(plotly,layout) | ||
importFrom(plotly,plot_ly) | ||
importFrom(rlang,.data) | ||
importFrom(rstpm2,vuniroot) | ||
importFrom(splines,bs) | ||
importFrom(stats,dlnorm) | ||
importFrom(stats,dweibull) | ||
importFrom(stats,loess.smooth) | ||
importFrom(stats,optim) | ||
importFrom(stats,optimHess) | ||
importFrom(stats,pexp) | ||
importFrom(stats,plnorm) | ||
importFrom(stats,plogis) | ||
importFrom(stats,pnorm) | ||
importFrom(stats,pweibull) | ||
importFrom(stats,qlogis) | ||
importFrom(stats,qnorm) | ||
importFrom(stats,quantile) | ||
importFrom(stats,rbinom) | ||
importFrom(stats,reorder) | ||
importFrom(stats,rexp) | ||
importFrom(stats,rlnorm) | ||
importFrom(stats,rmultinom) | ||
importFrom(stats,rnorm) | ||
importFrom(stats,runif) | ||
importFrom(stats,rweibull) | ||
importFrom(stats,uniroot) | ||
importFrom(stats,var) | ||
importFrom(survival,Surv) | ||
importFrom(survival,survfit) | ||
importFrom(survival,survreg) | ||
importFrom(tmvtnsim,rtnorm) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
#' @title Function to generate event time in the existence of cured population | ||
#' | ||
#' @description generate event time under the delay-treatment effect and cured population setting | ||
#' @param u a scalar with between 0 and 1 | ||
#' @param hr hazard ratio if this subject in the corresponding arm vs control arm | ||
#' @param distribution the distribution for the control arm, valid values of inputs include: exponential, weibull, log-normal, log-logistic | ||
#' @param p the proportion of cured population in the control arm | ||
#' @param lag delayed treatment effect time after treatment initialization, when the hr between treatment arm and control =1 until lag time | ||
#' @param a the shape parameter in the Weibull or the log-logistic distribution | ||
#' @param b the scale parameter in the exponential, Weibull or the log-logistic distribution | ||
#' @param mu the mean in the log-normal distribution | ||
#' @param sd the standard deviation in the log-normal distribution | ||
#' @return the event time | ||
#' | ||
#' @references | ||
#' \itemize{ | ||
#' \item Chen, Tai-Tsang. "Predicting analysis times in randomized clinical trials with cancer immunotherapy." | ||
#' BMC medical research methodology 16.1 (2016): 1-10. | ||
#' } | ||
#' | ||
#' @export | ||
#' | ||
Chen_2016_event_time<-function(u,hr,distribution,p,lag,a, b,mu,sd){ | ||
distribution=tolower(distribution) | ||
|
||
if((distribution!="weibull")&(distribution!="log-normal")&(distribution!="log-logistic")&(distribution!="exponential")){ | ||
stop("The input of distribution is invalid. The valid input of distribution can be chosen from the following distributions: 'exponential','weibull', 'log-normal', and 'Log-logistic'.") | ||
} | ||
if(!is.numeric(u)|length(u)!=1|u<0|u>1){ | ||
stop('The input of u is invalid. The u should be a scalar between 0 and 1.') | ||
} | ||
|
||
if(!is.numeric(hr)|length(hr)!=1|hr<=0){ | ||
stop('The input of hr is invalid. The hr should be a positive scalar.') | ||
} | ||
|
||
if(!is.numeric(p)|length(p)!=1|p<0|p>1){ | ||
stop('The input of p is invalid. The valid value of p should be a scalar between 0 and 1.') | ||
} | ||
if(!is.numeric(lag)|length(lag)!=1|lag<0){ | ||
stop('The input of lag is invalid. The valid value of lag should be a a non-negative scalar.') | ||
} | ||
if((distribution=="weibull")|(distribution=="log-logistic")){ | ||
if(!is.numeric(a)|length(a)!=1|a<=0){ | ||
stop('The input of a is invalid. The shape paramtere a should be a positive scalar.') | ||
} | ||
if(!is.numeric(b)|length(b)!=1|b<=0){ | ||
stop('The input of b is invalid. The scale paramtere b should be a positive scalar.') | ||
} | ||
} | ||
if(distribution=="log-normal"){ | ||
if(!is.numeric(mu)|length(mu)!=1){ | ||
stop('The input of a is invalid. The shape paramtere a should be a numerical scalar.') | ||
} | ||
if(!is.numeric(sd)|length(sd)!=1|sd<=0){ | ||
stop('The input of sd is invalid. The scale paramtere sd should be a positive scalar.') | ||
} | ||
} | ||
|
||
|
||
if(distribution=="exponential"){ | ||
if(!is.numeric(b)|length(b)!=1|b<=0){ | ||
stop('The input of b is invalid. The scale paramtere b should be a positive scalar.') | ||
} | ||
} | ||
|
||
if(distribution=='exponential'){ | ||
st0=p+(1-p)*exp(-(lag/b)) | ||
phi0=p/st0 | ||
if(u>=st0){ | ||
t=(-log((u-p)/(1-p)))*b | ||
} | ||
if((u/st0)^(1/hr)<=phi0){ | ||
t=10^10 | ||
} | ||
|
||
if(u< st0&(u/st0)^(1/hr)>phi0){ | ||
t=(-log(((u/st0)^(1/hr)-phi0)/(1-phi0))+(lag/b))*b | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
if(distribution=='weibull'){ | ||
st0=p+(1-p)*exp(-(lag/b)^a) | ||
phi0=p/st0 | ||
if(u>=st0){ | ||
t=(-log((u-p)/(1-p)))^(1/a)*b | ||
} | ||
if((u/st0)^(1/hr)<=phi0){ | ||
t=10^10 | ||
} | ||
|
||
if(u< st0&(u/st0)^(1/hr)>phi0){ | ||
t=(-log(((u/st0)^(1/hr)-phi0)/(1-phi0))+(lag/b)^a)^(1/a)*b | ||
} | ||
} | ||
|
||
if(distribution=='log-normal'){ | ||
st0=p+(1-p)*(1-stats::pnorm((log(lag)-mu)/sd)) | ||
phi0=p/st0 | ||
if(u>=st0){ | ||
t=exp(stats::qnorm(1-(u-p)/(1-p))*sd+mu) | ||
} | ||
if((u/st0)^(1/hr)<=phi0){ | ||
t=10^10 | ||
} | ||
|
||
if(u< st0&(u/st0)^(1/hr)>phi0){ | ||
t=exp(stats::qnorm(1-((u/st0)^(1/hr)-phi0)/(1-phi0)*(1-stats::pnorm((log(lag)-mu)/sd)))*sd+mu) | ||
} | ||
} | ||
|
||
if(distribution=='log-logistic'){ | ||
st0=p+(1-p)*(1/(1+(lag/b)^a)) | ||
phi0=p/st0 | ||
if(u>=st0){ | ||
t=b*((1-u)/(u-p))^(1/a) | ||
} | ||
if((u/st0)^(1/hr)<=phi0){ | ||
t=10^10 | ||
} | ||
|
||
if(u< st0&(u/st0)^(1/hr)>phi0){ | ||
t=b*((1+(lag/b)^a)*(((u/st0)^(1/hr)-phi0)/(1-phi0))^(-1)-1)^(1/a) | ||
} | ||
} | ||
return(t) | ||
|
||
|
||
} | ||
|
||
### | ||
#Chen_2016_event_time(0.6,hr=1,distribution='weibull',p=0.4,lag=3,a=5,b=5) | ||
|
Oops, something went wrong.