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]
|
Maintainer: | Ioannis Malagaris <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.24 |
Built: | 2025-03-17 06:05:02 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
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
plot(yMax = NULL, Title = NULL)
:
Function which plots the results. It accepts the following arguments:
yMax
sets the upper limit of the y-axis
Title
sets the main title for the plot
pargs
:
An environment which contains objects and functions used to construct
the plot. Additional plot configuration to what the plot()
function
currently supports, can be achieved by modifying those objects
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
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), oma = c(0, 1, 0, 7), mar = c(4, 4, 3, 1)) for (x in scenarios) x$plot(yMax = maxY, Title = 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), oma = c(0, 1, 0, 7), mar = c(4, 4, 3, 1)) for (x in scenarios) x$plot(yMax = maxY, Title = 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.
gripsYR1
gripsYR1
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
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.
gripsYR2
gripsYR2
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
Modified recruitment data from the second year of the GRIPS study, aggregated by calendar week.
gripsYR2Weekly
gripsYR2Weekly
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
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
# 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) }
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
LoadData(gripsYR1, ScreenDt, Enrolled) (res <- Time2Nsubjects()) str(res)
LoadData(gripsYR1, ScreenDt, Enrolled) (res <- Time2Nsubjects()) str(res)