f_fit_di: Model Fitting for Dispensed Doses

View source: R/f_dispensing_models.R

f_fit_diR Documentation

Model Fitting for Dispensed Doses

Description

Fits a linear mixed-effects model to the dispensed doses at drug dispensing visits.

Usage

f_fit_di(df, model, nreps, showplot = TRUE)

Arguments

df

The subject-level dosing data, including usubjid, day, kit, and dose.

model

The model used to analyze the dispensed doses, with options including "constant", "linear model", and "linear mixed-effects model".

nreps

The number of simulations for drawing posterior model parameters.

showplot

A Boolean variable that controls whether or not to show the fitted dose bar chart. It defaults to TRUE.

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.

    • mud: The estimated mean dose.

    • vmud: The estimated variance of mud.

    • sigmab: The estimated between-subject standard deviation.

    • sigmae: The estimated within-subject residual standard deviation.

    • aic: The Akaike Information Criterion value.

    • bic: The Bayesian Information Criterion value.

  • fit_plot: A fitted dose bar chart.

  • theta: Posterior draws of model parameters.

    • fixed: Posterior draws of fixed model parameters: mud, sigmab, and sigmae.

    • random: Posterior draws of subject random effects.

    • usubjid: The unique subject ID associated with the subject random effects.

Author(s)

Kaifeng Lu, kaifenglu@gmail.com

Examples

library(dplyr)

observed <- f_dose_observed(df2, visitview2, showplot = FALSE)
vf <- observed$vf

vf1 <- vf %>% filter(kit == 3)
di_fit <- f_fit_di(vf1, model = "linear mixed-effects model", nreps = 200)


drugDemand documentation built on May 29, 2024, 8:43 a.m.