| f_dose_draw | R Documentation | 
Simulates drug dispensing data after cutoff for both ongoing and new patients.
f_dose_draw(
  vf_ongoing,
  vf_new,
  common_time_model,
  k0_fit,
  t0_fit,
  t1_fit,
  ki_fit,
  ti_fit,
  di_fit,
  t0,
  t,
  ncores_max
)
| vf_ongoing | A data frame for the observed drug dispensing
data for ongoing patients with drug dispensing records.
It includes the following variables:
 | 
| vf_new | A data frame for the randomization date for new
patients and ongoing patients with no drug dispensing records.
It includes the following variables:
 | 
| 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. | 
| t0 | The cutoff date relative to the trial start date. | 
| t | A vector of new time points for drug dispensing prediction. | 
| ncores_max | The maximum number of cores to use for parallel
computing. The actual number of cores used is the minimum of
 | 
A list with two components:
dosing_subject_new: A data frame containing observed and
imputed subject-level dosing records for ongoing and new patients
for the first iteration. It contains the following variables:
draw, kit, kit_name, usubjid,
day, dose, arrivalTime, treatment,
treatment_description, time, and totalTime.
dosing_summary_new: A data frame providing dosing summaries
by drug, future time point, and simulation draw for ongoing
and new patients. It contains the following variables:
kit, kit_name, t, draw, and
total_dose_b.
Kaifeng Lu, kaifenglu@gmail.com
f_fit_t0, f_fit_ki,
f_fit_ti, f_fit_di
set.seed(431)
library(dplyr)
pred <- eventPred::getPrediction(
  df = df2,
  to_predict = "event only",
  target_d = 250,
  event_model = "log-logistic",
  dropout_model = "none",
  pilevel = 0.95,
  nyears = 3,
  nreps = 200,
  showsummary = FALSE,
  showplot = FALSE,
  by_treatment = TRUE)
observed <- f_dose_observed(df2, visitview2, showplot = FALSE)
fit <- f_dispensing_models(
  observed$vf, 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",
  nreps = 200, showplot = FALSE)
trialsdt = df2$trialsdt[1]
cutoffdt = df2$cutoffdt[1]
t0 = as.numeric(cutoffdt - trialsdt + 1)
nyears = 3
t1 = t0 + nyears*365
t = c(seq(t0, t1, 30), t1)
vf_ongoing_new <- f_ongoing_new(
  pred$event_pred$newEvents,
  observed$kit_description_df,
  observed$treatment_by_drug_df,
  observed$vf)
dose_draw <- f_dose_draw(
  vf_ongoing_new$vf_ongoing,
  vf_ongoing_new$vf_new,
  fit$common_time_model,
  fit$k0_fit, fit$t0_fit, fit$t1_fit,
  fit$ki_fit, fit$ti_fit, fit$di_fit,
  t0, t, ncores_max = 2)
head(dose_draw$dosing_subject_new)
head(dose_draw$dosing_summary_new)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.