f_fit_t0 {drugDemand} | R Documentation |
Model Fitting for Dispensing Delay After Randomization
Description
Fits a specified time-to-event model to the gap time between randomization and the first drug dispensing visit when there is no visit skipping.
Usage
f_fit_t0(df, model, nreps, showplot = TRUE)
Arguments
df |
The subject-level dosing data, including the following variables:
|
model |
The event model used to analyze the gap time between randomization and the first drug dispensing visit when there is no visit skipping, with options including "constant", "exponential", "weibull", "log-logistic", and "log-normal". |
nreps |
The number of simulations for drawing posterior model parameter values. |
showplot |
A Boolean variable that controls whether or not to
show the fitted time-to-event bar chart. It defaults to |
Value
A list with three components:
-
fit
: A list of results from the model fit that includes-
model
: The specific model used in the analysis. -
theta
: The estimated model parameters. -
vtheta
: The estimated covariance matrix oftheta
. -
aic
: The Akaike Information Criterion value. -
bic
: The Bayesian Information Criterion value.
-
-
fit_plot
: A fitted time-to-event bar chart. -
theta
: Posterior draws of model parameters.
Author(s)
Kaifeng Lu, kaifenglu@gmail.com
Examples
library(dplyr)
observed <- f_dose_observed(df2, visitview2, showplot = FALSE)
vf <- observed$vf
vf <- vf %>% left_join(dosing_schedule_df, by = "kit")
# time from randomization to the first drug dispensing visit
df_k0 <- vf %>%
filter(row_id == 1) %>%
mutate(time = day,
skipped = floor((time - target_days/2)/target_days) + 1)
# no skipping
df_t0 <- df_k0 %>%
filter(skipped == 0) %>%
mutate(left = time - 1, right = time)
t0_fit <- f_fit_t0(df_t0, model = "log-logistic", nreps = 200)