Skip to content

fit.models

fit.models_exponential

Exponential models of concentration timecourses.

Sums of exponentials describe the decline of a concentration after an intravenous dose and, with an absorption term, after an extravascular dose (Gibaldi & Perrier 1982, ch. 1-2; Gabrielsson & Weiner 2016, ch. 3). The models here are descriptive: the coefficients a_i and rate constants k_i carry no compartmental interpretation; lambda_z is the smallest rate constant, t½ = ln 2 / k, and the area is sum a_i / k_i.

  • MonoExp: y = a e^{-k x}
  • BiExp: y = a1 e^{-k1 x} + a2 e^{-k2 x} with k1 > k2
  • TriExp: three terms with k1 > k2 > k3
  • Bateman: y = a ka / (ka - ke) (e^{-ke t} - e^{-ka t}), the one compartment curve with first order absorption, optionally with a lag time; ka < ke is a flip-flop (the terminal phase reflects absorption)

The initial guesses use the method of residuals (curve stripping): the terminal phase is regressed on the last points, its contribution is subtracted and the residuals give the faster phase.

MonoExp

Bases: Model

y = a exp(-k x).

predict

predict(x, p)

The curve.

derived

derived(p)

Half-life and area.

initial_guess

initial_guess(x, y)

From the log-linear regression of the positive points.

BiExp

Bases: _SumOfExponentials

y = a1 exp(-k1 x) + a2 exp(-k2 x) with k1 > k2.

TriExp

Bases: _SumOfExponentials

y = a1 exp(-k1 x) + a2 exp(-k2 x) + a3 exp(-k3 x) with k1 > k2 > k3.

Bateman

Bateman(lag=False)

Bases: Model

One compartment with first order absorption: y = a ka/(ka - ke) (e^{-ke t} - e^{-ka t}).

t = max(x - tlag, 0) with the optional lag time. a is the dose over the apparent volume (D F / V), so auc = a / ke.

Parameters:

Name Type Description Default
lag bool

whether a lag time tlag is fitted

False

Create the model with or without a lag time.

Parameters:

Name Type Description Default
lag bool

whether a lag time tlag is fitted.

False

predict

predict(x, p)

The curve, with the ka == ke limit a ka t exp(-ke t).

derived

derived(p)

Time and value of the maximum, half-life, area and the flip-flop indicator.

Computed with numpy under numpy.errstate, so a rate constant of zero, which a degenerate fit can end at, gives an infinite or undefined value instead of the ZeroDivisionError of python floats or the ValueError of math.log.

initial_guess

initial_guess(x, y)

ke from the terminal phase, ka from the rise (or 5 ke), a from the maximum.

log_linear_regression

log_linear_regression(x, y)

Slope and intercept of ln y on x over the finite positive points.

Parameters:

Name Type Description Default
x ndarray

independent variable.

required
y ndarray

dependent variable.

required

Returns:

Type Description
tuple[float, float]

(slope, intercept), (nan, nan) with fewer than two usable points.

terminal_guess

terminal_guess(x, y)

a and k of the terminal phase from the last half of the points after the maximum.

Parameters:

Name Type Description Default
x ndarray

independent variable.

required
y ndarray

dependent variable.

required

Returns:

Type Description
float

(a, k), falling back to the maximum and ln 2 / (range / 3) when no

float

regression is possible, or when the regression line at x = 0 is

tuple[float, float]

beyond the range of double precision.

fit.models_response

Concentration-effect models (Emax family).

The Emax model E = E0 + Emax C / (EC50 + C) and its sigmoid form with the Hill coefficient n describe a saturable response (Gabrielsson & Weiner 2016, ch. 4; Bonate 2011), the exposure-response relationship regulatory guidance addresses (FDA 2003); Imax is the inhibitory form E = E0 (1 - Imax C / (IC50 + C)). EC90 = 9^{1/n} EC50 is the concentration of 90 % of the maximal effect. The same models describe a pharmacokinetic parameter against an inhibitor dose.

Emax

Bases: Model

E = e0 + emax x / (ec50 + x).

predict

predict(x, p)

The curve.

derived

derived(p)

ec90 = 9 ec50.

initial_guess

initial_guess(x, y)

Baseline at the smallest x, plateau at the largest, ec50 at the half-way crossing.

SigmoidEmax

Bases: Emax

E = e0 + emax x^n / (ec50^n + x^n) with the Hill coefficient n.

predict

predict(x, p)

The curve.

derived

derived(p)

ec90 = 9^(1/n) ec50.

initial_guess

initial_guess(x, y)

The Emax guess with hill = 1.

Imax

Bases: Model

E = e0 (1 - imax x / (ic50 + x)).

predict

predict(x, p)

The curve.

derived

derived(p)

ic90 = 9 ic50.

initial_guess

initial_guess(x, y)

Baseline at the smallest x, inhibition from the minimum, ic50 at the half-way crossing.

SigmoidImax

Bases: Imax

E = e0 (1 - imax x^n / (ic50^n + x^n)).

predict

predict(x, p)

The curve.

derived

derived(p)

ic90 = 9^(1/n) ic50.

initial_guess

initial_guess(x, y)

The Imax guess with hill = 1.

fit.models_linear

Linear, log-linear, power and allometric models.

Power (y = a x^b) is the model of dose proportionality (Smith et al. 2000): b = 1 is proportional; proportionality_test in pkpdutils.fit.proportionality applies the confidence interval criterion. Allometric is the same model for a parameter against body weight with the exponent free or fixed (0.75 for clearances, 1 for volumes; Rowland & Tozer 2011, ch. 12). Linear and LogLinear describe an effect or a parameter against a concentration or covariate.

Linear

Bases: Model

y = intercept + slope x.

predict

predict(x, p)

The line.

initial_guess

initial_guess(x, y)

Ordinary least squares.

LogLinear

Bases: Model

y = intercept + slope ln x for x > 0.

predict

predict(x, p)

The curve (NaN for x <= 0).

initial_guess

initial_guess(x, y)

Least squares on ln x, a flat line at zero without a positive x.

Power

Bases: Model

y = a x^b for x > 0.

predict

predict(x, p)

The curve.

initial_guess

initial_guess(x, y)

Least squares on the log-log data, a = 1, b = 1 without a positive x.

Allometric

Allometric(exponent=None)

Bases: Model

y = a x^b against body weight with the exponent free or fixed.

Parameters:

Name Type Description Default
exponent float | None

fixed exponent (0.75 for clearances, 1 for volumes), None to fit it

None

Create the model with a free or a fixed exponent.

Parameters:

Name Type Description Default
exponent float | None

fixed exponent, None to fit it.

None

predict

predict(x, p)

The curve.

initial_guess

initial_guess(x, y)

Log-log least squares (a only when the exponent is fixed), a = 1 without a positive x.