Fitting Non-Identifiable and Poorly Identifiable Models using Bayesian Inference

Author

Mohamed Tarek

In this tutorial, we will see how to use Bayesian inference in Pumas to fit a non-identifiable (or a poorly identifiable) model by sampling from the full posterior. Unlike maximum likelihood estimation methods which only find point estimates for the model parameters, Bayesian methods can be used to sample from the full posterior of the model parameters making it more robust to identifiability issues.

1 Model Identifiability

One of the goals of statistical learning is to identify the underlying parameter values in a parametric model that best fit the observed data. In many practical scenarios, some parameters in a model may not be identifiable, for one of the following problems:

  1. The model is over-parameterized with redundant parameters, where a continuum of parameter values, e.g \(0 \leq \theta \leq 1\), would all give identical model predictions. This tends to happen when a dynamical model has many compartments and associated parameters but only one or a few compartments are observed. Another case where this happens is if there is a typo in the model where a parameter is not used everywhere it should.
  2. The model has symmetries such that a discrete set of parameter values, e.g. \(\theta = -1\) or \(\theta = 1\), give identical model predictions. This tends to happen with inappropriate use of the “absolute value” function (abs) if used on a function that can be either negative or positive potentially creating 2 separate modes. This problem can sometimes be fixed by using appropriate parameter bounds, e.g. \(\theta \geq 0\), in the model.
  3. The data is insufficient to learn some parameters’ values but more data would have been sufficient.

The first 2 problems are problems in the model describing structural non-identifiability and the third problem is a problem in the data or data-model mismatch describing practical non-identifiability (sometimes called non-estimability).

Type of Identifiability Description
Globally Structurally Identifiable Every set of parameter values \(\theta\) makes a unique model prediction \(\mu(\theta)\).
Globally Practically Identifiable Globally structurally identifiable and there is enough data to estimate the data-generating parameter values.
Locally Structurally Identifiable Only dis-connected parameters values \(\{\theta_1, \theta_2, \dots, \theta_m\}\) can result in the same model prediction \(\mu\), i.e. \(\mu(\theta_1) = \mu(\theta_2) = \dots = \mu(\theta_m)\). However, in the neighborhood \(N(\theta)\) of each set of parameters \(\theta\), each \(\theta' \in N(\theta)\) results in a unique model prediction \(\mu(\theta')\).
Locally Practically Identifiable Locally structurally identifiable and there is enough data to estimate the (potentially non-unique but dis-connected) data-generating parameter values.
Key Points
  • Local (or global) practical identifiablity is what we usually want in analyses.
  • Practical identifiability (estimability) implies structural identifiability.
Poor Identifiability

When a model may be identifiable in exact arithmetic but its identifiability is sensitive to numerical errors in computations, we will call it poorly identifiable. When the term “poorly identifiable models” is used in the rest of this tutorial, this also includes truly non-identifiable models.

2 Example

Let’s consider an example of fitting a poorly identifiable model.

2.1 Loading Pumas

First, let’s load Pumas:

using Pumas

2.2 Two Compartment Model

Now let’s define a single-subject, 2-compartment model with a depot, central and peripheral compartments and a proportional error model.

model = @model begin
    @param begin
        θ  VectorDomain(lower = zeros(5))
        σ  RealDomain(lower = 0.0)
    end
    @pre begin
        CL = θ[1]
        Vc = θ[2]
        Ka = θ[3]
        Vp = θ[4]
        Q = θ[5]
    end
    @dynamics begin
        Depot' = -Ka * Depot
        Central' = Ka * Depot - (CL + Q) / Vc * Central + Q / Vp * Peripheral
        Peripheral' = Q / Vc * Central - Q / Vp * Peripheral
    end
    @derived begin
        cp := @. Central / Vc
        dv ~ @. Normal(cp, abs(cp) * σ + 1e-6)
    end
end
PumasModel
  Parameters: θ, σ
  Random effects:
  Covariates:
  Dynamical system variables: Depot, Central, Peripheral
  Dynamical system type: Nonlinear ODE
  Derived: dv
  Observed: dv
Subject Model vs Population Model

Note that studying the identifiability of subject models is still relevant when fitting a population version of the model with typical values and random effects. The reason is that when evaluating the log likelihood using the Laplace method or first-order conditional estimation (FOCE), one of the steps involved is finding the empirical Bayes estimates (EBE) which is essentially fitting a subject’s version of the model, fixing population parameters and estimating random effects. Non-identifiability in the EBE estimation can often cause the EBE estimation to fail or to be so numerically unstable that the population parameters’ fit itself fails because the marginal likelihood (and its gradient) computed with Laplace/FOCE relied on incorrect or numerically unstable EBEs.

2.3 Parameter Values

Let’s define some parameter values to use for simulation.

params == [35, 100, 0.5, 210, 30], σ = 0.1)
(θ = [35.0, 100.0, 0.5, 210.0, 30.0],
 σ = 0.1,)

2.4 Subject Definition

Next we define a subject skeleton with a single bolus dose and no observations.

skeleton = Subject(
    id = 1,
    time = 0.0:0.5:30.0,
    events = DosageRegimen(3000, time = 0.0, cmt = 1),
    observations = (; dv = nothing),
)
Subject
  ID: 1
  Events: 1
  Observations: dv: (n=61)

2.5 Fisher Information Matrix

The expected Fisher Information Matrix (FIM) is an important diagnostic which can be used to detect local practical identifiability (LPI) given the model and the experiment design [1]. The first order approximation of the expected FIM [2,3] has also been used successfully to analyze the LPI of pharmacometric nonlinear mixed effect (NLME) models [4,5,6].

The positive definiteness (non-singularity) of the expected FIM \(F(\theta)\) at parameters \(\theta\) is a sufficient condition for LPI at \(\theta\). Under more strict assumptions which are more difficult to verify, the positive definiteness of \(F(\theta)\) is even a necessary condition for LPI [1].

To compute a first-order approximation of the expected FIM, we will use the OptimalDesign package:

using OptimalDesign

times = OptimalDesign.ObsTimes(skeleton.time)
F = OptimalDesign.fim(model, [skeleton], params, [times])
6×6 Symmetric{Float64, Matrix{Float64}}:
  1.29489    -0.0538762     13.6934     0.0254882   -0.218694      -2.68028
 -0.0538762   0.0188821     -4.38015   -0.00168545   0.0296863     -0.325336
 13.6934     -4.38015     1054.71       0.635262    -7.13309       66.7482
  0.0254882  -0.00168545     0.635262   0.00215196  -0.00487912    -0.0895271
 -0.218694    0.0296863     -7.13309   -0.00487912   0.144604      -0.720992
 -2.68028    -0.325336      66.7482    -0.0895271   -0.720992    1667.74

2.6 Procedure for Detecting Practical Non-Identifiability

Next, let’s do an eigenvalue decomposition of F to find the smallest eigenvalue. The smallest eigenvalue is always the first one because they are sorted.

E = eigen(F)
E.values[1]
9.646842562376956e-5

It is close to 0! This implies that the matrix is very close to being singular. While this is not strictly a proof of local non-identifiability, it is one step towards detecting non-identifiability.

Tip

The non-singularity of the expected FIM is generally only a sufficient (not necessary) condition for local identifiability. So there are some locally identifiable models that have a singular or undefined expected FIM. However, there is a subclass of models satisfying strict assumptions for which the non-singularity of the expected FIM is a necessary condition for local identifiability [1]. In practice, these assumptions are difficult to verify for a general model but if our model happens to satisfy these assumptions, then a singular expected FIM would imply local non-identifiability. In that case, the eigenvector(s) corresponding to the 0 eigenvalue would be useful diagnostics as they point in the directions along which changes in the parameters will have no effect on the log likelihood.

To summarize:

  • Being “Non-Singular” Isn’t Always a Must: A non-singular expected FIM always signals that a model is “locally identifiable” (meaning you can find a locally unique solution for its parameters). However, some locally identifiable models can still have singular or undefined expected FIM.
  • Sometimes, It’s Absolutely Necessary: There’s a special group of models where a non-singular expected FIM is required to be locally identifiable. It’s hard to know if your model falls into this group.
  • Practical Use: Even if your expected FIM is singular, it may be a helpful diagnostic. The eigenvectors of the FIM with 0 eigenvalues show you directions where changing the model’s parameters may not affect the model’s predictions – this may help you pinpoint where the model is fuzzy.

To prove if a model is practically non-identifiable, it suffices to find a single set \(\Theta\) such that for all parameters \(\theta \in \Theta\), the log likelihood is unchanged. To find \(\Theta\) numerically, one can

  1. Assume parameter values \(\theta_0\),
  2. Define a criteria for changing the parameters \(\theta\) from their current values \(\theta_0\), and then create a candidate set of parameters \(\Theta_c\),
  3. Simulate synthetic data using the parameters \(\theta_0\),
  4. Evaluate the log likelihood \(L(\theta)\) for all \(\theta \in \Theta_c\),
  5. Evaluate the sensitivity of the log likelihood to local changes within \(\Theta_c\).

One way to construct a candidate \(\Theta_c\) is as the set \(\{\theta_0 + \alpha \cdot d : \alpha \in [-\epsilon, \epsilon] \}\) for a small \(\epsilon > 0\), where \(d\) is an eigenvector corresponding to the smallest eigenvalue of the expected FIM, \(F\). The sensitivity of the log likelihood to changes within \(\Theta_c\) can then be quantified as the average value of:

\[ \Bigg( \frac{L(\theta_0 + \alpha \cdot d) - L(\theta_0)}{\alpha} \Bigg)^2 \]

for all \(\alpha \in [-\epsilon, \epsilon]\), \(\alpha \neq 0\). Let’s follow this procedure for the above model assuming \(\theta_0\) is params.

2.7 Simulating Data

Here we simulate a synthetic subject using the skeleton subject we have. We fix the seed of the pseudo-random number generator for reproducibility.

using Random

Random.seed!(12345)
pop = [Subject(simobs(model, skeleton, params))]
Population
  Subjects: 1
  Observations: dv

To evaluate the log likelihood of params given pop, we can use the loglikelihood function:

ll0 = loglikelihood(model, pop, params, NaivePooled())
32.824611660476236

Since there are no random effects in this model, we use the NaivePooled() algorithm in Pumas.

2.8 Local Sensitivity Analysis of Log Likelihood

The eigenvectors corresponding to the smallest eigenvalue of F give us the directions that are likely to have the largest standard error in the maximum likelihood estimates. These are the most promising directions to test when constructing candidate sets \(\Theta_c\) for identifiability analysis. To get the eigenvector corresponding to the smallest eigenvalue, you can run:

d = E.vectors[:, 1]
6-element Vector{Float64}:
  0.006717009025688778
  0.8382731175267348
  0.0037560578471354886
 -0.5451738773361731
  0.004939403972915483
 -3.13735234359295e-6

The order of parameters is the same as the order of definition in the model: θ and then σ.

Note that the potential non-identifiability seems to be mostly in the second and fourth parameter, Vc and Vp. More precisely, the above eigenvector implies that simultaneously increasing Vc and decreasing Vp (or vice versa) by the ratios given in d may have little to no effect on the log likelihood.

Let’s try to add α * d[1:end-1] to params.θ (i.e. move params.θ in the direction d[1:end-1]) and evaluate the log likelihood for different step sizes α. To do that, we will first define a function that moves params.θ and call it on different step values α. These choices of α values correspond to a discrete candidate set \(\Theta_c\).

function moveθ(α)
    # unpacking the fields of params to variables with the same names
    (; θ, σ) = params
    # move θ by step * d[1:end-1]
    return (; θ = θ + α * d[1:end-1], σ)
end
# move by both negative and positive steps (excluding α = 0)
αs = vcat(-1e-3 .* (1:10), 1e-3 .* (1:10))
20-element Vector{Float64}:
 -0.001
 -0.002
 -0.003
 -0.004
 -0.005
 -0.006
 -0.007
 -0.008
 -0.009
 -0.01
  0.001
  0.002
  0.003
  0.004
  0.005
  0.006
  0.007
  0.008
  0.009
  0.01
newparams = moveθ.(αs)
20-element Vector{@NamedTuple{θ::Vector{Float64}, σ::Float64}}:
 (θ = [34.99999328299097, 99.99916172688248, 0.49999624394215286, 210.00054517387733, 29.999995060596028], σ = 0.1)
 (θ = [34.99998656598195, 99.99832345376494, 0.4999924878843057, 210.00109034775468, 29.999990121192056], σ = 0.1)
 (θ = [34.99997984897292, 99.99748518064742, 0.4999887318264586, 210.001635521632, 29.99998518178808], σ = 0.1)
 (θ = [34.9999731319639, 99.9966469075299, 0.49998497576861145, 210.00218069550934, 29.999980242384108], σ = 0.1)
 (θ = [34.99996641495487, 99.99580863441237, 0.4999812197107643, 210.0027258693867, 29.999975302980136], σ = 0.1)
 (θ = [34.99995969794585, 99.99497036129483, 0.4999774636529172, 210.00327104326402, 29.999970363576164], σ = 0.1)
 (θ = [34.99995298093682, 99.99413208817731, 0.49997370759507004, 210.00381621714135, 29.99996542417219], σ = 0.1)
 (θ = [34.9999462639278, 99.99329381505979, 0.4999699515372229, 210.00436139101868, 29.999960484768216], σ = 0.1)
 (θ = [34.99993954691877, 99.99245554194226, 0.49996619547937576, 210.00490656489603, 29.999955545364244], σ = 0.1)
 (θ = [34.999932829909746, 99.99161726882473, 0.4999624394215286, 210.00545173877336, 29.999950605960272], σ = 0.1)
 (θ = [35.00000671700903, 100.00083827311752, 0.5000037560578471, 209.99945482612267, 30.000004939403972], σ = 0.1)
 (θ = [35.00001343401805, 100.00167654623506, 0.5000075121156943, 209.99890965224532, 30.000009878807944], σ = 0.1)
 (θ = [35.00002015102708, 100.00251481935258, 0.5000112681735414, 209.998364478368, 30.00001481821192], σ = 0.1)
 (θ = [35.0000268680361, 100.0033530924701, 0.5000150242313885, 209.99781930449066, 30.000019757615892], σ = 0.1)
 (θ = [35.00003358504513, 100.00419136558763, 0.5000187802892356, 209.9972741306133, 30.000024697019864], σ = 0.1)
 (θ = [35.00004030205415, 100.00502963870517, 0.5000225363470828, 209.99672895673598, 30.000029636423836], σ = 0.1)
 (θ = [35.00004701906318, 100.00586791182269, 0.5000262924049299, 209.99618378285865, 30.00003457582781], σ = 0.1)
 (θ = [35.0000537360722, 100.00670618494021, 0.5000300484627771, 209.99563860898132, 30.000039515231784], σ = 0.1)
 (θ = [35.00006045308123, 100.00754445805774, 0.5000338045206242, 209.99509343510397, 30.000044454635756], σ = 0.1)
 (θ = [35.000067170090254, 100.00838273117527, 0.5000375605784714, 209.99454826122664, 30.000049394039728], σ = 0.1)

Now let’s evaluate the log likelihoods of all these parameter sets.

lls = map(newparams) do p
    loglikelihood(model, pop, p, NaivePooled())
end
20-element Vector{Float64}:
 32.82463258849702
 32.824653516925856
 32.82467444575527
 32.82469537518845
 32.824716304876276
 32.82473723532276
 32.82475816599724
 32.8247790973253
 32.82480002901429
 32.82482096110599
 32.8245907329934
 32.824569805959214
 32.82454887944093
 32.82452795331599
 32.824507027606245
 32.824486102538266
 32.82446517786739
 32.8244442536138
 32.82442332987449
 32.82440240661064

To compute the average sensitivity within \(\Theta_c\), we then call:

sens = abs2.((lls .- ll0) ./ αs)
mean(sens)
0.00043796995166702515

Not very sensitive! Therefore, we can conclude that the log likelihood is almost the same inside \(\Theta_c\). This is a strong sign of non-identifiability, or at least poor identifiability.

Let’s contrast this with a random direction d2:

d2 = normalize(rand(6))
function moveθ2(α)
    # unpacking the fields of params to variables with the same names
    (; θ, σ) = params
    # move θ by step * d2[1:end-1]
    return (; θ = θ + α * d2[1:end-1], σ)
end
newparams2 = moveθ2.(αs)
lls2 = map(newparams2) do p
    loglikelihood(model, pop, p, NaivePooled())
end
sens2 = abs2.((lls2 .- ll0) ./ αs)
mean(sens2)
648.222090921982

Notice the difference in sensitivity compared to a random direction.

Note

In practice, it can be difficult to be definitive about practical non-identifiability with numerical tests due to the nature of computation in floating point numbers where numerical errors can accumulate and either:

  1. Mask a truly singular matrix by reporting its smallest eigenvalue as very close to 0 but not exactly 0 in floating point numbers, or
  2. Make a truly non-singular matrix appear singular because its smallest eigenvalue was close to 0 in exact arithmetic but was computed as exactly 0 in floating point arithmetic.

A small enough average local sensitivity can therefore be taken as numerically equivalent to 0, i.e. local practical non-identifiability. To be more general, we will sometimes use the term poor identifiability to refer to the case when the model is approximately non-identifiable.

3 Fitting a Poorly Identifiable Model

3.1 Maximum Likelihood Estimation

When using maximum likelihood (ML) estimation to fit a poorly identifiable model, the parameter values you get can be dependent on arbitrary factors such as:

  • The initial parameter estimates. Optimization algorithms will typically converge to values close to the initial value which is arbitrary.
  • Level of noise in the data. Different levels of noise in the data can cause the optimization algorithm to take different trajectories reaching different optimal parameter values at the end.
  • The implementation details of the optimization algorithm. For example, some optimization algorithms implicitly favor parameter values with the smallest norm.

Most of these factors have no statistical significance and can be considered arbitrary in any analysis. Therefore, any insights drawn from poorly identifiable parameter values fitted with ML estimation may be flawed. Luckily, the standard error estimation, if done right, will often reveal signs of poor identifiability. However, common techniques for estimating standard errors can often break down when the model is poorly identifiable. For instance,

  1. Asymptotic estimates of standard errors require the model to be locally identifiable,
  2. Bootstrap relies on the same arbitrary optimization algorithm for fitting the data resamples so its estimates are as unreliable as the ML estimates. For instance, since all the re-fits in bootstrapping are typically initialized from the ML estimates, there is a high probability that the optimization algorithm will only converge to nearby values, significantly under-estimating the variance in the ML estimates.
  3. Sampling importance resampling (SIR) may be able to handle non-identifiable models but it requires a good proposal and its results are sensitive to the proposal used.

Example: Sensitivity to Initial Estimates

Let’s fit the model to the same subject but with 2 different sets of initial estimates:

params1 == [35, 100, 0.5, 210, 30], σ = 0.1)
fpm1 = fit(model, pop, params1, NaivePooled())
[ Info: Checking the initial parameter values.
[ Info: The initial negative log likelihood and its gradient are finite. Check passed.
Iter     Function value   Gradient norm 
     0    -3.282461e+01     5.896801e+01
 * time: 0.04216790199279785
     1    -3.299541e+01     8.371540e+01
 * time: 2.0491437911987305
     2    -3.440867e+01     3.937303e+01
 * time: 2.05002498626709
     3    -3.550285e+01     3.429323e+01
 * time: 2.0507497787475586
     4    -3.585802e+01     2.078146e+01
 * time: 2.0514588356018066
     5    -3.605801e+01     4.208231e+00
 * time: 2.052161931991577
     6    -3.606867e+01     5.500193e+00
 * time: 2.052656888961792
     7    -3.607820e+01     5.143560e-01
 * time: 2.0531818866729736
     8    -3.607823e+01     1.670014e-01
 * time: 2.0536959171295166
     9    -3.607823e+01     6.594680e-03
 * time: 2.054196834564209
    10    -3.607823e+01     3.931881e-03
 * time: 2.054750919342041
    11    -3.607823e+01     5.365684e-02
 * time: 2.0553109645843506
    12    -3.607823e+01     2.875457e-02
 * time: 2.0558488368988037
    13    -3.607823e+01     3.163452e-03
 * time: 2.0563488006591797
    14    -3.607823e+01     1.189272e-04
 * time: 2.0568368434906006
FittedPumasModel

Dynamical system type:               Nonlinear ODE
Solver(s): (OrdinaryDiffEqVerner.Vern7,OrdinaryDiffEqRosenbrock.Rodas5P)

Number of subjects:                              1

Observation records:         Active        Missing
    dv:                          61              0
    Total:                       61              0

Number of parameters:      Constant      Optimized
                                  0              6

Likelihood approximation:              NaivePooled
Likelihood optimizer:                         BFGS

Termination Reason:                   GradientNorm
Log-likelihood value:                    36.078234

----------------
     Estimate
----------------
θ₁    34.397
θ₂   103.17
θ₃     0.46566
θ₄   204.44
θ₅    26.234
σ      0.092273
----------------
params2 == [10.0, 300, 1.0, 10.0, 5], σ = 0.2)
fpm2 = fit(model, pop, params2, NaivePooled())
[ Info: Checking the initial parameter values.
[ Info: The initial negative log likelihood and its gradient are finite. Check passed.
Iter     Function value   Gradient norm 
     0     4.245135e+02     6.802168e+02
 * time: 1.3828277587890625e-5
     1     1.499850e+02     4.520555e+01
 * time: 0.0007059574127197266
     2     1.436201e+02     4.485781e+01
 * time: 0.0012969970703125
     3     1.108786e+02     4.698780e+01
 * time: 0.0019378662109375
     4     9.146731e+01     4.889574e+01
 * time: 0.002560853958129883
     5     8.587677e+01     4.879782e+01
 * time: 0.003911018371582031
     6     8.353852e+01     5.068832e+01
 * time: 0.004797935485839844
     7     8.061237e+01     4.922992e+01
 * time: 0.005616903305053711
     8     7.723482e+01     3.939427e+01
 * time: 0.006433963775634766
     9     7.347395e+01     6.732180e+01
 * time: 0.007048845291137695
    10     6.467070e+01     2.181937e+01
 * time: 0.0076618194580078125
    11     5.389941e+01     4.260985e+01
 * time: 0.008528947830200195
    12     4.899559e+01     4.746853e+01
 * time: 0.009382009506225586
    13     4.636064e+01     4.389414e+01
 * time: 0.00993800163269043
    14     4.311120e+01     3.667380e+01
 * time: 0.010489940643310547
    15     3.452695e+01     4.210878e+01
 * time: 0.01124882698059082
    16     2.786722e+01     4.181505e+01
 * time: 0.012017011642456055
    17     2.167865e+01     2.502622e+01
 * time: 0.013242959976196289
    18     2.102586e+01     3.073394e+01
 * time: 0.013806819915771484
    19     2.012361e+01     9.155807e+00
 * time: 0.014354944229125977
    20     1.993999e+01     8.931312e+00
 * time: 0.014930963516235352
    21     1.899136e+01     3.290300e+01
 * time: 0.015488862991333008
    22     1.831295e+01     1.555682e+01
 * time: 0.016043901443481445
    23     1.764099e+01     4.156265e+00
 * time: 0.016633987426757812
    24     1.734278e+01     4.764554e+00
 * time: 0.017225980758666992
    25     1.692204e+01     5.545117e+00
 * time: 0.04168987274169922
    26     1.576407e+01     6.312612e+00
 * time: 0.042784929275512695
    27     1.433865e+01     8.298711e+00
 * time: 0.043762922286987305
    28     1.402269e+01     1.935486e+01
 * time: 0.044693946838378906
    29     1.388981e+01     5.313925e+00
 * time: 0.04543185234069824
    30     1.380201e+01     6.598836e+00
 * time: 0.0461578369140625
    31     1.361376e+01     1.819859e+01
 * time: 0.0474088191986084
    32     1.307080e+01     3.715716e+01
 * time: 0.04812979698181152
    33     1.084750e+01     4.989781e+01
 * time: 0.0488739013671875
    34     8.794238e+00     2.744451e+01
 * time: 0.05069279670715332
    35     7.967408e+00     6.286963e+01
 * time: 0.051724910736083984
    36     5.931440e+00     1.205554e+02
 * time: 0.05252790451049805
    37     1.326882e+00     7.171424e+01
 * time: 0.05331683158874512
    38    -3.689390e+00     4.981381e+01
 * time: 0.05486488342285156
    39    -7.683857e+00     6.783385e+01
 * time: 0.05589485168457031
    40    -8.092027e+00     7.796858e+01
 * time: 0.05674886703491211
    41    -9.110314e+00     4.537887e+01
 * time: 0.05757880210876465
    42    -9.287384e+00     8.050351e+00
 * time: 0.0584409236907959
    43    -9.348582e+00     4.057569e+00
 * time: 0.059474945068359375
    44    -9.351770e+00     5.739435e+00
 * time: 0.060307979583740234
    45    -9.356978e+00     7.035575e+00
 * time: 0.06114602088928223
    46    -9.368317e+00     8.142350e+00
 * time: 0.06245088577270508
    47    -9.397391e+00     8.755167e+00
 * time: 0.06325101852416992
    48    -9.477951e+00     5.352088e+00
 * time: 0.06408381462097168
    49    -9.561863e+00     2.652212e+01
 * time: 0.06490182876586914
    50    -9.929531e+00     4.062858e+01
 * time: 0.06572079658508301
    51    -1.064883e+01     1.589425e+01
 * time: 0.06657290458679199
    52    -1.075110e+01     4.886046e+00
 * time: 0.06763100624084473
    53    -1.084652e+01     3.402713e+01
 * time: 0.06849002838134766
    54    -1.092801e+01     1.835285e+01
 * time: 0.06935882568359375
    55    -1.096860e+01     1.465504e+01
 * time: 0.07072186470031738
    56    -1.100970e+01     6.565916e+00
 * time: 0.07154703140258789
    57    -1.101462e+01     1.227337e+00
 * time: 0.07237100601196289
    58    -1.101764e+01     1.250654e+00
 * time: 0.07321500778198242
    59    -1.102001e+01     4.857709e-01
 * time: 0.0740668773651123
    60    -1.102013e+01     5.436072e-02
 * time: 0.07498002052307129
    61    -1.102013e+01     2.178629e-03
 * time: 0.07585501670837402
    62    -1.102013e+01     1.690983e-04
 * time: 0.07673096656799316
FittedPumasModel

Dynamical system type:               Nonlinear ODE
Solver(s): (OrdinaryDiffEqVerner.Vern7,OrdinaryDiffEqRosenbrock.Rodas5P)

Number of subjects:                              1

Observation records:         Active        Missing
    dv:                          61              0
    Total:                       61              0

Number of parameters:      Constant      Optimized
                                  0              6

Likelihood approximation:              NaivePooled
Likelihood optimizer:                         BFGS

Termination Reason:                   GradientNorm
Log-likelihood value:                    11.020132

---------------
     Estimate
---------------
θ₁    30.963
θ₂   214.26
θ₃    55.564
θ₄   169.43
θ₅    12.071
σ      0.13904
---------------

Now let’s display the estimates of θ side by side:

hcat(coef(fpm1).θ, coef(fpm2).θ)
5×2 Matrix{Float64}:
  34.3968     30.9629
 103.168     214.262
   0.465659   55.5643
 204.442     169.427
  26.2337     12.0708

Notice the significant difference in the final estimates when changing nothing but the initial estimates. Also note that the 2 sets of coefficients are not in the same neighbourhood and don’t have similar log likelihoods. This is indicative of the existence of multiple dis-connected local optima.

Example: Sensitivity to Noise Level

To demonstrate the sensitivity to noise level, we will re-simulate the synthetic subject with the same seed but using a higher σ.

Random.seed!(12345)
newparams = (; θ = params.θ, σ = 0.2)
newpop = [Subject(simobs(model, skeleton, newparams))]
Population
  Subjects: 1
  Observations: dv

Now let’s do the fit once with pop and once with newpop:

fpm1 = fit(model, pop, params, NaivePooled())
[ Info: Checking the initial parameter values.
[ Info: The initial negative log likelihood and its gradient are finite. Check passed.
Iter     Function value   Gradient norm 
     0    -3.282461e+01     5.896801e+01
 * time: 1.5020370483398438e-5
     1    -3.299541e+01     8.371540e+01
 * time: 0.0009648799896240234
     2    -3.440867e+01     3.937303e+01
 * time: 0.0017180442810058594
     3    -3.550285e+01     3.429323e+01
 * time: 0.002454042434692383
     4    -3.585802e+01     2.078146e+01
 * time: 0.003225088119506836
     5    -3.605801e+01     4.208231e+00
 * time: 0.0039348602294921875
     6    -3.606867e+01     5.500193e+00
 * time: 0.004909992218017578
     7    -3.607820e+01     5.143560e-01
 * time: 0.0054209232330322266
     8    -3.607823e+01     1.670014e-01
 * time: 0.005909919738769531
     9    -3.607823e+01     6.594680e-03
 * time: 0.0064160823822021484
    10    -3.607823e+01     3.931881e-03
 * time: 0.006897926330566406
    11    -3.607823e+01     5.365684e-02
 * time: 0.007380962371826172
    12    -3.607823e+01     2.875457e-02
 * time: 0.00786590576171875
    13    -3.607823e+01     3.163452e-03
 * time: 0.00836801528930664
    14    -3.607823e+01     1.189272e-04
 * time: 0.00931692123413086
FittedPumasModel

Dynamical system type:               Nonlinear ODE
Solver(s): (OrdinaryDiffEqVerner.Vern7,OrdinaryDiffEqRosenbrock.Rodas5P)

Number of subjects:                              1

Observation records:         Active        Missing
    dv:                          61              0
    Total:                       61              0

Number of parameters:      Constant      Optimized
                                  0              6

Likelihood approximation:              NaivePooled
Likelihood optimizer:                         BFGS

Termination Reason:                   GradientNorm
Log-likelihood value:                    36.078234

----------------
     Estimate
----------------
θ₁    34.397
θ₂   103.17
θ₃     0.46566
θ₄   204.44
θ₅    26.234
σ      0.092273
----------------
fpm2 = fit(model, newpop, newparams, NaivePooled())
[ Info: Checking the initial parameter values.
[ Info: The initial negative log likelihood and its gradient are finite. Check passed.
Iter     Function value   Gradient norm 
     0     8.763976e+00     2.735808e+01
 * time: 1.0967254638671875e-5
     1     8.405325e+00     2.531358e+01
 * time: 0.0008299350738525391
     2     6.620382e+00     1.286061e+01
 * time: 0.0014579296112060547
     3     5.297438e+00     8.779519e+00
 * time: 0.0021169185638427734
     4     4.963913e+00     3.840318e+00
 * time: 0.0027959346771240234
     5     4.930293e+00     1.184668e+01
 * time: 0.0037479400634765625
     6     4.873975e+00     3.753008e+00
 * time: 0.004240989685058594
     7     4.858307e+00     2.308575e+00
 * time: 0.0048940181732177734
     8     4.854947e+00     8.434789e-02
 * time: 0.005347013473510742
     9     4.854713e+00     7.173484e-02
 * time: 0.005806922912597656
    10     4.853126e+00     8.197275e-01
 * time: 0.006263017654418945
    11     4.851996e+00     1.269989e+00
 * time: 0.0067369937896728516
    12     4.850709e+00     1.179594e+00
 * time: 0.007192134857177734
    13     4.849908e+00     1.616557e-01
 * time: 0.008126020431518555
    14     4.849724e+00     8.747458e-01
 * time: 0.7935140132904053
    15     4.849534e+00     1.703991e-01
 * time: 0.7942450046539307
    16     4.849431e+00     1.385412e-01
 * time: 0.7948391437530518
    17     4.849400e+00     1.192473e-01
 * time: 0.7954211235046387
    18     4.849395e+00     8.727144e-03
 * time: 0.7959380149841309
    19     4.849394e+00     2.408208e-02
 * time: 0.7964260578155518
    20     4.849394e+00     1.491005e-03
 * time: 0.7969040870666504
    21     4.849394e+00     1.658854e-04
 * time: 0.7973959445953369
FittedPumasModel

Dynamical system type:               Nonlinear ODE
Solver(s): (OrdinaryDiffEqVerner.Vern7,OrdinaryDiffEqRosenbrock.Rodas5P)

Number of subjects:                              1

Observation records:         Active        Missing
    dv:                          61              0
    Total:                       61              0

Number of parameters:      Constant      Optimized
                                  0              6

Likelihood approximation:              NaivePooled
Likelihood optimizer:                         BFGS

Termination Reason:                   GradientNorm
Log-likelihood value:                   -4.8493937

---------------
     Estimate
---------------
θ₁    33.85
θ₂   125.52
θ₃     0.50012
θ₄   192.8
θ₅    22.25
σ      0.18103
---------------

Now let’s display the estimates of θ side by side:

hcat(coef(fpm1).θ, coef(fpm2).θ)
5×2 Matrix{Float64}:
  34.3968     33.8499
 103.168     125.517
   0.465659    0.500121
 204.442     192.8
  26.2337     22.2497

Given that we have many observations per subject, this level of fluctuation due to a higher noise is a symptom of non-identifiability. Also note the big difference compared to the true data-generating parameter values!

params.θ
5-element Vector{Float64}:
  35.0
 100.0
   0.5
 210.0
  30.0
Summary

In this section, we have demonstrated beyond reasonable doubt that ML estimation workflows can be unreliable when fitting poorly identifiable models, potentially leading to erroneous conclusions in a study. So if we cannot rely on ML estimation for fitting poorly identifiable models, what can we use? The answer is Bayesian inference.

3.2 Bayesian Inference

Using Bayesian methods to sample from the posterior of the parameter estimates is a mathematically sound way to fit non-identifiable models because even non-identifiable models have a well-defined posterior distribution, when their parameters are assigned prior distributions. If multiple parameter values all fit the data well, then all such values will be plausible samples from the posterior distribution, assuming reasonable priors were used.

3.2.1 Model Definition

Let’s see how to minimally change our model above to make it Bayesian using a weakly informative priors “roughly in the ballpark”:

bayes_model = @model begin
    @param begin
        θ ~ MvLogNormal([log(50), log(150), log(1.0), log(100.0), log(10.0)], I(5))
        σ ~ Uniform(0.0, 1.0)
    end
    @pre begin
        CL = θ[1]
        Vc = θ[2]
        Ka = θ[3]
        Vp = θ[4]
        Q = θ[5]
    end
    @dynamics begin
        Depot' = -Ka * Depot
        Central' = Ka * Depot - (CL + Q) / Vc * Central + Q / Vp * Peripheral
        Peripheral' = Q / Vc * Central - Q / Vp * Peripheral
    end
    @derived begin
        cp := @. Central / Vc
        dv ~ @. Normal(cp, abs(cp) * σ + 1e-6)
    end
end
PumasModel
  Parameters: θ, σ
  Random effects:
  Covariates:
  Dynamical system variables: Depot, Central, Peripheral
  Dynamical system type: Nonlinear ODE
  Derived: dv
  Observed: dv

3.2.2 Sampling from the Posterior

Now to fit it, we need to pass an instance of BayesMCMC as the algorithm in fit. In this case, we used 4 chains for sampling with 3000 samples per chain out of which the first 1500 samples will be used to adapt the mass matrix and step size of the No-U-Turn sampler (NUTS) used in Pumas. All the chains are also parallelized using multi-threading.

# Setting the pseudo-random number generator's seed for reproducibility
Random.seed!(54321)
bayes_alg = BayesMCMC(; nsamples = 3_000, nadapts = 1_500)
bayes_fpm = fit(bayes_model, pop, params, bayes_alg)
[ Info: Checking the initial parameter values.
[ Info: The initial log probability and its gradient are finite. Check passed.
[ Info: Checking the initial parameter values.
[ Info: Checking the initial parameter values.
[ Info: Checking the initial parameter values.
[ Info: The initial log probability and its gradient are finite. Check passed.
[ Info: The initial log probability and its gradient are finite. Check passed.
[ Info: The initial log probability and its gradient are finite. Check passed.
Chains MCMC chain (3000×6×4 Array{Float64, 3}):

Iterations        = 1:1:3000
Number of chains  = 4
Samples per chain = 3000
Wall duration     = 110.53 seconds
Compute duration  = 416.07 seconds
parameters        = θ₁, θ₂, θ₃, θ₄, θ₅, σ

Summary Statistics
  parameters       mean       std      mcse    ess_bulk    ess_tail      rhat  ⋯
      Symbol    Float64   Float64   Float64     Float64     Float64   Float64  ⋯

          θ₁    34.2677    0.6464    0.0085   5815.1419   6390.7501    1.0010  ⋯
          θ₂   139.8970   34.6391    0.7496   2266.3463   4255.8765    1.0016  ⋯
          θ₃     0.6574    0.1851    0.0038   2320.3004   4460.0648    1.0016  ⋯
          θ₄   189.5964   18.5551    0.3653   2727.8152   4666.4209    1.0015  ⋯
          θ₅    23.1944    3.0474    0.0573   2876.5304   5456.6299    1.0010  ⋯
           σ     0.0985    0.0096    0.0001   5594.5428   5530.4651    1.0006  ⋯
                                                                1 column omitted

Quantiles
  parameters       2.5%      25.0%      50.0%      75.0%      97.5%
      Symbol    Float64    Float64    Float64    Float64    Float64

          θ₁    32.9894    33.8337    34.2722    34.7025    35.5045
          θ₂    72.0350   113.5729   143.8091   166.7516   197.8151
          θ₃     0.3513     0.5091     0.6543     0.7854     1.0357
          θ₄   158.2060   176.3866   187.5781   201.2976   229.5720
          θ₅    17.1992    20.9941    23.3691    25.4403    28.7541
           σ     0.0819     0.0918     0.0978     0.1044     0.1195

Now let’s discard the NUTS warmup samples as burn-in:

bayes_fpm_samples = discard(bayes_fpm; burnin = 1500)
Chains MCMC chain (1500×6×4 Array{Float64, 3}):

Iterations        = 1:1:1500
Number of chains  = 4
Samples per chain = 1500
Wall duration     = 110.53 seconds
Compute duration  = 416.07 seconds
parameters        = θ₁, θ₂, θ₃, θ₄, θ₅, σ

Summary Statistics
  parameters       mean       std      mcse    ess_bulk    ess_tail      rhat  ⋯
      Symbol    Float64   Float64   Float64     Float64     Float64   Float64  ⋯

          θ₁    34.2684    0.6520    0.0120   2981.6204   3371.5641    1.0013  ⋯
          θ₂   139.2850   34.8641    1.0486   1169.6000   2581.4860    1.0045  ⋯
          θ₃     0.6534    0.1851    0.0053   1230.9391   2610.3520    1.0039  ⋯
          θ₄   189.8497   18.5301    0.4905   1470.3191   2664.1951    1.0035  ⋯
          θ₅    23.2319    3.0401    0.0840   1313.1488   2543.8806    1.0032  ⋯
           σ     0.0987    0.0098    0.0002   2988.2563   2848.0184    1.0009  ⋯
                                                                1 column omitted

Quantiles
  parameters       2.5%      25.0%      50.0%      75.0%      97.5%
      Symbol    Float64    Float64    Float64    Float64    Float64

          θ₁    32.9947    33.8246    34.2679    34.7114    35.5278
          θ₂    72.2122   112.1741   143.7048   166.3786   197.2114
          θ₃     0.3514     0.5026     0.6509     0.7802     1.0268
          θ₄   157.8813   176.6777   187.7904   201.8730   228.5581
          θ₅    17.3330    21.0503    23.3992    25.4549    28.8343
           σ     0.0820     0.0918     0.0978     0.1047     0.1202

Notice how Bayesian inference was able to quantify the uncertainty in the non-identifiable parameters (mostly θ₂ which is Vc and θ₄ which is Vp) reflected in the large standard deviation of the marginal posterior of some parameters, std, relative to its mean value, mean. This is consistent with the eigenvector d we used earlier to prove that the model is poorly identifiable which also showed the poor identifiability was mostly prevalent in these 2 parameters.

d
6-element Vector{Float64}:
  0.006717009025688778
  0.8382731175267348
  0.0037560578471354886
 -0.5451738773361731
  0.004939403972915483
 -3.13735234359295e-6

3.2.3 Convergence Diagnostics

By default, we print summary statistics and a few convergence diagnostics: effective samples size (ess_bulk) and \(\hat{R}\) (rhat). In this case, the diagnostics look reasonable. The rhat is close to 1 and the minimum ess_bulk is around 1000.

Next we show the trace plot of all the parameters

using PumasPlots

trace_plot(bayes_fpm_samples)

It can be seen that the chains are mostly well mixed. Occasional jumps seem to happen which may indicate the presence of another mode in the posterior with a relatively small probability mass.

Now let’s look at the auto-correlation plot:

autocor_plot(bayes_fpm_samples)

Some auto-correlation seems to persist in some chains so let’s try some thinning, by keeping only one out of every 5 samples.

thin_bayes_fpm_samples = discard(bayes_fpm; burnin = 1500, ratio = 0.2)

autocor_plot(thin_bayes_fpm_samples)

Looks better!

To Thin Or Not To Thin

In general, thinning is not recommended unless there are extremely high levels of auto-correlation in the samples. This is because the thinned samples will always have less information than the full set of samples before thinning. However, we perform thinning in this tutorial for demonstration purposes.

3.2.4 Posterior Predictive Check

Now let’s do a posterior predictive check by first simulating 1000 scenarios from the posterior distribution of the response including residual noise.

obstimes = 0.0:0.5:30.0
sims = simobs(bayes_fpm_samples; samples = 1000, simulate_error = true, obstimes)
[ Info: Simulating 1000 sample(s) from the posterior predictive distribution of each subject.
Simulated population (Vector{<:Subject})
  Simulated subjects: 1000
  Simulated variables: dv

then we can do a visual predictive check (VPC) plot using the simulations

vpc_res = vpc(sims; observations = [:dv], ensemblealg = EnsembleThreads())

vpc_plt = vpc_plot(
    vpc_res;
    simquantile_medians = true,
    observations = true,
    axis = (xlabel = "Time (h)", ylabel = "Concentration", xticks = 0:2:30),
)
[ Info: Detected 1000 scenarios and 1 subjects in the input simulations. Running VPC.
[ Info: Continuous VPC

Summary

With very few changes in the model and a few lines of code, we were able to obtain samples from the full posterior of the parameters of our poorly identifiable model.

4 Uncertainty Propagation, Queries and Decision Making

Just because a model is non-identifiable does not mean that the model is useless or less correct. In fact, more correct models that incorporate more biological processes tend to be non-identifiable because we can only observe/measure very few variables in the model, while simplified models are more likely to be identifiable. Given samples from the posterior of a non-identifiable model, one can do the following:

  • Propagate the uncertainty forward to the predictions to get samples from the posterior predictive distribution, instead of relying on a single prediction using the ML estimates.
Value of Uncertainty Quantification

Parameter uncertainty due to structural non-identifiability will by definition have no effect on the model’s predictions when predicting the observed response. However, uncertainty due to practical non-identifiability, or otherwise insufficient data, can have an impact on the model’s predictions. In this case, basing decisions on the full posterior predictive distribution instead of a single prediction from the ML estimates will make the decisions more robust to parameter uncertainty due to insufficient observations and model misspecification.

  • Ask probabilistic questions given your data. For example, what’s the probability that the drug effect is \(> 0\)? Or what’s the probability that the new drug A is better than the control drug B after only 3 months of data? Or what’s the probability of satisfying a therapeutic criteria for efficacy and safety given the current dose?
  • What-if analysis (aka counter-factual simulation) and dose optimization. For example, you can make predictions assuming the subject is a pediatric using the model parameters’ posterior inferred from an adult’s data. Or you can test different dose levels to select the best dose according to some therapeutic criteria. This can also be done in the non-Bayesian setting.

4.1 Probabilistic Questions

In this section, we show how to

  1. Estimate the probability that a parameter is more than a specific value, and
  2. Estimate the probability that the subject satisfies a desired therapeutic criteria. From there, one can simulate multiple doses and choose the dose that maximizes this probability.

To estimate the probability that CL > 35, we can run:

mean(bayes_fpm_samples) do p
    p.θ[1] > 35
end
0.12833333333333333

To estimate the probability that a subject satisfies a desired therapeutic criteria, we first simulate from the posterior predictive distribution (without residual error):

ipreds = simobs(bayes_fpm_samples; samples = 1000, simulate_error = false, obstimes)
[ Info: Simulating 1000 sample(s) from the posterior predictive distribution of each subject.
Simulated population (Vector{<:Subject})
  Simulated subjects: 1000
  Simulated variables: dv

Next, we can estimate the area-under-curve (auc) and maximum drug concentration (cmax) given the different posterior samples.

using NCA

nca_params = postprocess(ipreds) do gen, obs
    pk_auc = NCA.auc(gen.dv, obstimes)
    pk_cmax = NCA.cmax(gen.dv, obstimes)
    (; pk_auc, pk_cmax)
end
1000-element Vector{@NamedTuple{pk_auc::Float64, pk_cmax::Float64}}:
 (pk_auc = 87.29642947563113, pk_cmax = 9.690567927847662)
 (pk_auc = 85.94407279171637, pk_cmax = 9.354986951092625)
 (pk_auc = 86.91982021900203, pk_cmax = 9.719992022903899)
 (pk_auc = 85.17704962603005, pk_cmax = 9.239326433040972)
 (pk_auc = 88.16832553090032, pk_cmax = 10.052607602171387)
 (pk_auc = 88.49760023693337, pk_cmax = 9.656950564056446)
 (pk_auc = 84.55179877782469, pk_cmax = 9.354271697656262)
 (pk_auc = 87.56627722395369, pk_cmax = 9.760301462506515)
 (pk_auc = 86.14097507404395, pk_cmax = 9.400028800966414)
 (pk_auc = 88.71603712587172, pk_cmax = 10.125632129614567)
 ⋮
 (pk_auc = 89.18817332752273, pk_cmax = 9.698452586988054)
 (pk_auc = 87.86007258063809, pk_cmax = 9.989844574487536)
 (pk_auc = 85.87498778635563, pk_cmax = 9.410039527603717)
 (pk_auc = 85.46821681201037, pk_cmax = 9.682133424754609)
 (pk_auc = 89.74888558334365, pk_cmax = 9.775133507225247)
 (pk_auc = 87.0169707201292, pk_cmax = 9.637937190363404)
 (pk_auc = 88.15521600707697, pk_cmax = 9.684946583149811)
 (pk_auc = 85.27107046780036, pk_cmax = 9.330575866960968)
 (pk_auc = 84.57659060779415, pk_cmax = 9.237495986771233)

Finally, we can estimate the probability of satisfying a therapeutic criteria.

prob = mean(nca_params) do p
    p.pk_auc > 90 && p.pk_cmax < 15.0
end
0.036

To compute the probability of efficacy and safety separately, one can instead run:

prob1 = mean(nca_params) do p
    p.pk_auc > 90
end
prob2 = mean(nca_params) do p
    p.pk_cmax < 15.0
end
prob1, prob2
(0.036, 1.0)

4.2 Counter-factual Analysis and Dose Optimization

After developing a model, one may be interested in simulating scenarios, e.g. different covariates or doses, that have not been observed in the data while reusing the same posterior distribution of the parameters learnt from the data. This can be used to select a new dose that maximizes the probabilities of efficacy and safety simultaneously given the previously observed data.

In Pumas, you can do this by defining a new subject that includes the new covariates or dose and then passing that to simobs. First, let’s define a new skeleton subject that represents our counter-factual scenario where a dose of 3200 was administered instead of the 3000 used in the observed case:

cf_skeleton = Subject(
    id = 1,
    time = 0.0:0.5:30.0,
    events = DosageRegimen(3200, time = 0.0, cmt = 1),
    observations = (; dv = nothing),
)
Subject
  ID: 1
  Events: 1
  Observations: dv: (n=61)

To simulate from the posterior predictive distribution of this new subject using the posterior of the parameters, you can run:

cf_ipreds = simobs(
    thin_bayes_fpm_samples,
    cf_skeleton;
    samples = 1000,
    simulate_error = false,
    obstimes,
    subject = 1,
)
[ Info: [Subject: 1] Simulating 1000 sample(s) from the posterior predictive distribution of subject 1 using the dose and covariates in the input subject.
Simulated population (Vector{<:Subject})
  Simulated subjects: 1000
  Simulated variables: dv

We can then re-evaluate the probability of satisfying a therapeutic criteria:

cf_nca_params = postprocess(cf_ipreds) do gen, obs
    pk_auc = NCA.auc(gen.dv, obstimes)
    pk_cmax = NCA.cmax(gen.dv, obstimes)
    (; pk_auc, pk_cmax)
end
cf_prob = mean(cf_nca_params) do p
    p.pk_auc > 90 && p.pk_cmax < 15.0
end
0.946

We can see that the probability increased. To understand why, let’s look at the probabilities of the auc and cmax criteria separately:

cf_prob1 = mean(cf_nca_params) do p
    p.pk_auc > 90
end
cf_prob2 = mean(cf_nca_params) do p
    p.pk_cmax < 15.0
end
cf_prob1, cf_prob2
(0.946, 1.0)

Contrast this to the old dose’s probabilities:

prob1, prob2
(0.036, 1.0)

Note that this example was not particularly interesting because of the dense sampling which despite of it, the uncertainty in the parameters was still high. This implies that the uncertainty was largely due to structural identifiability issues in the model. Since uncertainty in parameters due to structural non-identifiability does not affect the model predictions, the posterior predictive distribution was much more concentrated than the parameters’ posterior.

To estimate the mean and standard deviation of the predictions at each point in time we can run:

μs = mean(ipreds) do gen, obs
    gen.dv
end
σs = std(ipreds) do gen, obs
    gen.dv
end
61-element Vector{Float64}:
 0.0
 0.3314843845192407
 0.3992120624442027
 0.3749665505219793
 0.3340735921663106
 0.3005013898253989
 0.2749376872454878
 0.2525509481701991
 0.23035326221132532
 0.2078373259694056
 ⋮
 0.015133936062242679
 0.01543423794080337
 0.015775986410417983
 0.016146363110257043
 0.01653425665177691
 0.016930274972207806
 0.017326643500542842
 0.01771704343425608
 0.01809642742401062

To get the average relative standard deviations (ignoring the first prediction which is 0), we run:

mean(σs[2:end] ./ μs[2:end])
0.026043004101569005

So the predictions are not very sensitive to the parameter uncertainty.

5 Summary

In this tutorial, we have seen how to test for model non-identifiability using the Fisher information matrix and sensitivity analysis. We have shown that maximum likelihood estimation is unreliable when fitting poorly identifiable models. And we have seen how one can use Bayesian inference to: 1) fit non-identifiable or poorly identifiable models to data, 2) ask probabilistic questions of the model, and 3) simulate counter-factual scenarios.

6 References

  1. Thomas J. Rothenberg. Identification in parametric models. Econometrica, 1971.
  2. F. Mentre, A Mallet, and D. Baccar. Optimal design in random-effects regression models. Biometrika, 1997.
  3. S. Retout and F Mentre. Further development of the fisher information matrix in nonlinear mixed-effects models with evaluation in population pharmacokinetics. Journal of biopharmaceutical statistics, 2003.
  4. V. Shivva, K. Korell, I. Tucker, and S. Duffull. An approach for identifiability of population pharmacokinetic-pharmacodynamic models. CPT Pharmacometrics & Systems Pharmacology, 2013.
  5. Stephen Dufful, A workflow for resolving model internal consistency in use-reuse settings (aka repairing unstable models). PAGANZ, 2024.
  6. Dan Wright. The identifiability of a turnover model for allopurinol urate-lowering effect. PAGANZ, 2024.