# Parameter Estimation of DelayDiffEq (and other Non-ODE) Problems

**URL:** <https://discourse.pumas.ai/t/parameter-estimation-of-delaydiffeq-and-other-non-ode-problems/912>\
**Category:** Estimation\
**Created:** [August 7, 2023, 9:09pm UTC](https://discourse.pumas.ai/t/parameter-estimation-of-delaydiffeq-and-other-non-ode-problems/912 "2023-08-07T21:09:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bca](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/bca/32/400_2.png) [@bca](https://discourse.pumas.ai/u/bca)\
**Post date:** [August 7, 2023, 9:09pm UTC](https://discourse.pumas.ai/t/parameter-estimation-of-delaydiffeq-and-other-non-ode-problems/912/1 "2023-08-07T21:09:55Z")

</div>

I am currently trying to model and simulate a system of delay differential equations(DDEs) in Pumas. While I can currently simulate, when I try to do parameter estimation I get the error  
“Incompatible problem+solver pairing”, which I presume means that Pumas does not currently support non-ode parameter estimation.

The closest advice I’ve seen for non-ode parameter estimation portion came from @ChrisRackauckas in a Pumas discussion thread from July 2020 found [here](https://discourse.pumas.ai/t/estimation-with-stochastic-differential-equations/377). Are there any updates on if/when Pumas will support non-ode parameter estimation? Also, the aforementioned thread said there is a workaround for parameter estimation of SDE problems using another Julia Library. Does such a workaround exist for the parameter estimation of a system of DDEs? Thank you in advance.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/chrisrackauckas/32/14_2.png) [@ChrisRackauckas](https://discourse.pumas.ai/u/ChrisRackauckas)\
**Post date:** [August 7, 2023, 9:29pm UTC](https://discourse.pumas.ai/t/parameter-estimation-of-delaydiffeq-and-other-non-ode-problems/912/2 "2023-08-07T21:29:08Z")

</div>

> [@bca](#):
>
> “Incompatible problem+solver pairing”, which I presume means that Pumas does not currently support non-ode parameter estimation.

This error means that an ODE solver was specified on a non-ODE. When you did the `fit` call, did you pass a DDE solver algorithm?

---

<div class="post-metadata">

**Author:** ![bca](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/bca/32/400_2.png) [@bca](https://discourse.pumas.ai/u/bca)\
**Post date:** [August 16, 2023, 8:38pm UTC](https://discourse.pumas.ai/t/parameter-estimation-of-delaydiffeq-and-other-non-ode-problems/912/3 "2023-08-16T20:38:38Z")

</div>

Apologies, yeah that was the issue, thanks!

Now I’m onto a new issue with the fit, specifically I am able to simulate it correctly with the following settings:

```auto
diffeq_options = (alg = MethodOfSteps(Rodas4()),
                    reltol = 1e-15, abstol = 1e-14, dtmax = 0.001,
                    saveat = 0:600, maxiters = 1e7, tstops = discontinuities)

```

However, applying the same settings to the fit (FOCE) results in an error that states the dde is too stiff to solve.

Increasing maxiters to 1e9 doesn’t fix it (haven’t tested past that since 1e9 already takes a while). Dropping both of the tolerances to 1e-3 gets a different error:

```auto
┌ Info: Checking the initial parameter values.
└ @ Pumas /build/_work/PumasSystemImages/PumasSystemImages/julia_depot/packages/Pumas/9AGx1/src/estimation/likelihoods.jl:3995

MethodError: no method matching _valid_foce_distribution(::Matrix{ForwardDiff.Dual{ForwardDiff.Tag{Pumas.Tag, Float64}, Float64, 1}})

```

I get a similar error when using LaplaceI.

Any idea what I could be setting up incorrectly? At the moment, everything in the model aspect is exactly the same as the simulation. Below is my current fit function. Let me know if you need to see other aspects of the code. Thank you again.

```julia
ada_fit = fit(p_model,ada_fig5a_prefit,init_params(p_model), Pumas.FOCE();
                optimize_fn=Pumas.DefaultOptimizeFN(show_trace=true), 
                diffeq_options=diffeq_options,
                ensemblealg = EnsembleDistributed())

```

---

<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:** [August 17, 2023, 8:20am UTC](https://discourse.pumas.ai/t/parameter-estimation-of-delaydiffeq-and-other-non-ode-problems/912/4 "2023-08-17T08:20:02Z")

</div>

It could look like you are missing a dot or `@.` in the derived block. Notice that it is checking a `Matrix` in `_valid_foce_distribution(::Matrix...)`. E.g.

```julia
julia> Central = [1.0, 2.0, 3.0];

julia> Vc = [1.1, 1.2, 1.1];

julia> Central / Vc
3×3 Matrix{Float64}:
 0.284974 0.310881 0.284974
 0.569948 0.621762 0.569948
 0.854922 0.932642 0.854922

```

vs

```julia
julia> @. Central / Vc
3-element Vector{Float64}:
 0.9090909090909091
 1.6666666666666667
 2.727272727272727

```

---

<div class="post-metadata">

**Author:** ![JohnTillinghast](https://avatars.discourse-cdn.com/v4/letter/j/5f9b8f/32.png) [@JohnTillinghast](https://discourse.pumas.ai/u/JohnTillinghast)\
**Post date:** [September 23, 2024, 6:49pm UTC](https://discourse.pumas.ai/t/parameter-estimation-of-delaydiffeq-and-other-non-ode-problems/912/5 "2024-09-23T18:49:11Z")

</div>

How does the SDE workaround “work”? Has anyone tried it (and are they willing to show some code)?

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/mohamed82008/32/127_2.png) [@mohamed82008](https://discourse.pumas.ai/u/mohamed82008)\
**Post date:** [October 25, 2024, 11:20pm UTC](https://discourse.pumas.ai/t/parameter-estimation-of-delaydiffeq-and-other-non-ode-problems/912/6 "2024-10-25T23:20:19Z")

</div>

SDEs are currently not natively supported in Pumas. Could you tell us more about your use case?
