Example: Oral bioavailability (logit-normal F)
Oral bioavailability F is a fraction bounded in (0, 1). Estimating it with a log-normal ETA (the default for most PK parameters) is inappropriate because log-normal values are unbounded above. ferx supports a logit-normal parameterisation that constrains F to (0, 1) on the natural scale while the optimiser works on an unbounded logit scale.
Parameterisation
F_i = inv_logit(logit(THETA_F) + ETA_F_i)
THETA_Fis the typical bioavailability, specified directly on the (0, 1) scale (e.g.0.70for 70%). ferx applieslogit(THETA_F)internally so the optimiser works on an unbounded scale.omega ETA_Fis the BSV variance on the logit scale — not the variance of F itself. Smallomega_Fstill allows large F variability near F = 0.5 and smaller variability near F = 0 or 1 (the logit squeeze effect).
Example A — analytical one-compartment model
The bioavailability bundled example uses the analytical one_cpt_oral solver with an f=F slot:
[parameters]
theta TVCL(5.0, 0.1, 50.0)
theta TVV(50.0, 5.0, 500.0)
theta TVKA(1.5, 0.05, 20.0)
theta THETA_F(0.70, 0.001, 0.999)
omega ETA_CL ~ 0.09
omega ETA_F ~ 0.10
sigma PROP_ERR ~ 0.15 (sd)
[individual_parameters]
CL = TVCL * exp(ETA_CL)
V = TVV
KA = TVKA
F = inv_logit(logit(THETA_F) + ETA_F)
[structural_model]
pk one_cpt_oral(cl=CL, v=V, ka=KA, f=F)
[error_model]
DV ~ proportional(PROP_ERR)
[fit_options]
method = focei
maxiter = 500
covariance = true
library(ferx)
ex <- ferx_example("bioavailability")
fit <- ferx_fit(ex$model, ex$data)
print(fit)Example B — ODE implementation
bioavailability_ode is the ODE equivalent of Example A — same model, same data, same true parameters — useful for verifying that the ODE and analytical paths agree. F enters the depot→central transfer directly in the ODE:
[odes]
d/dt(depot) = -KA * depot
d/dt(central) = F * KA * depot / V - CL/V * central
library(ferx)
ex <- ferx_example("bioavailability_ode")
fit <- ferx_fit(ex$model, ex$data)
print(fit)Warfarin variant
warfarin_logit_f applies the same logit-normal F parameterisation to the standard warfarin dataset:
library(ferx)
ex <- ferx_example("warfarin_logit_f")
fit <- ferx_fit(ex$model, ex$data)
print(fit)Listing all available examples
?ferx_example # see full list in the help page
ferx_example() # returns a character vector of all example names