f_dose_draw_t_1 {drugDemand}R Documentation

Drug Dispensing Visit Dates Simulation for One Iteration

Description

Simulates drug dispensing visit dates for one iteration.

Usage

f_dose_draw_t_1(
  i,
  k0_fit,
  t0_fit,
  t1_fit,
  ki_fit,
  ti_fit,
  vf_ongoing1,
  vf_new1
)

Arguments

i

The iteration number.

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.

vf_ongoing1

A data frame for the last observed drug dispensing date for ongoing patients with drug dispensing records. For the common time model, it includes the following variables: draw, usubjid, arrivalTime, treatment, treatment_description, time, totalTime, V, C, and D. For separate time models, it includes the following variables: draw, kit, kit_name, usubjid, arrivalTime, treatment, treatment_description, time, totalTime, V, C, and D.

vf_new1

A data frame for the randomization date for new patients and ongoing patients with no drug dispensing records. For the common time model, it includes the following variables: draw, usubjid, arrivalTime, treatment, treatment_description, time, totalTime, V, C, and D. For separate time models, it includes the following variables: draw, kit, kit_name, usubjid, arrivalTime, treatment, treatment_description, time, totalTime, V, C, and D.

Value

A data frame containing the simulated drug dispensing visit dates at the subject level for ongoing and new subjects. It includes the following variables: usubjid, day, draw, arrivalTime, treatment, treatment_description, time, totalTime, and status.

Author(s)

Kaifeng Lu, kaifenglu@gmail.com

See Also

f_fit_t0, f_fit_ki, f_fit_ti

Examples



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

vf_ongoing_new <- f_ongoing_new(
  pred$event_pred$newEvents,
  observed$kit_description_df,
  observed$treatment_by_drug_df,
  observed$vf)

vf_ongoing <- vf_ongoing_new$vf_ongoing
vf_new <- vf_ongoing_new$vf_new

vf_ongoing1 <- vf_ongoing %>%
  group_by(draw, usubjid) %>%
  slice(n()) %>%
  mutate(V = day - 1,
         C = as.numeric(t0 - arrivalTime),
         D = pmin(time - 1, t1 - arrivalTime)) %>%
  select(-c("kit", "kit_name", "day", "dose"))

### new patients and ongoing patients with no dosing records ###
vf_new1 <- vf_new %>%
  group_by(draw, usubjid) %>%
  slice(n()) %>%
  mutate(V = 0,
         C = as.numeric(t0 - arrivalTime),
         D = pmin(time - 1, t1 - arrivalTime)) %>%
  select(-c("kit", "kit_name"))

dosing_subject_new1 <- f_dose_draw_t_1(
  1, fit$k0_fit, fit$t0_fit, fit$t1_fit,
  fit$ki_fit, fit$ti_fit, vf_ongoing1, vf_new1)

head(dosing_subject_new1)



[Package drugDemand version 0.1.3 Index]