Core Types
The main types exported by ferx_nlme. All types are available via use ferx_nlme::*.
CompiledModel
A parsed and compiled model ready for estimation. Created by parse_model_file() or parse_full_model_file().
#![allow(unused)] fn main() { pub struct CompiledModel { pub name: String, pub pk_model: PkModel, pub error_model: ErrorModel, pub pk_param_fn: PkParamFn, // (theta, eta, covariates) -> PkParams pub n_theta: usize, pub n_eta: usize, pub n_epsilon: usize, pub theta_names: Vec<String>, pub eta_names: Vec<String>, pub default_params: ModelParameters, pub tv_fn: Option<...>, // Typical values function (for AD) pub pk_indices: Vec<usize>, // Maps eta index -> PK parameter index pub ode_spec: Option<OdeSpec>, // ODE specification (if ODE model) } }
Key fields:
pk_param_fn: Closure that maps (theta, eta, covariates) to PK parameters. Generated by the parser from[individual_parameters].default_params: Initial parameter values from[parameters]block.ode_spec: Present only for ODE models;Nonefor analytical models.
Population and Subject
#![allow(unused)] fn main() { pub struct Population { pub subjects: Vec<Subject>, pub covariate_names: Vec<String>, pub dv_column: String, } pub struct Subject { pub id: String, pub doses: Vec<DoseEvent>, pub obs_times: Vec<f64>, pub observations: Vec<f64>, pub obs_cmts: Vec<usize>, pub covariates: HashMap<String, f64>, // Time-constant pub tvcov: HashMap<String, Vec<f64>>, // Time-varying (LOCF) } }
ModelParameters
#![allow(unused)] fn main() { pub struct ModelParameters { pub theta: Vec<f64>, pub theta_names: Vec<String>, pub theta_lower: Vec<f64>, pub theta_upper: Vec<f64>, pub omega: OmegaMatrix, pub sigma: SigmaVector, } }
OmegaMatrix
Between-subject variability matrix with pre-computed Cholesky factor.
#![allow(unused)] fn main() { pub struct OmegaMatrix { pub matrix: DMatrix<f64>, // Full omega matrix pub chol: DMatrix<f64>, // Lower Cholesky factor L (Omega = L*L') pub eta_names: Vec<String>, pub diagonal: bool, // True if omega is diagonal } }
Constructors:
OmegaMatrix::from_matrix(m, names, diagonal)-- From a full matrix (computes Cholesky, regularizes if needed)OmegaMatrix::from_diagonal(variances, names)-- From diagonal variances
FitOptions
#![allow(unused)] fn main() { pub struct FitOptions { pub method: EstimationMethod, // Foce, FoceI, or Saem pub outer_maxiter: usize, // Default: 500 pub outer_gtol: f64, // Default: 1e-6 pub inner_maxiter: usize, // Default: 200 pub inner_tol: f64, // Default: 1e-8 pub run_covariance_step: bool, // Default: true pub interaction: bool, // FOCEI flag pub verbose: bool, // Default: true pub optimizer: Optimizer, // Default: Slsqp pub lbfgs_memory: usize, // Default: 5 pub global_search: bool, // Default: false pub global_maxeval: usize, // Default: 0 (auto) // SAEM-specific pub saem_n_exploration: usize, // Default: 150 pub saem_n_convergence: usize, // Default: 250 pub saem_n_mh_steps: usize, // Default: 3 pub saem_adapt_interval: usize, // Default: 50 pub saem_seed: Option<u64>, // Default: None } }
Use FitOptions::default() for standard FOCE settings.
FitResult
#![allow(unused)] fn main() { pub struct FitResult { pub method: EstimationMethod, pub converged: bool, pub ofv: f64, pub aic: f64, pub bic: f64, pub theta: Vec<f64>, pub theta_names: Vec<String>, pub omega: DMatrix<f64>, pub sigma: Vec<f64>, pub covariance_matrix: Option<DMatrix<f64>>, pub se_theta: Option<Vec<f64>>, pub se_omega: Option<Vec<f64>>, pub se_sigma: Option<Vec<f64>>, pub subjects: Vec<SubjectResult>, pub n_obs: usize, pub n_subjects: usize, pub n_parameters: usize, pub n_iterations: usize, pub interaction: bool, pub warnings: Vec<String>, } }
SubjectResult
Per-subject diagnostics from the fit.
#![allow(unused)] fn main() { pub struct SubjectResult { pub id: String, pub eta: DVector<f64>, pub ipred: Vec<f64>, // Individual predictions pub pred: Vec<f64>, // Population predictions pub iwres: Vec<f64>, // Individual weighted residuals pub cwres: Vec<f64>, // Conditional weighted residuals pub ofv_contribution: f64, } }
Enums
#![allow(unused)] fn main() { pub enum EstimationMethod { Foce, FoceI, Saem } pub enum PkModel { OneCptIvBolus, OneCptOral, OneCptInfusion, TwoCptIvBolus, TwoCptOral, TwoCptInfusion } pub enum ErrorModel { Additive, Proportional, Combined } pub enum Optimizer { Bfgs, Lbfgs, Slsqp, NloptLbfgs, Mma } }
DoseEvent
#![allow(unused)] fn main() { pub struct DoseEvent { pub time: f64, pub amt: f64, pub cmt: usize, pub rate: f64, pub duration: f64, pub ss: bool, pub ii: f64, } }