f_drug_demand {drugDemand}  R Documentation 
Drug Demand Forecasting
Description
Obtains drug demand forecasting via modeling and simulation.
Usage
f_drug_demand(
df = NULL,
newEvents = NULL,
visitview = NULL,
kit_description_df = NULL,
treatment_by_drug_df = NULL,
dosing_schedule_df = NULL,
model_k0 = "negative binomial",
model_t0 = "loglogistic",
model_t1 = "least squares",
model_ki = "negative binomial",
model_ti = "least absolute deviations",
model_di = "linear mixedeffects model",
pilevel = 0.95,
nyears = 1,
ncores_max = 10,
pred_pp_only = FALSE,
showplot = TRUE
)
Arguments
df 
A data frame for subjectlevel enrollment and event data,
including the following variables:

newEvents 
A data frame containing the imputed event data
for both ongoing and new patients, typically obtained from
the output of the 
visitview 
A data frame containing the observed drug dispensing
data, including the following variables:

kit_description_df 
A data frame indicating the
drug and kit descriptions, including the following variables:

treatment_by_drug_df 
A data frame indicating the treatments
associated with each drug, including the following variables:

dosing_schedule_df 
A data frame providing dosing schedule
information. It contains the following variables:

model_k0 
The model for the number of skipped visits between randomization and the first drug dispensing visit. Options include "constant", "poisson", "zeroinflated poisson", and "negative binomial". 
model_t0 
The model for the gap time between randomization and the first drug dispensing visit when there is no visit skipping. Options include "constant", "exponential", "weibull", "loglogistic", and "lognormal". 
model_t1 
The model for the gap time between randomization and the first drug dispensing visit when there is visit skipping. Options include "least squares" and "least absolute deviations". 
model_ki 
The model for the number of skipped visits between two consecutive drug dispensing visits. Options include "constant", "poisson", "zeroinflated poisson", and "negative binomial". 
model_ti 
The model for the gap time between two consecutive drug dispensing visits. Options include "least squares" and "least absolute deviations". 
model_di 
The model for the dispensed doses at drug dispensing visits. Options include "constant", "linear model", and "linear mixedeffects model". 
pilevel 
The prediction interval level. 
nyears 
The number of years after the data cut for prediction. 
ncores_max 
The maximum number of cores to use for parallel
computing. The actual number of cores used is the minimum of

pred_pp_only 
A Boolean variable that controls whether or not to make protocolbased predictions only. 
showplot 
A Boolean variable that controls whether or not to
show the drug dispensing model fit and drug demand prediction
plots. It defaults to 
Value
For designstage drug demand forecasting, a list with the following components:

kit_description_df
: A data frame indicating the drug and kit descriptions, including the following variables:drug
,drug_name
,kit
, andkit_name
. 
treatment_by_drug_df
: A data frame indicating the treatments associated with each drug, including the following variables:treatment
anddrug
. 
dosing_schedule_df
: A data frame providing dosing schedule information. It contains the following variables:kit
,target_days
,target_dose
, andmax_cycles
. 
dosing_pred_df
: A data frame for dosing summary by kit type and time point per protocol. It includes the following variables:kit
,kit_name
,t
,n
,pilevel
,lower
,upper
,mean
,var
, andparameter
. 
dosing_pred_plot
: A plot object for dosing prediction.
For analysisstage drug demand forecasting, a list with the following components:

trialsdt
: The trial start date. 
cutoffdt
: The cutoff date. 
dosing_summary_t0
: A data frame for the cumulative doses dispensed before the cutoff date. It contains the following variables:kit
,kit_name
, andcum_dose_t0
. 
cum_dispense_plot
: The step plot for the cumulative doses dispensed for each kit type. 
bar_t0_plot
: The bar chart for the time between randomization and the first drug dispensing visit. 
bar_ti_plot
: The bar chart for the gap time between two consecutive drug dispensing visits. 
bar_di_plot
: The bar chart for the doses dispensed at drug dispensing visits. 
common_time_model
: A Boolean variable that indicates whether a common time model is used for drug dispensing visits. 
k0_fit
: The model fit for the number of skipped visits between randomization and the first drug dispensing visit. 
t0_fit
: The model fit for the gap time between randomization and the first drug dispensing visit when there is no visit skipping. 
t1_fit
: The model fit for the gap time between randomization and the first drug dispensing visit when there is visit skipping. 
ki_fit
: The model fit for the number of skipped visits between two consecutive drug dispensing visits. 
ti_fit
: The model fit for the gap time between two consecutive drug dispensing visits. 
di_fit
: The model fit for the dispensed doses at drug dispensing visits. 
kit_description_df
: A data frame indicating the drug and kit descriptions, including the following variables:drug
,drug_name
,kit
, andkit_name
. 
treatment_by_drug_df
: A data frame indicating the treatments associated with each drug, including the following variables:treatment
anddrug
. 
dosing_schedule_df
: A data frame providing dosing schedule information. It contains the following variables:kit
,target_days
,target_dose
, andmax_cycles
. 
dosing_subject_df
: A data frame for the observed and imputed subjectlevel dosing records for the first iteration. It includes the following variables:drug
,drug_name
,kit
,kit_name
,usubjid
,treatment
,treatment_description
,arrivalTime
,time
,day
,dose
,cum_dose
,row_id
,subject_type
,imputed
,trialsdt
,cutoffdt
,randdt
,adt
, anddate
. 
dosing_pred_df
: A data frame for dosing summary by kit type and time point. It includes the following variables:kit
,kit_name
,t
,n
,pilevel
,lower
,upper
,mean
,var
,date
, andparameter
. 
dosing_pred_plot
: A plot object for dosing prediction.
Author(s)
Kaifeng Lu, kaifenglu@gmail.com
See Also
f_fit_t0
, f_fit_ki
,
f_fit_ti
, f_fit_di
Examples
set.seed(529)
pred < eventPred::getPrediction(
df = df2,
to_predict = "event only",
target_d = 250,
event_model = "loglogistic",
dropout_model = "none",
pilevel = 0.95,
nyears = 1,
nreps = 200,
showplot = FALSE,
by_treatment = TRUE)
drug_demand < f_drug_demand(
df = df2,
newEvents = pred$event_pred$newEvents,
visitview = visitview2,
dosing_schedule_df = dosing_schedule_df,
model_k0 = "zeroinflated poisson",
model_t0 = "loglogistic",
model_t1 = "least squares",
model_ki = "zeroinflated poisson",
model_ti = "least squares",
model_di = "linear mixedeffects model",
pilevel = 0.95,
nyears = 1,
ncores_max = 2,
showplot = FALSE)
drug_demand$dosing_pred_plot