# Dt\<= dtmin . Error

**URL:** <https://discourse.pumas.ai/t/dt-dtmin-error/442>\
**Category:** Uncategorized\
**Created:** [November 30, 2020, 6:03am UTC](https://discourse.pumas.ai/t/dt-dtmin-error/442 "2020-11-30T06:03:27Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![sai\_matcha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/sai_matcha/32/297_2.png) [@sai\_matcha](https://discourse.pumas.ai/u/sai_matcha)\
**Post date:** [November 30, 2020, 6:03am UTC](https://discourse.pumas.ai/t/dt-dtmin-error/442/1 "2020-11-30T06:03:28Z")

</div>

Can somebody can help me to interpret this error?

```auto
┌ Warning: dt <= dtmin. Aborting. There is either an error in your model specification or the true solution is unstable.
└ @ DiffEqBase C:\Users\julia\.julia\packages\DiffEqBase\3iigH\src\integrator_interface.jl:343

```

Thankyou.

---

<div class="post-metadata">

**Author:** ![andreasnoack](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/andreasnoack/32/22_2.png) [@andreasnoack](https://discourse.pumas.ai/u/andreasnoack)\
**Post date:** [November 30, 2020, 7:47am UTC](https://discourse.pumas.ai/t/dt-dtmin-error/442/2 "2020-11-30T07:47:01Z")

</div>

It means that the numerical ODE integrator is having problems but it’s hard to know why without seeing the model and maybe also the data. However, it has often helped to add upper or more narrow bounds on the parameters during the optimization so you might want to try that.

---

<div class="post-metadata">

**Author:** ![sai\_matcha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/sai_matcha/32/297_2.png) [@sai\_matcha](https://discourse.pumas.ai/u/sai_matcha)\
**Post date:** [November 30, 2020, 9:03am UTC](https://discourse.pumas.ai/t/dt-dtmin-error/442/3 "2020-11-30T09:03:19Z")

</div>

Thank you,  
I gave huge upper bounds

```auto
phenbm = @model begin
  @param begin
    tvka ∈ RealDomain(lower=0,init =0.225, upper = 10)
    tvk23 ∈ RealDomain(lower=0,init = 5.02, upper = 300 )
    tvQ ∈ RealDomain(lower=0,init = 60 , upper = 6000 )
    tvvc ∈ RealDomain(lower=0,init = 223, upper = 7000)
    tvvp ∈ RealDomain(lower=0,init = 2.8, upper = 1000)
    tvCL ∈ RealDomain(lower=0,init = 7 ,upper =4000)
    tvbio1 ∈ RealDomain(lower=0,init =0.63 , upper =1)
    tvbio2 ∈ RealDomain(lower=0,init = 0.66, upper =1)
    Ω ∈ PDiagDomain(init=[3.37,0.09,0.04,0.72,0.04,0.23,0.74,0.04]) # CL = 0.23,Vc = 0.72,KA = 3.37,vp = 0.04,k23 = 0.09
    σ ∈ RealDomain(lower=0,init = 0.04,upper = 0.1)
  end
  @random begin
    η ~ MvNormal(Ω)
  end
  @pre begin
    ka = tvka * exp(η[1])
    k23 = tvk23 * exp(η[2])
    Q = tvQ * exp(η[3])
    vc = tvvc * exp(η[4])
    vp = tvvp * exp(η[5])
    CL = tvCL * exp(η[6])
    bioav = (Depot1 = tvbio1* exp(η[7]), Depot2 = tvbio2* exp(η[8]))
  end
  @dynamics begin
    Depot1' = -ka * Depot1
    Depot2' = -k23 * Depot2
    Central' = ka * Depot1 + k23 * Depot2 - (Q/vc)*(Central) + (Q/vp)*Peripheral - (CL/vc)*Central
    Peripheral' = (Q/vc) * Central - (Q/vp) * Peripheral
  end
  @derived begin
    cp = @. Central/vc
    DV ~ @. Normal(cp,abs(cp)*σ)
  end
end

```

---

<div class="post-metadata">

**Author:** ![andreasnoack](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/andreasnoack/32/22_2.png) [@andreasnoack](https://discourse.pumas.ai/u/andreasnoack)\
**Post date:** [November 30, 2020, 11:12am UTC](https://discourse.pumas.ai/t/dt-dtmin-error/442/4 "2020-11-30T11:12:56Z")

</div>

Does it help if you lower the upper bounds?

---

<div class="post-metadata">

**Author:** ![sai\_matcha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/sai_matcha/32/297_2.png) [@sai\_matcha](https://discourse.pumas.ai/u/sai_matcha)\
**Post date:** [November 30, 2020, 12:35pm UTC](https://discourse.pumas.ai/t/dt-dtmin-error/442/5 "2020-11-30T12:35:09Z")

</div>

I did not try that yet. I just allowed model to run and give the parameter estimates. It took very long time to complete fitting. So ill try that out in night and post the update here.

---

<div class="post-metadata">

**Author:** ![sai\_matcha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/sai_matcha/32/297_2.png) [@sai\_matcha](https://discourse.pumas.ai/u/sai_matcha)\
**Post date:** [December 1, 2020, 5:43am UTC](https://discourse.pumas.ai/t/dt-dtmin-error/442/6 "2020-12-01T05:43:03Z")

</div>

I have adjusted limits. it shows the below Warning.

```auto
┌ Warning: First function call produced NaNs. Exiting.
└ @ OrdinaryDiffEq C:\Users\julia\.julia\packages\OrdinaryDiffEq\HO8vN\src\initdt.jl:137
┌ Warning: Automatic dt set the starting dt as NaN, causing instability.
└ @ OrdinaryDiffEq C:\Users\julia\.julia\packages\OrdinaryDiffEq\HO8vN\src\solve.jl:481
┌ Warning: NaN dt detected. Likely a NaN value in the state, parameters, or derivative value caused this outcome.
└ @ DiffEqBase C:\Users\julia\.julia\packages\DiffEqBase\3iigH\src\integrator_interface.jl:323

```

Adjusted Upper bounds

```auto
phenbm = @model begin
  @param begin
    tvka ∈ RealDomain(lower=0,init =0.225, upper = 2)
    tvk23 ∈ RealDomain(lower=0,init = 5.02, upper = 10)
    tvQ ∈ RealDomain(lower=0,init = 60 , upper = 150 )
    tvvc ∈ RealDomain(lower=0,init = 223, upper = 500)
    tvvp ∈ RealDomain(lower=0,init = 2.8, upper = 10)
    tvCL ∈ RealDomain(lower=0,init = 7 ,upper =40)
    tvbio1 ∈ RealDomain(lower=0,init =0.63 , upper =1)
    tvbio2 ∈ RealDomain(lower=0,init = 0.66, upper =1)
    Ω ∈ PDiagDomain(init=[3.37,0.09,0.04,0.72,0.04,0.23,0.74,0.04]) # CL = 0.23,Vc = 0.72,KA = 3.37,vp = 0.04,k23 = 0.09
    σ ∈ RealDomain(lower=0,init = 0.04,upper = 0.1)
  end
  @random begin
    η ~ MvNormal(Ω)
  end
  @pre begin
    ka = tvka * exp(η[1])
    k23 = tvk23 * exp(η[2])
    Q = tvQ * exp(η[3])
    vc = tvvc * exp(η[4])
    vp = tvvp * exp(η[5])
    CL = tvCL * exp(η[6])
    bioav = (Depot1 = tvbio1* exp(η[7]), Depot2 = tvbio2* exp(η[8]))
  end
  @dynamics begin
    Depot1' = -ka * Depot1
    Depot2' = -k23 * Depot2
    Central' = ka * Depot1 + k23 * Depot2 - (Q/vc)*(Central) + (Q/vp)*Peripheral - (CL/vc)*Central
    Peripheral' = (Q/vc) * Central - (Q/vp) * Peripheral
  end
  @derived begin
    cp = @. Central/vc
    DV ~ @. Normal(cp,abs(cp)*σ)
  end
end

```

---

<div class="post-metadata">

**Author:** ![andreasnoack](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/andreasnoack/32/22_2.png) [@andreasnoack](https://discourse.pumas.ai/u/andreasnoack)\
**Post date:** [December 1, 2020, 11:12am UTC](https://discourse.pumas.ai/t/dt-dtmin-error/442/7 "2020-12-01T11:12:02Z")

</div>

Do you get the warnings even if you just evaluate `loglikelihood` in the starting values?

---

<div class="post-metadata">

**Author:** ![sai\_matcha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/sai_matcha/32/297_2.png) [@sai\_matcha](https://discourse.pumas.ai/u/sai_matcha)\
**Post date:** [December 1, 2020, 11:35am UTC](https://discourse.pumas.ai/t/dt-dtmin-error/442/8 "2020-12-01T11:35:06Z")

</div>

it Came after 20th iteration

```auto
┌ Warning: First function call produced NaNs. Exiting.
└ @ OrdinaryDiffEq C:\Users\julia\.julia\packages\OrdinaryDiffEq\HO8vN\src\initdt.jl:137
┌ Warning: Automatic dt set the starting dt as NaN, causing instability.
└ @ OrdinaryDiffEq C:\Users\julia\.julia\packages\OrdinaryDiffEq\HO8vN\src\solve.jl:481
┌ Warning: NaN dt detected. Likely a NaN value in the state, parameters, or derivative value caused this outcome.
└ @ DiffEqBase C:\Users\julia\.julia\packages\DiffEqBase\3iigH\src\integrator_interface.jl:323
    21 2.221417e+03 4.272145e+01
 * time: 3872.898999929428
    22 2.191276e+03 3.996152e+01
 * time: 4018.6080000400543
    23 2.190728e+03 4.096070e+01
 * time: 4128.06299996376
    24 2.190317e+03 3.837986e+01

```

---

<div class="post-metadata">

**Author:** ![andreasnoack](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/andreasnoack/32/22_2.png) [@andreasnoack](https://discourse.pumas.ai/u/andreasnoack)\
**Post date:** [December 1, 2020, 12:16pm UTC](https://discourse.pumas.ai/t/dt-dtmin-error/442/9 "2020-12-01T12:16:41Z")

</div>

It looks like the optimization continues after the warnings. In that case you don’t have to worry about them. During the optimization, the optimizer might try to take a step that causes the warnings but the step will typically then be rejected and a shorter step will be tried instead. Occasionally, these steps can slow the optimization down so much that it becomes a problem. How long does `fit` spend on the 20th iteration?

---

<div class="post-metadata">

**Author:** ![sai\_matcha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/sai_matcha/32/297_2.png) [@sai\_matcha](https://discourse.pumas.ai/u/sai_matcha)\
**Post date:** [December 1, 2020, 12:37pm UTC](https://discourse.pumas.ai/t/dt-dtmin-error/442/10 "2020-12-01T12:37:09Z")

</div>

I did not check how long it took. I am not able to access later. May be REPL capacity id limited(?).

is there way to save total output and used model after each run?
