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 = "log-logistic",
  model_t1 = "least squares",
  model_ki = "negative binomial",
  model_ti = "least absolute deviations",
  model_di = "linear mixed-effects model",
  pilevel = 0.95,
  nyears = 1,
  ncores_max = 10,
  pred_pp_only = FALSE,
  showplot = TRUE
)

Arguments

df

A data frame for subject-level enrollment and event data, including the following variables: trialsdt, usubjid, randdt, treatment, treatment_description, time, event, dropout, and cutoffdt.

newEvents

A data frame containing the imputed event data for both ongoing and new patients, typically obtained from the output of the getPrediction function of the eventPred package. It contains the following variables: draw, usubjid, arrivalTime, treatment, treatment_description, time, event, dropout, and totalTime. It must be provided.

visitview

A data frame containing the observed drug dispensing data, including the following variables: usubjid, visit, date, drug, drug_name, kit, kit_name, kit_number, and dispensed_quantity.

kit_description_df

A data frame indicating the drug and kit descriptions, including the following variables: drug, drug_name, kit, and kit_name. It must be specified at the design stage. It will be replaced with the observed information at the analysis stage.

treatment_by_drug_df

A data frame indicating the treatments associated with each drug, including the following variables: treatment and drug. It must be specified at the design stage. It will be replaced with the observed information at the analysis stage.

dosing_schedule_df

A data frame providing dosing schedule information. It contains the following variables: kit, target_days, target_dose, and max_cycles. It must be provided.

model_k0

The model for the number of skipped visits between randomization and the first drug dispensing visit. Options include "constant", "poisson", "zero-inflated 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", "log-logistic", and "log-normal".

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", "zero-inflated 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 mixed-effects 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 ncores_max and half of the detected number of cores.

pred_pp_only

A Boolean variable that controls whether or not to make protocol-based 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 TRUE.

Value

For design-stage drug demand forecasting, a list with the following components:

For analysis-stage drug demand forecasting, a list with the following components:

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 = "log-logistic",
  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 = "zero-inflated poisson",
  model_t0 = "log-logistic",
  model_t1 = "least squares",
  model_ki = "zero-inflated poisson",
  model_ti = "least squares",
  model_di = "linear mixed-effects model",
  pilevel = 0.95,
  nyears = 1,
  ncores_max = 2,
  showplot = FALSE)

drug_demand$dosing_pred_plot



[Package drugDemand version 0.1.3 Index]