f_fit_ki {drugDemand} | R Documentation |
Model Fitting for Number of Skipped Visits
Description
Fits a count model to the number of skipped visits between two consecutive drug dispensing visits.
Usage
f_fit_ki(df, model, nreps, showplot = TRUE)
Arguments
df |
The subject-level dosing data, including |
model |
The count model used to analyze the number of skipped visits, with options including "constant", "poisson", "zero-inflated poisson", and "negative binomial". |
nreps |
The number of simulations for drawing posterior model parameter values. |
showplot |
A Boolean variable that controls whether or not to
show the fitted count 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 count 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")
df_ti <- vf %>%
mutate(time = lead(day) - day,
skipped = pmax(floor((time - target_days/2)/target_days), 0),
k1 = skipped + 1) %>%
filter(row_id < n())
ki_fit <- f_fit_ki(df_ti, model = "zero-inflated poisson", nreps = 200)