| Title: | 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. |
| Authors: | Ioannis Malagaris [aut, cre, cph] (ORCID: <https://orcid.org/0000-0001-5126-2068>), Alejandro Villasante-Tezanos [aut], Christopher Kurinec [aut], Xiaoying Yu [aut] |
| Maintainer: | Ioannis Malagaris <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0.9000 |
| Built: | 2026-05-23 09:17:01 UTC |
| Source: | https://github.com/imalagaris/rctrecruit |
Euclidean distance between predicted and actual recruitment
GetDistance( target, nSim = 10000L, fillGaps = FALSE, cauchyWt = FALSE, efficiencyFactor = 1 )GetDistance( target, nSim = 10000L, fillGaps = FALSE, cauchyWt = FALSE, efficiencyFactor = 1 )
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).
|
An object of RCTDist class with four elements.
dist:
A numeric vector with length equal to nSim 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
Other Links:
GetWeekPredCI(),
LoadData(),
RCTRecruit-package,
Time2Nsubjects(),
gripsYR1,
gripsYR2,
gripsYR2Weekly,
plot.RCTPredCI()
LoadData(gripsYR1, ScreenDt, Enrolled) (res <- GetDistance(gripsYR2Weekly$enrolled)) str(res)LoadData(gripsYR1, ScreenDt, Enrolled) (res <- GetDistance(gripsYR2Weekly$enrolled)) str(res)
Calculate median recruitment with 95% CI for the next 104 weeks (two years)
GetWeekPredCI( nSim = 10000L, fillGaps = FALSE, cauchyWt = FALSE, efficiencyFactor = 1 )GetWeekPredCI( nSim = 10000L, fillGaps = FALSE, cauchyWt = FALSE, efficiencyFactor = 1 )
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).
|
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 with base::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
Other Links:
GetDistance(),
LoadData(),
RCTRecruit-package,
Time2Nsubjects(),
gripsYR1,
gripsYR2,
gripsYR2Weekly,
plot.RCTPredCI()
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)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)
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.
gripsYR1gripsYR1
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 |
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/.
Other Links:
GetDistance(),
GetWeekPredCI(),
LoadData(),
RCTRecruit-package,
Time2Nsubjects(),
gripsYR2,
gripsYR2Weekly,
plot.RCTPredCI()
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.
gripsYR2gripsYR2
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 |
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/.
Other Links:
GetDistance(),
GetWeekPredCI(),
LoadData(),
RCTRecruit-package,
Time2Nsubjects(),
gripsYR1,
gripsYR2Weekly,
plot.RCTPredCI()
Modified recruitment data from the second year of the GRIPS study, aggregated by calendar week.
gripsYR2WeeklygripsYR2Weekly
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 |
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/.
Other Links:
GetDistance(),
GetWeekPredCI(),
LoadData(),
RCTRecruit-package,
Time2Nsubjects(),
gripsYR1,
gripsYR2,
plot.RCTPredCI()
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.
LoadData(data, date, enrolled)LoadData(data, date, enrolled)
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 |
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)
Other Links:
GetDistance(),
GetWeekPredCI(),
RCTRecruit-package,
Time2Nsubjects(),
gripsYR1,
gripsYR2,
gripsYR2Weekly,
plot.RCTPredCI()
# 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) }# 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) }
Plots RCTPredCI object
## S3 method for class 'RCTPredCI' plot(x, yMax = NULL, includeYR2 = FALSE, xGrid = TRUE, yGrid = TRUE, ...)## S3 method for class 'RCTPredCI' plot(x, yMax = NULL, includeYR2 = FALSE, xGrid = TRUE, yGrid = TRUE, ...)
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 |
Other Links:
GetDistance(),
GetWeekPredCI(),
LoadData(),
RCTRecruit-package,
Time2Nsubjects(),
gripsYR1,
gripsYR2,
gripsYR2Weekly
Simulate the number of weeks needed to recruit a given number of subjects
Time2Nsubjects( nSub = 50L, nSim = 10000L, fillGaps = FALSE, cauchyWt = FALSE, efficiencyFactor = 1 )Time2Nsubjects( nSub = 50L, nSim = 10000L, fillGaps = FALSE, cauchyWt = FALSE, efficiencyFactor = 1 )
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).
|
An object of RCTNWeeks class with four elements.
weeks is an integer vector with length equal to nSim 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
Other Links:
GetDistance(),
GetWeekPredCI(),
LoadData(),
RCTRecruit-package,
gripsYR1,
gripsYR2,
gripsYR2Weekly,
plot.RCTPredCI()
LoadData(gripsYR1, ScreenDt, Enrolled) (res <- Time2Nsubjects()) str(res)LoadData(gripsYR1, ScreenDt, Enrolled) (res <- Time2Nsubjects()) str(res)