# Estimating parameter and function in an ODE model

**URL:** https://discourse.julialang.org/t/estimating-parameter-and-function-in-an-ode-model/126109
**Category:** Modelling & Simulations
**Tags:** machine-learning
**Created:** [February 20, 2025, 10:29am UTC](https://discourse.julialang.org/t/estimating-parameter-and-function-in-an-ode-model/126109 "2025-02-20T10:29:46Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![dg.aragones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dg.aragones/32/11275_2.png) [@dg.aragones](https://discourse.julialang.org/u/dg.aragones)
#### Post date: [February 20, 2025, 10:29am UTC](https://discourse.julialang.org/t/estimating-parameter-and-function-in-an-ode-model/126109/1 "2025-02-20T10:29:46Z")

</div>

Hi all,

I’m working on an ODE model where I want to infer a parameter μ and a function ϕ(t), and I’m looking for recommendations for tools or approaches in Julia to solve this problem. My dataset is small, with just 7 data points in the form (t, n).

The model is given by:

\frac{dn}{dt} = \phi(t) - \mu \, n(t), \quad n(t=0) = 0

I’m considering two possible approaches for modeling ϕ(t):

1. Gaussian Process (GP) for a non-parametric approach.
2. Neural Networks (NNs) to approximate ϕ(t), but with strong regularization given the limited data.

Which approach and related packages would you recommend in Julia for this problem?

Any guidance or relevant examples would be greatly appreciated!

Thanks in advance for your help!

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [February 21, 2025, 6:47am UTC](https://discourse.julialang.org/t/estimating-parameter-and-function-in-an-ode-model/126109/2 "2025-02-21T06:47:47Z")

</div>

> [@dg.aragones](#):
>
> Neural Networks (NNs) to approximate ϕ(t), but with strong regularization given the limited data.

See for example [Parameter Estimation of Ordinary Differential Equations · SciMLSensitivity.jl](https://docs.sciml.ai/SciMLSensitivity/stable/tutorials/parameter_estimation_ode/)

For your case here, I’d recommend using DataInterpolations.jl to represent the phi via a spline at a bunch of points, and differentiate w.r.t. those points.

---

<div class="post-metadata">

### Author: ![zdenek\_hurak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zdenek_hurak/32/53118_2.png) [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)
#### Post date: [February 22, 2025, 6:48am UTC](https://discourse.julialang.org/t/estimating-parameter-and-function-in-an-ode-model/126109/3 "2025-02-22T06:48:32Z")

</div>

Isn’t at least anything known/assumed about \phi(t)?

---

<div class="post-metadata">

### Author: ![dg.aragones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dg.aragones/32/11275_2.png) [@dg.aragones](https://discourse.julialang.org/u/dg.aragones)
#### Post date: [February 22, 2025, 10:44am UTC](https://discourse.julialang.org/t/estimating-parameter-and-function-in-an-ode-model/126109/4 "2025-02-22T10:44:43Z")

</div>

Thank you for your suggestion!

I’ll definitely look into `SciMLSensitivity.jl` and explore how to use it.

---

<div class="post-metadata">

### Author: ![dg.aragones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dg.aragones/32/11275_2.png) [@dg.aragones](https://discourse.julialang.org/u/dg.aragones)
#### Post date: [February 22, 2025, 10:50am UTC](https://discourse.julialang.org/t/estimating-parameter-and-function-in-an-ode-model/126109/5 "2025-02-22T10:50:03Z")

</div>

In my case, I can indeed make some reasonable assumptions: I would assume that \mu \> 0 and \phi(t) \> 0 for all t. These constraints are physically meaningful in the context of my problem, and incorporating them into the model could help improve the robustness of the inference, but I would like to keep the function \phi(t) as flexible as possible without overfitting.

---

<div class="post-metadata">

### Author: ![zdenek\_hurak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zdenek_hurak/32/53118_2.png) [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)
#### Post date: [February 22, 2025, 9:43pm UTC](https://discourse.julialang.org/t/estimating-parameter-and-function-in-an-ode-model/126109/6 "2025-02-22T21:43:31Z")

</div>

Any other assumption? Can continuity (or perhaps even smoothnesss) of \phi(t) be assumed? Is some upper bound on the amplitude of \phi(t) known?

---

<div class="post-metadata">

### Author: ![dg.aragones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dg.aragones/32/11275_2.png) [@dg.aragones](https://discourse.julialang.org/u/dg.aragones)
#### Post date: [February 23, 2025, 12:29am UTC](https://discourse.julialang.org/t/estimating-parameter-and-function-in-an-ode-model/126109/8 "2025-02-23T00:29:09Z")

</div>

Yes, I can assume that ϕ(t) is continuous and smooth. However, I’m not sure how to determine or set an upper bound.

---

<div class="post-metadata">

### Author: ![dg.aragones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dg.aragones/32/11275_2.png) [@dg.aragones](https://discourse.julialang.org/u/dg.aragones)
#### Post date: [May 7, 2025, 10:44am UTC](https://discourse.julialang.org/t/estimating-parameter-and-function-in-an-ode-model/126109/9 "2025-05-07T10:44:31Z")

</div>

Thanks again for your previous suggestion! Using `DataInterpolations.jl` to represent ϕ(t) as a spline worked really well, and I am impressed by both the performance and flexibility of Julia, especially compared to other scientific programming languages I’ve used.

Now I’m looking to go one step further and estimate the uncertainty in my model predictions. Specifically, I’d like to obtain confidence intervals that account for both the standard errors in the observed data (which I have) and the temporal autocorrelation between data points.

I was considering using a bootstrap-based approach, but I’m not sure how best to implement resampling in a way that incorporates both the measurement uncertainty and the correlation structure. Do you have any recommendations on how to do this in Julia? Or are there tools/packages in the SciML ecosystem that might be particularly suited to this task?

Thanks again for your guidance, really appreciate the support!

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [May 7, 2025, 10:55am UTC](https://discourse.julialang.org/t/estimating-parameter-and-function-in-an-ode-model/126109/10 "2025-05-07T10:55:12Z")

</div>

- [Parallel Ensemble Simulations · DifferentialEquations.jl](https://docs.sciml.ai/DiffEqDocs/stable/features/ensemble/)
- [Bayesian Differential Equations – Turing.jl](https://turinglang.org/docs/tutorials/bayesian-differential-equations/index.html)
- [Home · SciMLExpectations.jl](https://docs.sciml.ai/SciMLExpectations/stable/)
- [Overview · PolyChaos.jl](https://docs.sciml.ai/PolyChaos/stable/)

Are all different approaches to this

---

<div class="post-metadata">

### Author: ![dg.aragones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dg.aragones/32/11275_2.png) [@dg.aragones](https://discourse.julialang.org/u/dg.aragones)
#### Post date: [May 13, 2025, 11:38am UTC](https://discourse.julialang.org/t/estimating-parameter-and-function-in-an-ode-model/126109/11 "2025-05-13T11:38:47Z")

</div>

Thanks a lot for these great suggestions! I hadn’t come across these packages before, so I’m really glad you pointed them out, they seem especially interesting for exploring uncertainty in a more principled way. I’ll also take a closer look at ensemble simulations.

Really appreciate you taking the time to share these options, it’s super helpful!

---

<div class="post-metadata">

### Author: ![Matthew1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/matthew1/32/215134_2.png) [@Matthew1](https://discourse.julialang.org/u/Matthew1)
#### Post date: [May 15, 2025, 9:44am UTC](https://discourse.julialang.org/t/estimating-parameter-and-function-in-an-ode-model/126109/12 "2025-05-15T09:44:27Z")

</div>

Is it possible to use DataInterpolations.jl within MTK? In other words will MTK be able to infer the functions and derivatives in a symbolic way it understands?

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [May 15, 2025, 9:50am UTC](https://discourse.julialang.org/t/estimating-parameter-and-function-in-an-ode-model/126109/13 "2025-05-15T09:50:17Z")

</div>

Yes. Extended discussion in [SampledData Component · ModelingToolkitStandardLibrary.jl](https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/tutorials/input_component/)
