Package 'mbbe'

Title: Model Based Bio-Equivalence
Description: Uses several Nonlinear Mixed effect (NONMEM) models (as NONMEM control files) to perform bootstrap model averaging and Monte Carlo Simulation for Model Based Bio-Equivalence (MBBE). Power is returned as the fraction of the simulations with successful bioequivalence (BE) test, for maximum concentration (Cmax), Area under the curve to the last observed value (AUClast) and Area under the curve extrapolate to infinity (AUCinf). See Hooker, A. (2020) Improved bioequivalence assessment through model-informed and model-based strategies <https://www.fda.gov/media/138035/download>.
Authors: Mark Sale [aut, cre] (<https://orcid.org/0000-0002-6239-2359>, Funded by FDA/NIH grant 1U01FD007355), James Craig [aut] , Michael Tomashevskiy [aut]
Maintainer: Mark Sale <[email protected]>
License: LGPL-3
Version: 0.1.0
Built: 2025-02-09 05:00:47 UTC
Source: https://github.com/certara/mbbe

Help Index


Calculate Non-Compartmental Analysis (NCA) Parameters

Description

This function performs Non-Compartmental Analysis (NCA) to derive key pharmacokinetic parameters such as Cmax, AUCinf, and AUClast for specified time intervals.

Usage

calc_NCA(
  run_dir,
  ngroups,
  reference_groups,
  test_groups,
  NCA_end_time,
  samp_size
)

Arguments

run_dir

Character string specifying the path to the run directory.

ngroups

Integer specifying the total number of groups (e.g., 4 for an ABBA design).

reference_groups

Numeric vector indicating the group IDs that are designated as reference.

test_groups

Numeric vector indicating the group IDs that are designated as test.

NCA_end_time

Numeric value specifying the end time for calculations of AUClast and AUCinf.

samp_size

Integer indicating the sample size or the total number of samples for the analysis.

Details

The calc_NCA function internally calls getNCA for each sample in the sequence from 1 to samp_size. Note that the function is currently executed in a serial manner and is not parallelized.

Value

The function returns a list containing the derived NCA parameters for each sample.

Examples

## Not run: 
run_dir <- "c:/Workspace/mbbe"
ngroups <- 4
reference_groups <- c(1,2)
test_groups <- c(3,4)
NCA_end_time <- 7
samp_size <- 6
calc_NCA(run_dir, ngroups, reference_groups, test_groups, NCA_end_time, samp_size)

## End(Not run)

Calculate Bioequivalence Power

Description

Computes the power for bioequivalence (BE) testing based on EMA standards statistics applied to each Monte Carlo simulation. The power is determined by the proportion of simulations that meet the BE criteria.

Usage

calc_power(run_dir, samp_size, alpha, model_averaging_by, NTID)

Arguments

run_dir

Character string specifying the run directory where simulation outputs are located.

samp_size

Integer indicating the number of samples to be used in the analysis.

alpha

Numeric value representing the alpha error rate. It must lie between 0 and 1.

model_averaging_by

Character string indicating the method for model averaging, either "subject" or "study".

NTID

Logical indicating if the drug being tested is a narrow therapeutic index drug.

Details

When the simulation is conducted by study (i.e., a unique model for each study), this results in model averaging at the study level. If model_averaging_by is set to "subject", data from different studies are merged. For each study dataset, subjects are randomly selected (without replacement) from across all studies.

The function iterates over each sample, reading the corresponding NCAresults (designated by the sample number). Subsequently, it determines if each sample meets or fails the BE testing criteria.

Value

A list containing the results for:

  • Cmax_result: Power for the Cmax parameter.

  • AUCinf_result: Power for the AUCinf parameter.

  • AUClast_result: Power for the AUClast parameter. All power values range between 0 and 1.

Examples

calc_power(
 run_dir = system.file(package = "mbbe", "examples", "calc_power"),
 samp_size = 5,
 alpha = 0.05,
 model_averaging_by = "study",
 NTID = FALSE
)

run_example for Model-Based BE Assessment

Description

This function calls the example models (model1-5.mod), performs the bootstrap, model averaging and the Monte Carlo simulation.

Usage

run_example(run_dir, nmfe_path, Include_R_Code = FALSE, plan = "multisession")

Arguments

run_dir

Character string specifying the directory containing the parent folder where the models are to be run.

nmfe_path

Character string indicating the path to the nmfe batch file (e.g., nmfe?.bat).

Include_R_Code

Logical, whether the include the code in R_Penalty_Code in model averaging algorithm, Default is FALSE

plan

for future execution, one of "sequential", "multisession","multicore", Default is multisession

Details

The function executes the mbbe::run_mbbe_json() function. A user supplied installation of NONMEM is required run_dir is the parent folder where the models are to be run, nmfe_path is the path the nmfe??.bat where ?? is the version of NONMEM available plan is "sequential", "multisession","multicore", defining the plan for parallel execution (sequential is non-parallel execution) The function uses the included file mbbeargs.json as the options file for the run, and runs 5 supplied models for model averaging. Monte Carlo Simulation is then done, with the number of samples set in the mbbearg.json file, to 10 (probaby more would be appropriate for and actual power analysis) The model selection for the model averaging also includes a penalty calculate by the script RPenaltyCode.r for missing Cmax, AUCinf and AUClast Run time on 32 cores is ~3 minutes without the R code execution an 10 minutes with and the output should include:

Value

A list containing:

  • Cmax_power: Power for Cmax

  • AUClast_power: Power for AUClast

  • AUCinf_power: Power for AUCinf

  • run_dir: Directory where the function was executed

  • Num_identifiable: Number of identifiable parameters

  • BICS: Bayesian Information Criterion Scores

Examples

## Not run: 
run_dir <- tempdir()
mbbe::run_example(run_dir = run_dir,
  nmfe_path = "c:/nm74g64/util/nmfe74.bat",
  plan = "multisession")

## End(Not run)

Execute MBBE Analysis

Description

This function runs the MBBE analysis. It's typically called by run_mbbe_json which provides the necessary options via a JSON file.

Usage

run_mbbe(
  crash_value,
  ngroups,
  reference_groups,
  test_groups,
  num_parallel,
  samp_size,
  run_dir,
  model_source,
  nmfe_path,
  delta_parms,
  use_check_identifiable,
  NCA_end_time,
  rndseed,
  simulation_data_path,
  plan = c("multisession", "sequential", "multicore"),
  alpha_error = 0.05,
  NTID = FALSE,
  model_averaging_by = "study",
  user_R_code = FALSE,
  R_code_path = "",
  save_plots = FALSE,
  ...
)

Arguments

crash_value

Numeric. Value to be returned for BIC in models that crash during either bootstrap or simulation.

ngroups

Integer. Number of groups in the simulated data (e.g., an ABBA design has 4 groups).

reference_groups

Numeric vector. Indices of the groups representing the reference formulation (e.g., c(2,3) for an ABBA design).

test_groups

Numeric vector. Indices of the groups representing the test formulation (e.g., c(1,4) for an ABBA design).

num_parallel

Integer. Number of NONMEM processes (both bootstrap and simulation) to run concurrently.

samp_size

Integer. Size of the bootstrap and simulation samples.

run_dir

Character string. Directory for NONMEM execution.

model_source

Character string. Paths to the NONMEM control files for model averaging.

nmfe_path

Character string. Path to the nmfe executable.

delta_parms

Numeric. Parameter difference threshold defining identifiability.

use_check_identifiable

Logical. Should identifiability be checked based on the criterion defined by Aoki?

NCA_end_time

Numeric. The NCA calculation will start at 0 and end at this value.

rndseed

Integer. Random seed for reproducibility.

simulation_data_path

Character string. Path to the simulation dataset.

plan

Character string (default: "multisession"). Parallel execution plan. Can be "multisession", "sequential", or "multicore".

alpha_error

Numeric (default: 0.05). Alpha error rate for statistical tests.

NTID

Logical (default: FALSE). Is the drug a narrow therapeutic index drug?

model_averaging_by

Character string (default: "study"). Method of model averaging, either "study" or "subject".

user_R_code

Logical (default: FALSE). Should custom R code be used for model penalty?

R_code_path

Character string. If user_R_code is TRUE, this parameter defines the path to the custom R script.

save_plots

Logical (default: FALSE). Set to TRUE to save plot output.

...

Additional args

Details

This function is primarily intended to be called by run_mbbe_json, which provides input parameters through a JSON configuration.

Value

A list containing:

  • Cmax_power: Power for Cmax

  • AUClast_power: Power for AUClast

  • AUCinf_power: Power for AUCinf

  • run_dir: Directory where the function was executed

  • Num_identifiable: Number of identifiable parameters

  • BICS: Bayesian Information Criterion Scores


run_mbbe_json

Description

Runs MBBE from a json file of options e.g., calls run_mbbe

Usage

run_mbbe_json(Args.json)

Arguments

Args.json

path to JSON file with arguments

Value

A list containing:

  • Cmax_power: Power for Cmax

  • AUClast_power: Power for AUClast

  • AUCinf_power: Power for AUCinf

  • run_dir: Directory where the function was executed

  • Num_identifiable: Number of identifiable parameters

  • BICS: Bayesian Information Criterion Scores

Examples

## Not run: 
run_mbbe_json("Args.json")

## End(Not run)