# Indentify parameters in an ODEProblem

**URL:** <https://discourse.julialang.org/t/indentify-parameters-in-an-odeproblem/114784>\
**Category:** Modelling & Simulations\
**Tags:** turing, modelingtoolkit, differentialequation\
**Created:** [May 27, 2024, 1:56pm UTC](https://discourse.julialang.org/t/indentify-parameters-in-an-odeproblem/114784 "2024-05-27T13:56:39Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![langestefan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/langestefan/32/207923_2.png) [@langestefan](https://discourse.julialang.org/u/langestefan)\
**Post date:** [May 29, 2024, 10:49am UTC](https://discourse.julialang.org/t/indentify-parameters-in-an-odeproblem/114784/17 "2024-05-29T10:49:27Z")

</div>

> [@cryptic.ax](#):
>
> Thanks for the feedback, we’re definitely open to improving documentation wherever possible. [This](https://docs.sciml.ai/ModelingToolkit/stable/examples/remake/) is probably the page you were looking for, since it describes a similar kind of process to what you are doing here. I’ll see where I can put it so it’s more visible instead of being hidden under a folding menu.

Indeed, I was following that page already. But I got a totally lost with all the different options available to modify ODE problems.

> [@cryptic.ax](#):
>
> That looks correct

Apologies, I modified the code while you were typing a reply, i hope you caught that?

> [@cryptic.ax](#):
>
> The function you pass to `GeneralLazyBufferCache` takes the parameter values (as a vector) and does `remake_buffer`.

I implemented it like this:

```julia-auto
# ordered symbols
syms = [sys.lC_i, sys.lC_e, sys.lC_h, sys.lR_ie, sys.lR_ea, sys.lR_ih, sys.lA_w, sys.lA_e]

@model function LGDS(x::AbstractArray, prob, params::Dict, t_int)

    # cache for remake(prob, p=newp)
    lbc = GeneralLazyBufferCache(function (p)
        remake_buffer(sys, prob.p, Dict(zip(syms, p)))    
    end)    

    # prior distributions
    σ ~ InverseGamma(2, 3)
    lC ~ MvNormal(params[:μ_C], params[:Σ_C])
    lR ~ MvNormal(params[:μ_R], params[:Σ_R])
    lA ~ MvNormal(params[:μ_A], params[:Σ_A])
   
    # remake the problem with the sampled parameter values and enforce order
    newp = lbc[[lC; lR; lA]]
    new_prob = remake(prob, p=newp)

    # solve the ODE
    T_ode = solve(new_prob, Tsit5(); save_idxs=1, verbose=false)
    if !(SciMLBase.successful_retcode(T_ode.retcode))
       return
    end

    # time points corresponding to observations `x`
    x_est = T_ode(time)  
    x ~ MvNormal(x_est.u, σ^2 * I)    

    return nothing
end

```

Is that appropriate?

I am bit skeptical of how much performance benefits it will actually yield, since each sample `p` would have to be cached and I don’t know enough about HMC or the NUTS sampler implementation to say whether they would be reused at all. Is there a way to check cache usage?

---

_[View the full topic](https://discourse.julialang.org/t/indentify-parameters-in-an-odeproblem/114784)._
