# Issue with example in DiffEqParamEstim.jl

**URL:** <https://discourse.julialang.org/t/issue-with-example-in-diffeqparamestim-jl/83067>\
**Category:** New to Julia\
**Tags:** diffeq, examples, optim, differentialequation\
**Created:** [June 20, 2022, 1:20pm UTC](https://discourse.julialang.org/t/issue-with-example-in-diffeqparamestim-jl/83067 "2022-06-20T13:20:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Curio\_math](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/curio_math/32/32981_2.png) [@Curio\_math](https://discourse.julialang.org/u/Curio_math)\
**Post date:** [June 20, 2022, 1:20pm UTC](https://discourse.julialang.org/t/issue-with-example-in-diffeqparamestim-jl/83067/1 "2022-06-20T13:20:24Z")

</div>

Hi,  
I am excited to try **parameter estimation** on my model using **DiffEqParamEstim**.jl package. I thought of trying out some examples in the documentation and then choose the best method for my model. But I found some of those examples not working for me.

**Example of Lotka-Volterra Equation with 4 parameters** is the one I have tried. But after optimization using the package Optim.jl with BFGS algorithm, rendered **status failure** as the line search failed. Can I get a helping hand on this?

Also can I know if the same strategy in this example can be extended to a large system of differential equations with around 15 parameters to estimate?

Thanks in advance!

Here is the code in detail with the package versions I deal with.

Julia 1.7.1  
DiffEqParamEstim v1.23.1  
DifferentialEquations v7.1.0  
Optim v1.7.0  
RecursiveArrayTools v2.29.2

```julia
using DiffEqParamEstim, DifferentialEquations,RecursiveArrayTools, Optim

function f2(du,u,p,t)
  du[1] = dx = p[1]*u[1] - p[2]*u[1]*u[2]
  du[2] = dy = -p[3]*u[2] + p[4]*u[1]*u[2]
end

u0 = [1.0;1.0]
tspan = (0.0,10.0)
p = [1.5,1.0,3.0,1.0]
prob = ODEProblem(f2,u0,tspan,p)
sol = solve(prob,Tsit5())

t = collect(range(0,stop=10,length=200))
randomized = VectorOfArray([(sol(t[i]) + .01randn(2)) for i in 1:length(t)])
data = convert(Array,randomized)

cost_function = build_loss_objective(prob,Tsit5(),L2Loss(t,data),
                                      maxiters=10000,verbose=false)
result_bfgs = Optim.optimize(cost_function, [1.3,0.8,2.8,1.2], Optim.BFGS())

```

---

<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:** [June 20, 2022, 1:36pm UTC](https://discourse.julialang.org/t/issue-with-example-in-diffeqparamestim-jl/83067/2 "2022-06-20T13:36:55Z")

</div>

Did the optimization actually fail? Or did Optim just return a fail status? The latter tends to happen, Optim.jl does that but it doesn’t really mean it 🤷 .

> [@Curio\_math](#):
>
> Also can I know if the same strategy in this example can be extended to a large system of differential equations with around 15 parameters to estimate?

15 parameters is still very small. This will be fine for it. For more advanced stuff you’d want to directly use DiffEqSensitivity.jl, but for such small models with single datasets this should be fine.

---

<div class="post-metadata">

**Author:** ![Curio\_math](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/curio_math/32/32981_2.png) [@Curio\_math](https://discourse.julialang.org/u/Curio_math)\
**Post date:** [June 21, 2022, 10:03am UTC](https://discourse.julialang.org/t/issue-with-example-in-diffeqparamestim-jl/83067/3 "2022-06-21T10:03:53Z")

</div>

Thanks a lot. Yes it was Optim returning status failure. Even then we can access accurate estimates in case of Lotka Volterra example.
