# NaN error when modeling complex absorption using Inverse Gaussian func

**URL:** <https://forum.certara.com/t/nan-error-when-modeling-complex-absorption-using-inverse-gaussian-func/3609>\
**Category:** Modelling and Simulation\
**Created:** [June 1, 2022, 1:53pm UTC](https://forum.certara.com/t/nan-error-when-modeling-complex-absorption-using-inverse-gaussian-func/3609 "2022-06-01T13:53:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aabulfathi](https://avatars.discourse-cdn.com/v4/letter/a/e68b1a/32.png) [@aabulfathi](https://forum.certara.com/u/aabulfathi)\
**Post date:** [June 1, 2022, 1:53pm UTC](https://forum.certara.com/t/nan-error-when-modeling-complex-absorption-using-inverse-gaussian-func/3609/1 "2022-06-01T13:53:11Z")

</div>

Hi everyone,

Could you please assist me? When trying to model complex absorption with inverse Gaussian functions, I keep getting this error message “Model execution failed. Initial parameter values result in -LL = NaN” I have tried different initial estimates for MAT and CV without success.

See below the model code:

test(){

input = t ==0 ? 0 : ((MAT/(6.283_CV^2_t^3))^0.5) _exp(-((MAT-t)^2)/(2_CV^2_MAT_t))

P1 = (MAT/(2_3.14_CV_CV_(t+0.000001)**3))  
P2 = P1**0.5  
P3 = (MAT-(t+0.000001))_(MAT-(t+0.000001))/(2_CV_CV_MAT\*(t+0.000001))  
IG = 1_P2_exp(-P3)  
deriv(Aa = -input \* Aa)  
deriv(A1 = input \* Aa - Cl \* C- Cl2 \* (C - C2))  
deriv(cumabs = IG )  
#deriv(Aa = - Ka \* Aa)  
#deriv(A1 = Ka \* Aa - Cl \* C - Cl2 \* (C - C2))  
deriv(A2 = Cl2 \* (C - C2))  
dosepoint(Aa)  
C = A1 / V  
cumabsout = cumabs  
C2 = A2 / V2  
error(CEps = 0.171872765515157)  
observe(CObs = C \* (1 + CEps))  
#stparm(Ka = tvKa \* exp(nKa))  
stparm(MAT = tvMAT \* exp(nMAT))  
stparm(CV = tvCV \* exp(nCV))  
stparm(V = tvV \* exp(nV))  
stparm(V2 = tvV2)  
stparm(Cl = tvCl \* exp(nCl))  
stparm(Cl2 = tvCl2 \* exp(nCl2))  
fixef(tvMAT = c(,5,))  
fixef(tvCV = c(,0.6,))  
#fixef(tvKa = c(, 12.5738819057084, ))  
fixef(tvV = c(, 43.2890620436938, ))  
fixef(tvV2 = c(, 45.1186153287527, ))  
fixef(tvCl = c(, 7.49094934958544, ))  
fixef(tvCl2 = c(, 154.794695950696, ))  
ranef(diag(nV, nCl, nMAT, nCV, nCl2) = c(0.49173913, 0.71344537, 0.001, 0.001, 0.38537209))  
}

Many thanks and kind regards,  
Ahmed

---

<div class="post-metadata">

**Author:** ![kniefort](https://avatars.discourse-cdn.com/v4/letter/k/c68b51/32.png) [@kniefort](https://forum.certara.com/u/kniefort)\
**Post date:** [June 1, 2022, 2:14pm UTC](https://forum.certara.com/t/nan-error-when-modeling-complex-absorption-using-inverse-gaussian-func/3609/2 "2022-06-01T14:14:43Z")

</div>

Hi Ahmed,

As a quick comment have you considered using the built in delay model for InverseGaussian? E.g.:

In the meantime I will see if I can find any errors in your code.

test(){  
C2 = A2/V2  
dosepoint(A1)  
C = A1 / V  
delayInfCpt(A1, MeanDelayTime, ShapeParam, out = - Cl \* C - Cl2 \* (C - C2), dist = InverseGaussian)  
deriv(A2 = Cl2 \* (C - C2))  
error(CEps=0.1)  
observe(CObs=C \* ( 1 + CEps))  
stparm(MeanDelayTime = tvMeanDelayTime \* exp(nMeanDelayTime))  
stparm(ShapeParam = tvShapeParam \* exp(nShapeParam))  
stparm(V = tvV \* exp(nV))  
stparm(Cl = tvCl \* exp(nCl))  
stparm(V2 = tvV2 \* exp(nV2))  
stparm(Cl2 = tvCl2 \* exp(nCl2))  
fixef( tvMeanDelayTime = c(,1,))  
fixef( tvShapeParam = c(,1,))  
fixef( tvV = c(,1,))  
fixef( tvCl = c(,1,))  
fixef( tvV2 = c(,1,))  
fixef( tvCl2 = c(,1,))  
ranef(diag(nMeanDelayTime,nShapeParam,nV,nCl,nV2,nCl2) = c(1,1,1,1,1,1))  
}

Hu, Dunlavey, Guzy, and Teuscher (2018)

A distributed delay approach for modeling delayed outcomes in pharmacokinetics and pharmaco ­dynamics studies. J Pharmacokinet Pharmacodyn. [https://doi.org/10.1007/s10928-018-9570-4](https://doi.org/10.1007/s10928-018-9570-4).

[https://onlinehelp.certara.com/phoenix/8.3/index.html#t=topics%2FDiscrete\_and\_distributed\_delays.htm&rhsearch=logistic%20growth%20model&rhsyns=%20](https://onlinehelp.certara.com/phoenix/8.3/index.html#t=topics%2FDiscrete_and_distributed_delays.htm&rhsearch=logistic%20growth%20model&rhsyns=%20)

---

<div class="post-metadata">

**Author:** ![aabulfathi](https://avatars.discourse-cdn.com/v4/letter/a/e68b1a/32.png) [@aabulfathi](https://forum.certara.com/u/aabulfathi)\
**Post date:** [June 1, 2022, 4:14pm UTC](https://forum.certara.com/t/nan-error-when-modeling-complex-absorption-using-inverse-gaussian-func/3609/3 "2022-06-01T16:14:46Z")

</div>

Thanks a million! Kniefort,

I tried the built-in option you provided and it works!

With kind regards,

Ahmed

---

<div class="post-metadata">

**Author:** ![Samer\_Mouksassi](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Samer\_Mouksassi](https://forum.certara.com/u/Samer_Mouksassi)\
**Post date:** [June 5, 2022, 8:30am UTC](https://forum.certara.com/t/nan-error-when-modeling-complex-absorption-using-inverse-gaussian-func/3609/4 "2022-06-05T08:30:38Z")

</div>

indeed always better to use built-in distribution in modern software versus coding everything if you need anything the above error is probably because a division by zero for yet to get initial non zero value parameter.

An inverse Gaussian can have multiple way to get parametrized and the verotta paper has how to go form one to to the other.

Best wishes
