using Pumas
Fitting Non-Identifiable and Poorly Identifiable Models using Bayesian Inference
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:
- 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.
- 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. - 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. |
- Local (or global) practical identifiablity is what we usually want in analyses.
- Practical identifiability (estimability) implies structural 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:
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 ~ @. CombinedNormal(cp, 1e-6, σ)
end
endPumasModel
Parameters: θ, σ
Random effects:
Covariates:
Dynamical system variables: Depot, Central, Peripheral
Dynamical system type: Matrix exponential
Derived: dv
Observed: dv
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 = fill(missing, 61)),
)Subject
ID: 1
Events: 1
Observations: dv: (n=0)
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.2949 -0.0538767 13.6935 0.0254882 -0.218697 -2.68028
-0.0538767 0.0188821 -4.38016 -0.00168545 0.0296865 -0.325336
13.6935 -4.38016 1054.71 0.635264 -7.13312 66.7482
0.0254882 -0.00168545 0.635264 0.00215197 -0.00487914 -0.0895271
-0.218697 0.0296865 -7.13312 -0.00487914 0.144605 -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.646901451998056e-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.
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
- Assume parameter values \(\theta_0\),
- Define a criteria for changing the parameters \(\theta\) from their current values \(\theta_0\), and then create a candidate set of parameters \(\Theta_c\),
- Simulate synthetic data using the parameters \(\theta_0\),
- Evaluate the log likelihood \(L(\theta)\) for all \(\theta \in \Theta_c\),
- 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.82509838337168
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.006716973993299584
0.83827361662032
0.003756059324605163
-0.5451731110412071
0.004939326352942361
-3.137362825983634e-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.99999328302601, 99.99916172638338, 0.4999962439406754, 210.00054517311105, 29.999995060673648], σ = 0.1)
(θ = [34.999986566052016, 99.99832345276675, 0.4999924878813508, 210.00109034622207, 29.999990121347295], σ = 0.1)
(θ = [34.999979849078024, 99.99748517915013, 0.4999887318220262, 210.00163551933312, 29.999985182020943], σ = 0.1)
(θ = [34.999973132104024, 99.99664690553352, 0.49998497576270157, 210.00218069244417, 29.999980242694587], σ = 0.1)
(θ = [34.99996641513003, 99.9958086319169, 0.499981219703377, 210.0027258655552, 29.999975303368235], σ = 0.1)
(θ = [34.99995969815604, 99.99497035830028, 0.4999774636440524, 210.00327103866624, 29.999970364041882], σ = 0.1)
(θ = [34.99995298118205, 99.99413208468366, 0.49997370758472776, 210.0038162117773, 29.99996542471553], σ = 0.1)
(θ = [34.999946264208056, 99.99329381106703, 0.49996995152540313, 210.00436138488834, 29.999960485389177], σ = 0.1)
(θ = [34.999939547234064, 99.99245553745041, 0.49996619546607857, 210.00490655799936, 29.999955546062825], σ = 0.1)
(θ = [34.999932830260065, 99.9916172638338, 0.49996243940675394, 210.0054517311104, 29.99995060673647], σ = 0.1)
(θ = [35.00000671697399, 100.00083827361662, 0.5000037560593246, 209.99945482688895, 30.000004939326352], σ = 0.1)
(θ = [35.000013433947984, 100.00167654723325, 0.5000075121186492, 209.99890965377793, 30.000009878652705], σ = 0.1)
(θ = [35.000020150921976, 100.00251482084987, 0.5000112681779738, 209.99836448066688, 30.000014817979057], σ = 0.1)
(θ = [35.000026867895976, 100.00335309446648, 0.5000150242372984, 209.99781930755583, 30.000019757305413], σ = 0.1)
(θ = [35.00003358486997, 100.0041913680831, 0.500018780296623, 209.9972741344448, 30.000024696631765], σ = 0.1)
(θ = [35.00004030184396, 100.00502964169972, 0.5000225363559476, 209.99672896133376, 30.000029635958118], σ = 0.1)
(θ = [35.00004701881795, 100.00586791531634, 0.5000262924152722, 209.9961837882227, 30.00003457528447], σ = 0.1)
(θ = [35.000053735791944, 100.00670618893297, 0.5000300484745969, 209.99563861511166, 30.000039514610823], σ = 0.1)
(θ = [35.000060452765936, 100.00754446254959, 0.5000338045339214, 209.99509344200064, 30.000044453937175], σ = 0.1)
(θ = [35.000067169739935, 100.0083827361662, 0.500037560593246, 209.9945482688896, 30.00004939326353], σ = 0.1)
Now let’s evaluate the log likelihoods of all these parameter sets.
lls = map(newparams) do p
loglikelihood(model, pop, p, NaivePooled())
end20-element Vector{Float64}:
32.825119311648166
32.82514024037694
32.825161169095495
32.82518209882179
32.82520302921025
32.82522395943841
32.82524488996207
32.825265821411534
32.82528675346804
32.82530768588313
32.82507745580337
32.82505652827541
32.82503560233059
32.82501467557626
32.824993750087216
32.82497282459404
32.82495189997024
32.82493097587828
32.82491005203674
32.824889127763036
To compute the average sensitivity within \(\Theta_c\), we then call:
sens = abs2.((lls .- ll0) ./ αs)
mean(sens)0.0004379767047476752
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.2254070926463
Notice the difference in sensitivity compared to a random direction.
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:
- Mask a truly singular matrix by reporting its smallest eigenvalue as very close to 0 but not exactly 0 in floating point numbers, or
- 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,
- Asymptotic estimates of standard errors require the model to be locally identifiable,
- 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.
- 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.282510e+01 5.896826e+01 * time: 0.038893938064575195 1 -3.299588e+01 8.371810e+01 * time: 1.9175019264221191 2 -3.440914e+01 3.937519e+01 * time: 1.918968915939331 3 -3.550332e+01 3.429526e+01 * time: 1.920314073562622 4 -3.585849e+01 2.078271e+01 * time: 1.921665906906128 5 -3.605850e+01 4.208337e+00 * time: 1.9230120182037354 6 -3.606916e+01 5.500441e+00 * time: 1.9241509437561035 7 -3.607868e+01 5.143784e-01 * time: 1.925347089767456 8 -3.607872e+01 1.670003e-01 * time: 1.9265339374542236 9 -3.607872e+01 6.579100e-03 * time: 1.9277150630950928 10 -3.607872e+01 3.924734e-03 * time: 1.9288980960845947 11 -3.607872e+01 5.349622e-02 * time: 1.9300780296325684 12 -3.607872e+01 2.860912e-02 * time: 1.9312560558319092 13 -3.607872e+01 3.132441e-03 * time: 1.9324278831481934 14 -3.607872e+01 1.172498e-04 * time: 1.9336109161376953
FittedPumasModel
Dynamical system type: Matrix exponential
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.078723
----------------
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.245141e+02 6.802189e+02 * time: 1.811981201171875e-5 1 1.499851e+02 4.520553e+01 * time: 0.0012869834899902344 2 1.436202e+02 4.485778e+01 * time: 0.002521038055419922 3 1.108788e+02 4.698772e+01 * time: 0.00374603271484375 4 9.146761e+01 4.889582e+01 * time: 0.004968166351318359 5 8.587686e+01 4.879770e+01 * time: 0.006425142288208008 6 8.353867e+01 5.068823e+01 * time: 0.007910966873168945 7 8.061254e+01 4.923006e+01 * time: 0.009319067001342773 8 7.723505e+01 3.939533e+01 * time: 0.010740995407104492 9 7.347452e+01 6.732764e+01 * time: 0.011922121047973633 10 6.467186e+01 2.181862e+01 * time: 0.013100147247314453 11 5.389651e+01 4.261890e+01 * time: 0.014493942260742188 12 4.899496e+01 4.747087e+01 * time: 0.015900135040283203 13 4.635923e+01 4.385385e+01 * time: 0.017078161239624023 14 4.310628e+01 3.665783e+01 * time: 0.018264055252075195 15 3.451139e+01 4.222524e+01 * time: 0.019642114639282227 16 2.783156e+01 4.184498e+01 * time: 0.020993947982788086 17 2.167222e+01 2.490925e+01 * time: 0.0223691463470459 18 2.101609e+01 3.068432e+01 * time: 0.023528099060058594 19 2.012645e+01 9.150249e+00 * time: 0.024685144424438477 20 1.996284e+01 1.013947e+01 * time: 0.0258331298828125 21 1.919860e+01 1.426535e+01 * time: 0.02704906463623047 22 1.834470e+01 1.663386e+01 * time: 0.028237104415893555 23 1.770899e+01 8.638293e+00 * time: 0.029415130615234375 24 1.736337e+01 4.685621e+00 * time: 0.03061699867248535 25 1.698776e+01 5.459416e+00 * time: 0.03183102607727051 26 1.419162e+01 3.888220e+01 * time: 0.03307008743286133 27 1.413849e+01 1.322649e+01 * time: 0.03436708450317383 28 1.396486e+01 1.976848e+01 * time: 0.03567099571228027 29 1.381925e+01 5.251882e+00 * time: 0.03696799278259277 30 1.374284e+01 5.054361e+00 * time: 0.03826093673706055 31 1.287063e+01 1.257893e+01 * time: 0.03955197334289551 32 1.095164e+01 3.766952e+01 * time: 0.04084300994873047 33 9.527141e+00 5.917221e+01 * time: 0.042511940002441406 34 7.935017e+00 7.374433e+01 * time: 0.044175148010253906 35 5.133756e+00 8.073114e+01 * time: 0.04587101936340332 36 3.574430e+00 2.399332e+02 * time: 0.04732513427734375 37 -2.818015e+00 4.056217e+01 * time: 0.04904603958129883 38 -6.716130e+00 2.245883e+01 * time: 0.050768136978149414 39 -9.917655e+00 3.322705e+01 * time: 0.052204132080078125 40 -1.031668e+01 7.966725e+00 * time: 0.0536651611328125 41 -1.066621e+01 1.738575e+01 * time: 0.05510902404785156 42 -1.070012e+01 9.326113e+00 * time: 0.05656695365905762 43 -1.072844e+01 5.932161e+00 * time: 0.057997941970825195 44 -1.077821e+01 2.800923e+00 * time: 0.05944705009460449 45 -1.087937e+01 2.012460e+01 * time: 0.06089496612548828 46 -1.095502e+01 1.487566e+01 * time: 0.06234598159790039 47 -1.101592e+01 3.674092e+00 * time: 0.06380009651184082 48 -1.101981e+01 6.674368e-01 * time: 0.06549596786499023 49 -1.102041e+01 3.236929e-01 * time: 0.06694912910461426 50 -1.102050e+01 8.886111e-03 * time: 0.06831693649291992 51 -1.102050e+01 1.270485e-03 * time: 0.06968808174133301 52 -1.102050e+01 7.846672e-05 * time: 0.07106900215148926
FittedPumasModel
Dynamical system type: Matrix exponential
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.020497
---------------
Estimate
---------------
θ₁ 30.967
θ₂ 214.3
θ₃ 52.714
θ₄ 169.46
θ₅ 12.074
σ 0.13904
---------------
Now let’s display the estimates of θ side by side:
hcat(coef(fpm1).θ, coef(fpm2).θ)5×2 Matrix{Float64}:
34.3968 30.9673
103.168 214.304
0.46566 52.7137
204.442 169.462
26.2337 12.0741
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.282510e+01 5.896826e+01 * time: 1.2159347534179688e-5 1 -3.299588e+01 8.371810e+01 * time: 0.001608133316040039 2 -3.440914e+01 3.937519e+01 * time: 0.002936124801635742 3 -3.550332e+01 3.429526e+01 * time: 0.004263162612915039 4 -3.585849e+01 2.078271e+01 * time: 0.005660057067871094 5 -3.605850e+01 4.208337e+00 * time: 0.006967067718505859 6 -3.606916e+01 5.500441e+00 * time: 0.008147001266479492 7 -3.607868e+01 5.143784e-01 * time: 0.009268045425415039 8 -3.607872e+01 1.670003e-01 * time: 0.010430097579956055 9 -3.607872e+01 6.579100e-03 * time: 0.011542081832885742 10 -3.607872e+01 3.924734e-03 * time: 0.012645959854125977 11 -3.607872e+01 5.349622e-02 * time: 0.013813018798828125 12 -3.607872e+01 2.860912e-02 * time: 0.014948129653930664 13 -3.607872e+01 3.132441e-03 * time: 0.016108036041259766 14 -3.607872e+01 1.172498e-04 * time: 0.017258167266845703
FittedPumasModel
Dynamical system type: Matrix exponential
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.078723
----------------
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.763732e+00 2.735810e+01 * time: 1.811981201171875e-5 1 8.405084e+00 2.531373e+01 * time: 0.0015919208526611328 2 6.620140e+00 1.286067e+01 * time: 0.002911090850830078 3 5.297204e+00 8.779621e+00 * time: 0.004243135452270508 4 4.963671e+00 3.840425e+00 * time: 0.0055561065673828125 5 4.930049e+00 1.184693e+01 * time: 0.0066509246826171875 6 4.873733e+00 3.753111e+00 * time: 0.007754087448120117 7 4.858063e+00 2.308745e+00 * time: 0.009083986282348633 8 4.854703e+00 8.434993e-02 * time: 0.010165929794311523 9 4.854469e+00 7.173890e-02 * time: 0.011255025863647461 10 4.852883e+00 8.196445e-01 * time: 0.012346982955932617 11 4.851752e+00 1.270016e+00 * time: 0.01347494125366211 12 4.850465e+00 1.179807e+00 * time: 0.01462411880493164 13 4.849664e+00 1.617992e-01 * time: 0.015764951705932617 14 4.849480e+00 8.746251e-01 * time: 0.016887903213500977 15 4.849289e+00 1.703837e-01 * time: 0.01800990104675293 16 4.849187e+00 1.387087e-01 * time: 0.01918506622314453 17 4.849156e+00 1.190609e-01 * time: 0.020364046096801758 18 4.849150e+00 8.635074e-03 * time: 0.021533966064453125 19 4.849150e+00 2.415756e-02 * time: 0.02270197868347168 20 4.849149e+00 1.477038e-03 * time: 0.023869991302490234 21 4.849149e+00 1.662404e-04 * time: 0.0250399112701416
FittedPumasModel
Dynamical system type: Matrix exponential
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.8491495
---------------
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.46566 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
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 ~ @. CombinedNormal(cp, 1e-6, σ)
end
endPumasModel
Parameters: θ, σ
Random effects:
Covariates:
Dynamical system variables: Depot, Central, Peripheral
Dynamical system type: Matrix exponential
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: The initial log probability and its gradient are finite. Check passed. [ 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: 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 = 120.86 seconds
Compute duration = 479.76 seconds
parameters = θ₁, θ₂, θ₃, θ₄, θ₅, σ
Use `describe(chains)` for summary statistics and quantiles.
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 = 120.86 seconds
Compute duration = 479.76 seconds
parameters = θ₁, θ₂, θ₃, θ₄, θ₅, σ
Use `describe(chains)` for summary statistics and quantiles.
describe(bayes_fpm_samples)Chains MCMC chain (1500×6×4 Array{Float64, 3}):
Iterations = 1:1:1500
Number of chains = 4
Samples per chain = 1500
Wall duration = 120.86 seconds
Compute duration = 479.76 seconds
parameters = θ₁, θ₂, θ₃, θ₄, θ₅, σ
Summary Statistics
parameters mean std mcse ess_bulk ess_tail rhat ⋯
Symbol Float64 Float64 Float64 Float64 Float64 Float64 ⋯
θ₁ 34.2785 0.6365 0.0120 2821.1049 3227.7544 1.0014 ⋯
θ₂ 139.2919 35.1936 0.9858 1313.6815 2469.3308 1.0034 ⋯
θ₃ 0.6526 0.1854 0.0051 1307.2565 2318.8084 1.0037 ⋯
θ₄ 190.0433 19.0509 0.4736 1694.1802 2442.3016 1.0026 ⋯
θ₅ 23.2387 2.9452 0.0760 1533.3950 2222.5031 1.0034 ⋯
σ 0.0981 0.0096 0.0002 2462.6168 3291.5674 1.0019 ⋯
1 column omitted
Quantiles
parameters 2.5% 25.0% 50.0% 75.0% 97.5%
Symbol Float64 Float64 Float64 Float64 Float64
θ₁ 33.0141 33.8678 34.2764 34.6970 35.5219
θ₂ 69.8680 113.3728 143.1553 166.0829 199.3460
θ₃ 0.3442 0.5097 0.6479 0.7826 1.0348
θ₄ 158.4276 176.7684 187.7474 201.3510 232.0417
θ₅ 17.4839 21.1475 23.3923 25.3957 28.5251
σ 0.0813 0.0915 0.0973 0.1042 0.1187
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.
d6-element Vector{Float64}:
0.006716973993299584
0.83827361662032
0.003756059324605163
-0.5451731110412071
0.004939326352942361
-3.137362825983634e-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!
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_model,
pop,
sample(bayes_fpm_samples, 1000)...;
simulate_error = true,
obstimes,
)1000-element Vector{Vector{Pumas.SimulatedObservations{PumasModel{(θ = 5, σ = 1), 0, (:Depot, :Central, :Peripheral), (Symbol("##A##"), Symbol("##b##")), ParamSet{@NamedTuple{θ::MvLogNormal{Float64, PDMats.PDiagMat{Float64, Vector{Float64}}, Vector{Float64}}, σ::Uniform{Float64}}}, ParamSet{@NamedTuple{}}, Pumas.PreObj{var"#13#17"}, Pumas.DCPObj{Returns{Returns{@NamedTuple{}}}}, var"#14#18", Pumas.LinearODE, Pumas.DerivedObj{(:dv,), false, var"#15#19"}, var"#16#20", ModelingToolkit.ODESystem, Pumas.PumasModelOptions}, Subject{@NamedTuple{dv::Vector{Float64}}, Pumas.ConstantCovar{@NamedTuple{}}, DosageRegimen{Float64, Symbol, Float64, Float64, Float64, Float64}, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}}, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, @NamedTuple{θ::Vector{Float64}, σ::Float64}, @NamedTuple{}, @NamedTuple{}, @NamedTuple{saveat::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, ss_abstol::Float64, ss_reltol::Float64, ss_maxiters::Int64, abstol::Float64, reltol::Float64, alg::CompositeAlgorithm{0, Tuple{Vern7{typeof(OrdinaryDiffEqCore.trivial_limiter!), typeof(OrdinaryDiffEqCore.trivial_limiter!), Static.False}, Rodas5P{1, ADTypes.AutoForwardDiff{1, Nothing}, LinearSolve.GenericLUFactorization{RowMaximum}, typeof(OrdinaryDiffEqCore.DEFAULT_PRECS), Val{:forward}(), true, nothing, typeof(OrdinaryDiffEqCore.trivial_limiter!), typeof(OrdinaryDiffEqCore.trivial_limiter!)}}, OrdinaryDiffEqCore.AutoSwitch{Vern7{typeof(OrdinaryDiffEqCore.trivial_limiter!), typeof(OrdinaryDiffEqCore.trivial_limiter!), Static.False}, Rodas5P{1, ADTypes.AutoForwardDiff{1, Nothing}, LinearSolve.GenericLUFactorization{RowMaximum}, typeof(OrdinaryDiffEqCore.DEFAULT_PRECS), Val{:forward}(), true, nothing, typeof(OrdinaryDiffEqCore.trivial_limiter!), typeof(OrdinaryDiffEqCore.trivial_limiter!)}, Rational{Int64}, Int64}}, continuity::Symbol}, Pumas.PKPDAnalyticalSolution{StaticArraysCore.SVector{3, Float64}, 2, Vector{StaticArraysCore.SVector{3, Float64}}, Vector{Float64}, Vector{StaticArraysCore.SVector{3, Float64}}, Vector{StaticArraysCore.SVector{3, Float64}}, Returns{@NamedTuple{##A##::StaticArraysCore.SMatrix{3, 3, Float64, 9}, ##b##::StaticArraysCore.SVector{3, Int64}}}, Pumas.AnalyticalPKPDProblem{StaticArraysCore.SVector{3, Float64}, Float64, false, Pumas.LinearODE, Vector{Pumas.Event{Float64, Float64, Float64}}, Vector{Float64}, Returns{@NamedTuple{##A##::StaticArraysCore.SMatrix{3, 3, Float64, 9}, ##b##::StaticArraysCore.SVector{3, Int64}}}}}, @NamedTuple{}, @NamedTuple{CL::Vector{Float64}, Vc::Vector{Float64}, Ka::Vector{Float64}, Vp::Vector{Float64}, Q::Vector{Float64}, ##A##::Vector{StaticArraysCore.SMatrix{3, 3, Float64, 9}}, ##b##::Vector{StaticArraysCore.SVector{3, Int64}}}, @NamedTuple{dv::Vector{Float64}}, @NamedTuple{}}}}:
Simulated population (Vector{<:Subject}), n = 1, variables: dv
Simulated population (Vector{<:Subject}), n = 1, variables: dv
Simulated population (Vector{<:Subject}), n = 1, variables: dv
Simulated population (Vector{<:Subject}), n = 1, variables: dv
Simulated population (Vector{<:Subject}), n = 1, variables: dv
Simulated population (Vector{<:Subject}), n = 1, variables: dv
Simulated population (Vector{<:Subject}), n = 1, variables: dv
Simulated population (Vector{<:Subject}), n = 1, variables: dv
Simulated population (Vector{<:Subject}), n = 1, variables: dv
Simulated population (Vector{<:Subject}), n = 1, variables: dv
⋮
Simulated population (Vector{<:Subject}), n = 1, variables: dv
Simulated population (Vector{<:Subject}), n = 1, variables: dv
Simulated population (Vector{<:Subject}), n = 1, variables: dv
Simulated population (Vector{<:Subject}), n = 1, variables: dv
Simulated population (Vector{<:Subject}), n = 1, variables: dv
Simulated population (Vector{<:Subject}), n = 1, variables: dv
Simulated population (Vector{<:Subject}), n = 1, variables: dv
Simulated population (Vector{<:Subject}), n = 1, variables: dv
Simulated population (Vector{<:Subject}), n = 1, 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
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.
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
Ais better than the control drugBafter 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
- Estimate the probability that a parameter is more than a specific value, and
- 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
end0.13066666666666665
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_model,
pop,
sample(bayes_fpm_samples, 1000)...;
simulate_error = false,
obstimes,
)
ipreds = reduce(vcat, _ipreds)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)
end1000-element Vector{@NamedTuple{pk_auc::Float64, pk_cmax::Float64}}:
(pk_auc = 90.49929024783654, pk_cmax = 9.358825147938813)
(pk_auc = 85.07032863667726, pk_cmax = 9.17567597445371)
(pk_auc = 88.61803768069302, pk_cmax = 9.88660192878848)
(pk_auc = 88.28634618910372, pk_cmax = 9.537028744569755)
(pk_auc = 86.82348467947651, pk_cmax = 9.697777718298678)
(pk_auc = 88.87421819015402, pk_cmax = 9.821916869846795)
(pk_auc = 87.26992175477243, pk_cmax = 9.953140599882229)
(pk_auc = 89.12092554649794, pk_cmax = 9.644988346242918)
(pk_auc = 88.12247512993696, pk_cmax = 10.00186315347803)
(pk_auc = 88.40749910898445, pk_cmax = 9.863839578636805)
⋮
(pk_auc = 86.73913151513791, pk_cmax = 9.848745733854127)
(pk_auc = 86.06563368230053, pk_cmax = 9.59417893227365)
(pk_auc = 88.18030659631351, pk_cmax = 9.339606064372417)
(pk_auc = 88.36818771306497, pk_cmax = 9.940989213377529)
(pk_auc = 85.0360103770412, pk_cmax = 9.29557127194992)
(pk_auc = 86.419359846367, pk_cmax = 9.654293923060882)
(pk_auc = 89.57775955407766, pk_cmax = 10.143096202718125)
(pk_auc = 90.68658262036456, pk_cmax = 9.623644504496998)
(pk_auc = 86.22484357881964, pk_cmax = 9.89218587359731)
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
end0.028
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.028, 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(pop[1]; events = DosageRegimen(3200; time = 0.0, cmt = 1))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(
bayes_model,
cf_skeleton,
sample(thin_bayes_fpm_samples, 1000; subject = 1)...;
simulate_error = false,
obstimes,
)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
end0.96
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.96, 1.0)
Contrast this to the old dose’s probabilities:
prob1, prob2(0.028, 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.(postprocess((gen, _) -> gen.dv, ipreds))
σs = std.(postprocess((gen, _) -> gen.dv, ipreds))61-element Vector{Float64}:
0.0
0.3306286643224467
0.39380220094229706
0.3666959934856391
0.325466473893882
0.29300741053606155
0.2686823944841756
0.24703681870940603
0.22507881364143195
0.20251398735262485
⋮
0.014712994032095352
0.015060699684525806
0.015442009028043047
0.015844389490124653
0.016257283961506712
0.016671995869604214
0.017081496824635684
0.017480206146032195
0.017863771937595713
To get the average relative standard deviations (ignoring the first prediction which is 0), we run:
mean(σs[2:end] ./ μs[2:end])0.025565272878989364
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
- Thomas J. Rothenberg. Identification in parametric models. Econometrica, 1971.
- F. Mentre, A Mallet, and D. Baccar. Optimal design in random-effects regression models. Biometrika, 1997.
- 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.
- V. Shivva, K. Korell, I. Tucker, and S. Duffull. An approach for identifiability of population pharmacokinetic-pharmacodynamic models. CPT Pharmacometrics & Systems Pharmacology, 2013.
- Stephen Dufful, A workflow for resolving model internal consistency in use-reuse settings (aka repairing unstable models). PAGANZ, 2024.
- Dan Wright. The identifiability of a turnover model for allopurinol urate-lowering effect. PAGANZ, 2024.