Type: | Package |
Title: | Non-Parametric Recruitment Prediction for Randomized Clinical Trials |
Version: | 0.2.0 |
Description: | Accurate prediction of subject recruitment for Randomized Clinical Trials (RCT) remains an ongoing challenge. Many previous prediction models rely on parametric assumptions. We present functions for non-parametric RCT recruitment prediction under several scenarios. |
License: | MIT + file LICENSE |
Depends: | R (≥ 4.2.0) |
Imports: | lubridate, methods, Rcpp |
LinkingTo: | Rcpp |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.3.2 |
URL: | https://github.com/imalagaris/RCTRecruit |
BugReports: | https://github.com/imalagaris/RCTRecruit/issues |
Suggests: | knitr, magrittr, testthat (≥ 3.0.0), withr |
Config/testthat/edition: | 3 |
NeedsCompilation: | yes |
Packaged: | 2025-04-21 18:13:56 UTC; ymala |
Author: | Ioannis Malagaris |
Maintainer: | Ioannis Malagaris <iomalaga@utmb.edu> |
Repository: | CRAN |
Date/Publication: | 2025-04-21 18:30:02 UTC |
RCTRecruit: Non-Parametric Recruitment Prediction for Randomized Clinical Trials
Description
Accurate prediction of subject recruitment for Randomized Clinical Trials (RCT) remains an ongoing challenge. Many previous prediction models rely on parametric assumptions. We present functions for non-parametric RCT recruitment prediction under several scenarios.
Details
Package: | RCTRecruit | |
Type: | Package | |
Version: | 0.2.0 | |
Date: | 2025-04-21 | |
License: | MIT + file LICENSE | |
Functions: | ||
GetDistance | Euclidean distance between predicted and actual recruitment | |
GetWeekPredCI | Calculate median recruitment with 95% CI for the next 104 weeks (two years) | |
LoadData | Load recruitment data. | |
plot.RCTPredCI | Plots RCTPredCI object | |
Time2Nsubjects | Simulate the number of weeks needed to recruit a given number of subjects | |
Datasets: | ||
gripsYR1 | Daily recruitment data for the 1st year of the GRIPS study | |
gripsYR2 | Daily recruitment data for the 2nd year of the GRIPS study | |
gripsYR2Weekly | Weekly recruitment data for the 2nd year of the GRIPS study | |
Author(s)
Maintainer: Ioannis Malagaris iomalaga@utmb.edu (ORCID) [copyright holder]
Authors:
Alejandro Villasante-Tezanos alvillas@utmb.edu
Christopher Kurinec chkurine@utmb.edu
Xiaoying Yu xiyu@utmb.edu
References
Villasante-Tezanos A, Kuo Y, Kurinec C, Li Y, Yu X (2024). "A non-parametric approach to predict the recruitment for randomized clinical trials: an example in elderly inpatient settings." BMC medical research methodology, 24, 189. ISSN 1471-2288, https://pubmed.ncbi.nlm.nih.gov/39210285/.
Gajewski BJ, Simon SD, Carlson SE (2008). "Predicting accrual in clinical trials with Bayesian posterior predictive distributions." Statistics in medicine, 27, 2328-40. ISSN 0277-6715, https://pubmed.ncbi.nlm.nih.gov/17979152/.
Jiang Y, Simon S, Mayo MS, Gajewski BJ (2015). "Modeling and validating Bayesian accrual models on clinical data and simulations using adaptive priors." Statistics in medicine, 34, 613-29. ISSN 1097-0258, https://pubmed.ncbi.nlm.nih.gov/25376910/.
See Also
Useful links:
Report bugs at https://github.com/imalagaris/RCTRecruit/issues
Packages:
Liu J, Jiang Y, Wu C, Simon S, Mayo MS, Raghavan R, Gajewski BJ (2023). accrual: Bayesian Accrual Prediction. R package version 1.4, https://CRAN.R-project.org/package=accrual.
Other Links:
GetDistance()
,
GetWeekPredCI()
,
LoadData()
,
Time2Nsubjects()
,
gripsYR1
,
gripsYR2
,
gripsYR2Weekly
,
plot.RCTPredCI()
Euclidean distance between predicted and actual recruitment
Description
Euclidean distance between predicted and actual recruitment
Usage
GetDistance(
target,
nSim = 10000L,
fillGaps = FALSE,
cauchyWt = FALSE,
efficiencyFactor = 1
)
Arguments
target |
A vector with the actual recruitment by week |
nSim |
Number of simulations to run (default = 1e4L). Accepted values are in the |
fillGaps |
Whether to fill recruitment gaps in the data (default = FALSE). |
cauchyWt |
Whether to use Cauchy weights for sampling.
If FALSE (default), |
efficiencyFactor |
An efficiency coefficient to apply to the recruitment rate (default = 1).
|
Value
An object of RCTDist
class with four elements.
-
dist
: A numeric vector with length equal tonSim
containing the simulated
Euclidean distance. -
CI
: A numeric vector with the median and the 95% CI Euclidean distance. -
call.
: The call (deparsed) that created the object -
cargs
: A list with the arguments of the call that created the object
including the default arguments
See Also
Other Links:
GetWeekPredCI()
,
LoadData()
,
RCTRecruit-package
,
Time2Nsubjects()
,
gripsYR1
,
gripsYR2
,
gripsYR2Weekly
,
plot.RCTPredCI()
Examples
LoadData(gripsYR1, ScreenDt, Enrolled)
(res <- GetDistance(gripsYR2Weekly$enrolled))
str(res)
Calculate median recruitment with 95% CI for the next 104 weeks (two years)
Description
Calculate median recruitment with 95% CI for the next 104 weeks (two years)
Usage
GetWeekPredCI(
nSim = 10000L,
fillGaps = FALSE,
cauchyWt = FALSE,
efficiencyFactor = 1
)
Arguments
nSim |
Number of simulations to run (default = 1e4L). Accepted values are in the |
fillGaps |
Whether to fill recruitment gaps in the data (default = FALSE). |
cauchyWt |
Whether to use Cauchy weights for sampling.
If FALSE (default), |
efficiencyFactor |
An efficiency coefficient to apply to the recruitment rate (default = 1).
|
Value
An object of RCTPredCI
class with 5 elements.
-
predCI
: An 104x3 matrix with the 2.5%, 50% and 97.5% weekly percentiles -
pargs
:
An environment which contains objects and functions used to construct
the plot withbase::plot()
. For internal use only. -
call.
: The call (deparsed) that created the object -
cargs
: A list with the arguments of the call that created the object
including the default arguments
See Also
Other Links:
GetDistance()
,
LoadData()
,
RCTRecruit-package
,
Time2Nsubjects()
,
gripsYR1
,
gripsYR2
,
gripsYR2Weekly
,
plot.RCTPredCI()
Examples
LoadData(gripsYR1, ScreenDt, Enrolled)
(res <- GetWeekPredCI(fillGaps = TRUE, efficiencyFactor = 1.5))
scenarios <- list(
sc1 = GetWeekPredCI(),
sc2 = GetWeekPredCI(cauchyWt = TRUE),
sc3 = GetWeekPredCI(fillGaps = TRUE),
sc4 = GetWeekPredCI(fillGaps = TRUE, efficiencyFactor = 1.2)
)
maxY <- sapply(scenarios, \(x) x$pargs$maxY) |> max()
defaultGraphicParams <- par(no.readonly = TRUE)
graphics::par(mfrow = c(2, 2), cex.main = 1)
for (x in scenarios) plot(x, yMax = maxY, main = x$call.)
do.call(par, defaultGraphicParams)
Load recruitment data.
Description
This function must be called before any other function in this package. LoadData
checks the input data and stores the results internally for the session.
Calling this function more than once in the same session will overwrite the
previously created internal data.
Usage
LoadData(data, date, enrolled)
Arguments
data |
Main dataset containing at least two columns:
If the entries cover a period longer than 1 year, only the entries within |
date |
The name (symbol or string) of the column in the dataset with the calendar
|
enrolled |
The name (symbol or string) of the column in the dataset with the number of |
Value
This function does not return any value. It runs several tests and proccesses
the data and stores internally the results. It prints a message to the console
if the data is successfully loaded or an error message if there is an issue
with the input data. Once the dataset is loaded, the following functions can
be used:
-
Time2Nsubjects()
: simulates the number of weeks needed to recruit a
given number of subjects -
GetDistance()
: calculates the Euclidean distance between the
predicted and actual recruitment -
GetWeekPredCI()
: calculates the median recruitment with 95% CI for
up to the next 104 weeks (two years)
See Also
Other Links:
GetDistance()
,
GetWeekPredCI()
,
RCTRecruit-package
,
Time2Nsubjects()
,
gripsYR1
,
gripsYR2
,
gripsYR2Weekly
,
plot.RCTPredCI()
Examples
# Load using names as symbols
LoadData(gripsYR1, ScreenDt, Enrolled)
# Load using names as strings
LoadData(gripsYR1, "ScreenDt", "Enrolled")
# Load using base pipe operator
gripsYR1 |> LoadData(ScreenDt, Enrolled)
# Load using magrittr pipe operator
if (base::requireNamespace("magrittr", quietly = TRUE)) {
library(magrittr)
gripsYR1 %>% LoadData(ScreenDt, Enrolled)
}
Simulate the number of weeks needed to recruit a given number of subjects
Description
Simulate the number of weeks needed to recruit a given number of subjects
Usage
Time2Nsubjects(
nSub = 50L,
nSim = 10000L,
fillGaps = FALSE,
cauchyWt = FALSE,
efficiencyFactor = 1
)
Arguments
nSub |
Number of subjects to recruit (default = 50L) |
nSim |
Number of simulations to run (default = 1e4L). Accepted values are in the |
fillGaps |
Whether to fill recruitment gaps in the data (default = FALSE). |
cauchyWt |
Whether to use Cauchy weights for sampling.
If FALSE (default), |
efficiencyFactor |
An efficiency coefficient to apply to the recruitment rate (default = 1).
|
Value
An object of RCTNWeeks
class with four elements.
-
weeks
is an integer vector with length equal tonSim
containing the simulation results. -
CI
shows the median and the 95% CI. -
call.
: The call (deparsed) that created the object -
cargs
: A list with the arguments of the call that created the object
including the default arguments
See Also
Other Links:
GetDistance()
,
GetWeekPredCI()
,
LoadData()
,
RCTRecruit-package
,
gripsYR1
,
gripsYR2
,
gripsYR2Weekly
,
plot.RCTPredCI()
Examples
LoadData(gripsYR1, ScreenDt, Enrolled)
(res <- Time2Nsubjects())
str(res)
Daily recruitment data for the 1st year of the GRIPS study
Description
Modified recruitment data from the first year of the GRIPS study. This dataset includes the number or participants recruited for each calendar date during active recruitment periods.
Usage
gripsYR1
Format
A data frame with 159 observations of 2 variables
[,1] | ScreenDt | character | Calendar date of the screening process for recruitment in the study |
[,2] | Enrolled | integer | Number of new subjects enrolled in the study on that date |
Source
Villasante-Tezanos A, Kuo Y, Kurinec C, Li Y, Yu X (2024). "A non-parametric approach to predict the recruitment for randomized clinical trials: an example in elderly inpatient settings." BMC medical research methodology, 24, 189. ISSN 1471-2288, https://pubmed.ncbi.nlm.nih.gov/39210285/.
See Also
Other Links:
GetDistance()
,
GetWeekPredCI()
,
LoadData()
,
RCTRecruit-package
,
Time2Nsubjects()
,
gripsYR2
,
gripsYR2Weekly
,
plot.RCTPredCI()
Daily recruitment data for the 2nd year of the GRIPS study
Description
Modified recruitment data from the second year of the GRIPS study. This dataset includes the number or participants recruited for each calendar date during active recruitment periods.
Usage
gripsYR2
Format
A data frame with 292 observations of 2 variables
[,1] | ScreenDt | character | Calendar date of the screening process for recruitment in the study |
[,2] | Enrolled | integer | Number of new subjects enrolled in the study on that date |
Source
Villasante-Tezanos A, Kuo Y, Kurinec C, Li Y, Yu X (2024). "A non-parametric approach to predict the recruitment for randomized clinical trials: an example in elderly inpatient settings." BMC medical research methodology, 24, 189. ISSN 1471-2288, https://pubmed.ncbi.nlm.nih.gov/39210285/.
See Also
Other Links:
GetDistance()
,
GetWeekPredCI()
,
LoadData()
,
RCTRecruit-package
,
Time2Nsubjects()
,
gripsYR1
,
gripsYR2Weekly
,
plot.RCTPredCI()
Weekly recruitment data for the 2nd year of the GRIPS study
Description
Modified recruitment data from the second year of the GRIPS study, aggregated by calendar week.
Usage
gripsYR2Weekly
Format
A data frame with 52 observations of 4 variables
[,1] | week | double | Calendar week |
[,2] | year | double | Calendar year |
[,3] | enrolled | integer | Number of people enrolled that week |
[,4] | activeDays | integer | Number of days in that week when recruitment was active |
Source
Villasante-Tezanos A, Kuo Y, Kurinec C, Li Y, Yu X (2024). "A non-parametric approach to predict the recruitment for randomized clinical trials: an example in elderly inpatient settings." BMC medical research methodology, 24, 189. ISSN 1471-2288, https://pubmed.ncbi.nlm.nih.gov/39210285/.
See Also
Other Links:
GetDistance()
,
GetWeekPredCI()
,
LoadData()
,
RCTRecruit-package
,
Time2Nsubjects()
,
gripsYR1
,
gripsYR2
,
plot.RCTPredCI()
Plots RCTPredCI object
Description
Plots RCTPredCI object
Usage
## S3 method for class 'RCTPredCI'
plot(x, yMax = NULL, includeYR2 = FALSE, xGrid = TRUE, yGrid = TRUE, ...)
Arguments
x |
RCTPredCI object |
yMax |
It sets upper value for the y-axis. It is useful when several figures are plotted together |
includeYR2 |
Whether to plot predictions for 104 weeks. By default (default = FALSE) it only plots the first 52 weeks. |
xGrid |
Whether to plot vertical grid lines (default = TRUE) |
yGrid |
Whether to plot horizontal grid lines (default = TRUE) |
... |
Additional arguments to be passed as in |
See Also
Other Links:
GetDistance()
,
GetWeekPredCI()
,
LoadData()
,
RCTRecruit-package
,
Time2Nsubjects()
,
gripsYR1
,
gripsYR2
,
gripsYR2Weekly