Skip to main content

Module bestdose

Module bestdose 

Source
Expand description

Dose optimization and forecasting (BestDose).

§BestDose: dose forecasting and optimization

BestDose finds dosing regimens that hit target drug concentrations or AUC values for a given distribution over model parameters.

The distribution is supplied by the caller as support points (Theta) and probability Weights. It typically comes from a population fit, optionally updated to a patient-specific posterior with the NCNPAG or NPMAP algorithms.

§Flow

use pmcore::bestdose::{BestDoseProblem, BestDoseOptions, DoseRange, Target};
use pmcore::prelude::*;

// 1. Fit the population model with any algorithm.
let fit = EstimationProblem::nonparametric(eq.clone(), pop_data, prior_theta, ems.clone())?
    .fit_with(NpagConfig::default())?;

// 2. Choose the distribution: patient-specific posterior (past data) or population.
let (theta, weights) = match past_data {
    Some(past) => {
        let post = EstimationProblem::nonparametric(
                eq.clone(), data::Data::new(vec![past]), fit.get_theta().clone(), ems.clone())?
            .fit_with(NcnpagConfig::default())?; // or NpmapConfig::default()
        (post.get_theta().clone(), post.weights().clone())
    }
    None => (fit.get_theta().clone(), fit.weights().clone()),
};

// 3. Optimize doses.
let problem = BestDoseProblem::new(eq, theta, weights)?;
let result = problem.optimize(
    target,
    Target::Concentration,
    DoseRange::new(0.0, 300.0),
    0.5, // bias λ: 0 = personalized, 1 = population-typical
    BestDoseOptions::default(),
)?;

let optimal_subject = result.subject();
let cost = result.cost();

§Cost function

optimize minimizes, over the optimizable doses, a hybrid objective computed from the single distribution (theta, weights):

Cost = (1-λ) × Variance + λ × Bias²
Variance = Σᵢ wᵢ Σⱼ (targetⱼ − pred[i,j])²      (expected squared error)
Bias²    = Σⱼ (targetⱼ − Σᵢ wᵢ pred[i,j])²       (error of the weighted mean)

Modules§

cost
Cost function calculation for BestDose optimization
predictions
AUC / dense-grid helpers used by the cost function.

Structs§

Achievement
How well the optimal doses hit a single target observation.
BestDoseOptions
Optional forecasting settings for BestDoseProblem::optimize.
BestDoseProblem
A dose-optimization problem over a parameter distribution.
BestDoseResult
Result of a BestDose optimization: the optimal dosing subject, its cost, and how well each target was achieved.
DoseRange
Allowable dose range for optimization.

Enums§

Target
Target type for dose optimization.