# Getting issue in optim.optimize function while bayesian estimating parameters of stochastic differential equation

**URL:** <https://discourse.julialang.org/t/getting-issue-in-optim-optimize-function-while-bayesian-estimating-parameters-of-stochastic-differential-equation/88628>\
**Category:** New to Julia\
**Created:** [October 12, 2022, 3:19pm UTC](https://discourse.julialang.org/t/getting-issue-in-optim-optimize-function-while-bayesian-estimating-parameters-of-stochastic-differential-equation/88628 "2022-10-12T15:19:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Virendra\_Sheoran](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/virendra_sheoran/32/43185_2.png) [@Virendra\_Sheoran](https://discourse.julialang.org/u/Virendra_Sheoran)\
**Post date:** [October 12, 2022, 3:19pm UTC](https://discourse.julialang.org/t/getting-issue-in-optim-optimize-function-while-bayesian-estimating-parameters-of-stochastic-differential-equation/88628/1 "2022-10-12T15:19:56Z")

</div>

using Turing  
using DifferentialEquations  
using OrdinaryDiffEq, DiffEqParamEstim, JuMP, NLopt, Plots

# Load StatsPlots for visualizations and diagnostics.

using StatsPlots

using LinearAlgebra  
using DiffEqParamEstim  
using DiffEqBayes  
using Optim

# Set a seed for reproducibility.

using Random  
Random.seed!(14);

pf\_func = function (du,u,p,t)  
du[1] = p[1] \* u[1] - p[2] \* u[1]\*u[2]  
du[2] = -3 \* u[2] + u[1]\*u[2]  
end

u0 = [1.0;1.0]  
tspan = (0.0,10.0)  
p = [1.5,1.0]  
pg\_func = function (du,u,p,t)  
du[1] = 0.15_u[1]  
du[2] = 0.2_u[2]  
end  
prob = SDEProblem(pf\_func,pg\_func,u0,tspan,p)  
sol = solve(prob,SRIW1())  
#using plot  
plot(sol)

using RecursiveArrayTools # for VectorOfArray  
t = collect(range(0, stop=10, length=200))  
function generate\_data(t)  
sol = solve(prob,SRIW1())  
randomized = VectorOfArray([(sol(t[i]) + .01randn(2)) for i in 1:length(t)])  
data = convert(Array,randomized)  
end  
aggregate\_data = convert(Array,VectorOfArray([generate\_data(t) for i in 1:10000]))

monte\_prob = EnsembleProblem(prob)

obj = build\_loss\_objective(monte\_prob,SRIW1(),L2Loss(t,data,differ\_weight=1.0,data\_weight=0.5),maxiters=1000,  
verbose=false,verbose\_opt=false,verbose\_steps=1,num\_monte=50)  
result = Optim.optimize(obj, [1.0,0.5], Optim.BFGS())

following is the ERROR

┌ Warning: num\_monte has been replaced by trajectories  
└ @ SciMLBase C:\Users\User.julia\packages\SciMLBase\DXiE6\src\ensemble\basic\_ensemble\_solve.jl:47  
MethodError: no method matching -(::Vector{Float64}, ::Float64)  
For element-wise subtraction, use broadcasting with dot syntax: array .- scalar  
Closest candidates are:  
-(::AbstractAlgebra.MatrixElem, ::Union{AbstractFloat, Integer, Rational}) at C:\Users\User.julia\packages\AbstractAlgebra\2tNNk\src\generic\Matrix.jl:838  
-(::Union{MathOptInterface.ScalarAffineFunction{T}, MathOptInterface.ScalarQuadraticFunction{T}}, ::T) where T at C:\Users\User.julia\packages\MathOptInterface\YDdD3\src\Utilities\functions.jl:1725  
-(::Tracker.TrackedReal, ::Real) at C:\Users\User.julia\packages\Tracker\9xWLl\src\lib\real.jl:95  
…

Stacktrace:  
[1] (::L2Loss{Vector{Float64}, EnsembleSolution{Float64, 3, Vector{RODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, NoiseProcess{Float64, 2, Float64, Vector{Float64}, Vector{Float64}, Vector{Vector{Float64}}, typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_DIST), typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_BRIDGE), true, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, RSWM{Float64}, Nothing, RandomNumbers.Xorshifts.Xoroshiro128Plus}, SDEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, Nothing, SDEFunction{true, typeof(lotka\_volterra!), typeof(multiplicative\_noise!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, typeof(multiplicative\_noise!), Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing}, SOSRI, StochasticDiffEq.LinearInterpolationData{Vector{Vector{Float64}}, Vector{Float64}}, DiffEqBase.DEStats}}}, Float64, Float64, Nothing})(sol::RODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, NoiseProcess{Float64, 2, Float64, Vector{Float64}, Vector{Float64}, Vector{Vector{Float64}}, typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_DIST), typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_BRIDGE), true, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, RSWM{Float64}, Nothing, RandomNumbers.Xorshifts.Xoroshiro128Plus}, SDEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, Nothing, SDEFunction{true, var"#71#72", var"#73#74", UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, var"#73#74", Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing}, SRIW1, StochasticDiffEq.LinearInterpolationData{Vector{Vector{Float64}}, Vector{Float64}}, DiffEqBase.DEStats})  
@ DiffEqParamEstim C:\Users\User.julia\packages\DiffEqParamEstim\CEtDL\src\cost\_functions.jl:104  
[2] \_broadcast\_getindex\_evalf  
@ .\broadcast.jl:670 [inlined]  
[3] \_broadcast\_getindex  
@ .\broadcast.jl:643 [inlined]  
[4] getindex  
@ .\broadcast.jl:597 [inlined]  
[5] macro expansion  
@ .\broadcast.jl:961 [inlined]  
[6] macro expansion  
@ .\simdloop.jl:77 [inlined]  
[7] copyto!  
@ .\broadcast.jl:960 [inlined]  
[8] copyto!  
@ .\broadcast.jl:913 [inlined]  
[9] copy  
@ .\broadcast.jl:885 [inlined]  
[10] materialize  
@ .\broadcast.jl:860 [inlined]  
[11] (::L2Loss{Vector{Float64}, EnsembleSolution{Float64, 3, Vector{RODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, NoiseProcess{Float64, 2, Float64, Vector{Float64}, Vector{Float64}, Vector{Vector{Float64}}, typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_DIST), typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_BRIDGE), true, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, RSWM{Float64}, Nothing, RandomNumbers.Xorshifts.Xoroshiro128Plus}, SDEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, Nothing, SDEFunction{true, typeof(lotka\_volterra!), typeof(multiplicative\_noise!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, typeof(multiplicative\_noise!), Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing}, SOSRI, StochasticDiffEq.LinearInterpolationData{Vector{Vector{Float64}}, Vector{Float64}}, DiffEqBase.DEStats}}}, Float64, Float64, Nothing})(sol::EnsembleSolution{Float64, 3, Vector{RODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, NoiseProcess{Float64, 2, Float64, Vector{Float64}, Vector{Float64}, Vector{Vector{Float64}}, typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_DIST), typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_BRIDGE), true, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, RSWM{Float64}, Nothing, RandomNumbers.Xorshifts.Xoroshiro128Plus}, SDEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, Nothing, SDEFunction{true, var"#71#72", var"#73#74", UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, var"#73#74", Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing}, SRIW1, StochasticDiffEq.LinearInterpolationData{Vector{Vector{Float64}}, Vector{Float64}}, DiffEqBase.DEStats}}})  
@ DiffEqParamEstim C:\Users\User.julia\packages\DiffEqParamEstim\CEtDL\src\cost\_functions.jl:141  
[12] (::DiffEqParamEstim.var"#37#42"{Nothing, Bool, Int64, typeof(DiffEqParamEstim.STANDARD\_PROB\_GENERATOR), Base.Pairs{Symbol, Integer, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:maxiters, :verbose, :num\_monte), Tuple{Int64, Bool, Int64}}}, EnsembleProblem{SDEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, Nothing, SDEFunction{true, var"#71#72", var"#73#74", UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, var"#73#74", Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing}, typeof(SciMLBase.DEFAULT\_PROB\_FUNC), typeof(SciMLBase.DEFAULT\_OUTPUT\_FUNC), typeof(SciMLBase.DEFAULT\_REDUCTION), Nothing}, SRIW1, L2Loss{Vector{Float64}, EnsembleSolution{Float64, 3, Vector{RODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, NoiseProcess{Float64, 2, Float64, Vector{Float64}, Vector{Float64}, Vector{Vector{Float64}}, typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_DIST), typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_BRIDGE), true, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, RSWM{Float64}, Nothing, RandomNumbers.Xorshifts.Xoroshiro128Plus}, SDEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, Nothing, SDEFunction{true, typeof(lotka\_volterra!), typeof(multiplicative\_noise!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, typeof(multiplicative\_noise!), Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing}, SOSRI, StochasticDiffEq.LinearInterpolationData{Vector{Vector{Float64}}, Vector{Float64}}, DiffEqBase.DEStats}}}, Float64, Float64, Nothing}, Nothing, Tuple{}})(p::Vector{Float64})  
@ DiffEqParamEstim C:\Users\User.julia\packages\DiffEqParamEstim\CEtDL\src\build\_loss\_objective.jl:45  
[13] DiffEqObjective  
@ C:\Users\User.julia\packages\DiffEqParamEstim\CEtDL\src\build\_loss\_objective.jl:24 [inlined]  
[14] finite\_difference\_gradient!(df::Vector{Float64}, f::DiffEqObjective{DiffEqParamEstim.var"#37#42"{Nothing, Bool, Int64, typeof(DiffEqParamEstim.STANDARD\_PROB\_GENERATOR), Base.Pairs{Symbol, Integer, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:maxiters, :verbose, :num\_monte), Tuple{Int64, Bool, Int64}}}, EnsembleProblem{SDEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, Nothing, SDEFunction{true, var"#71#72", var"#73#74", UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, var"#73#74", Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing}, typeof(SciMLBase.DEFAULT\_PROB\_FUNC), typeof(SciMLBase.DEFAULT\_OUTPUT\_FUNC), typeof(SciMLBase.DEFAULT\_REDUCTION), Nothing}, SRIW1, L2Loss{Vector{Float64}, EnsembleSolution{Float64, 3, Vector{RODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, NoiseProcess{Float64, 2, Float64, Vector{Float64}, Vector{Float64}, Vector{Vector{Float64}}, typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_DIST), typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_BRIDGE), true, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, RSWM{Float64}, Nothing, RandomNumbers.Xorshifts.Xoroshiro128Plus}, SDEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, Nothing, SDEFunction{true, typeof(lotka\_volterra!), typeof(multiplicative\_noise!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, typeof(multiplicative\_noise!), Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing}, SOSRI, StochasticDiffEq.LinearInterpolationData{Vector{Vector{Float64}}, Vector{Float64}}, DiffEqBase.DEStats}}}, Float64, Float64, Nothing}, Nothing, Tuple{}}, DiffEqParamEstim.var"#41#47"{DiffEqParamEstim.var"#37#42"{Nothing, Bool, Int64, typeof(DiffEqParamEstim.STANDARD\_PROB\_GENERATOR), Base.Pairs{Symbol, Integer, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:maxiters, :verbose, :num\_monte), Tuple{Int64, Bool, Int64}}}, EnsembleProblem{SDEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, Nothing, SDEFunction{true, var"#71#72", var"#73#74", UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, var"#73#74", Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing}, typeof(SciMLBase.DEFAULT\_PROB\_FUNC), typeof(SciMLBase.DEFAULT\_OUTPUT\_FUNC), typeof(SciMLBase.DEFAULT\_REDUCTION), Nothing}, SRIW1, L2Loss{Vector{Float64}, EnsembleSolution{Float64, 3, Vector{RODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, NoiseProcess{Float64, 2, Float64, Vector{Float64}, Vector{Float64}, Vector{Vector{Float64}}, typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_DIST), typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_BRIDGE), true, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, RSWM{Float64}, Nothing, RandomNumbers.Xorshifts.Xoroshiro128Plus}, SDEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, Nothing, SDEFunction{true, typeof(lotka\_volterra!), typeof(multiplicative\_noise!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, typeof(multiplicative\_noise!), Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing}, SOSRI, StochasticDiffEq.LinearInterpolationData{Vector{Vector{Float64}}, Vector{Float64}}, DiffEqBase.DEStats}}}, Float64, Float64, Nothing}, Nothing, Tuple{}}}}, x::Vector{Float64}, cache::FiniteDiff.GradientCache{Nothing, Nothing, Nothing, Vector{Float64}, Val{:central}(), Float64, Val{true}()}; relstep::Float64, absstep::Float64, dir::Bool)  
@ FiniteDiff C:\Users\User.julia\packages\FiniteDiff\KkXlb\src\gradients.jl:273  
[15] finite\_difference\_gradient!  
@ C:\Users\User.julia\packages\FiniteDiff\KkXlb\src\gradients.jl:224 [inlined]  
[16] (::NLSolversBase.var"#g!#15"{DiffEqObjective{DiffEqParamEstim.var"#37#42"{Nothing, Bool, Int64, typeof(DiffEqParamEstim.STANDARD\_PROB\_GENERATOR), Base.Pairs{Symbol, Integer, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:maxiters, :verbose, :num\_monte), Tuple{Int64, Bool, Int64}}}, EnsembleProblem{SDEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, Nothing, SDEFunction{true, var"#71#72", var"#73#74", UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, var"#73#74", Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing}, typeof(SciMLBase.DEFAULT\_PROB\_FUNC), typeof(SciMLBase.DEFAULT\_OUTPUT\_FUNC), typeof(SciMLBase.DEFAULT\_REDUCTION), Nothing}, SRIW1, L2Loss{Vector{Float64}, EnsembleSolution{Float64, 3, Vector{RODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, NoiseProcess{Float64, 2, Float64, Vector{Float64}, Vector{Float64}, Vector{Vector{Float64}}, typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_DIST), typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_BRIDGE), true, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, RSWM{Float64}, Nothing, RandomNumbers.Xorshifts.Xoroshiro128Plus}, SDEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, Nothing, SDEFunction{true, typeof(lotka\_volterra!), typeof(multiplicative\_noise!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, typeof(multiplicative\_noise!), Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing}, SOSRI, StochasticDiffEq.LinearInterpolationData{Vector{Vector{Float64}}, Vector{Float64}}, DiffEqBase.DEStats}}}, Float64, Float64, Nothing}, Nothing, Tuple{}}, DiffEqParamEstim.var"#41#47"{DiffEqParamEstim.var"#37#42"{Nothing, Bool, Int64, typeof(DiffEqParamEstim.STANDARD\_PROB\_GENERATOR), Base.Pairs{Symbol, Integer, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:maxiters, :verbose, :num\_monte), Tuple{Int64, Bool, Int64}}}, EnsembleProblem{SDEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, Nothing, SDEFunction{true, var"#71#72", var"#73#74", UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, var"#73#74", Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing}, typeof(SciMLBase.DEFAULT\_PROB\_FUNC), typeof(SciMLBase.DEFAULT\_OUTPUT\_FUNC), typeof(SciMLBase.DEFAULT\_REDUCTION), Nothing}, SRIW1, L2Loss{Vector{Float64}, EnsembleSolution{Float64, 3, Vector{RODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, NoiseProcess{Float64, 2, Float64, Vector{Float64}, Vector{Float64}, Vector{Vector{Float64}}, typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_DIST), typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_BRIDGE), true, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, RSWM{Float64}, Nothing, RandomNumbers.Xorshifts.Xoroshiro128Plus}, SDEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, Nothing, SDEFunction{true, typeof(lotka\_volterra!), typeof(multiplicative\_noise!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, typeof(multiplicative\_noise!), Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing}, SOSRI, StochasticDiffEq.LinearInterpolationData{Vector{Vector{Float64}}, Vector{Float64}}, DiffEqBase.DEStats}}}, Float64, Float64, Nothing}, Nothing, Tuple{}}}}, FiniteDiff.GradientCache{Nothing, Nothing, Nothing, Vector{Float64}, Val{:central}(), Float64, Val{true}()}})(storage::Vector{Float64}, x::Vector{Float64})  
@ NLSolversBase C:\Users\User.julia\packages\NLSolversBase\cfJrN\src\objective\_types\oncedifferentiable.jl:57  
[17] (::NLSolversBase.var"#fg!#16"{DiffEqObjective{DiffEqParamEstim.var"#37#42"{Nothing, Bool, Int64, typeof(DiffEqParamEstim.STANDARD\_PROB\_GENERATOR), Base.Pairs{Symbol, Integer, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:maxiters, :verbose, :num\_monte), Tuple{Int64, Bool, Int64}}}, EnsembleProblem{SDEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, Nothing, SDEFunction{true, var"#71#72", var"#73#74", UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, var"#73#74", Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing}, typeof(SciMLBase.DEFAULT\_PROB\_FUNC), typeof(SciMLBase.DEFAULT\_OUTPUT\_FUNC), typeof(SciMLBase.DEFAULT\_REDUCTION), Nothing}, SRIW1, L2Loss{Vector{Float64}, EnsembleSolution{Float64, 3, Vector{RODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, NoiseProcess{Float64, 2, Float64, Vector{Float64}, Vector{Float64}, Vector{Vector{Float64}}, typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_DIST), typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_BRIDGE), true, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, RSWM{Float64}, Nothing, RandomNumbers.Xorshifts.Xoroshiro128Plus}, SDEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, Nothing, SDEFunction{true, typeof(lotka\_volterra!), typeof(multiplicative\_noise!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, typeof(multiplicative\_noise!), Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing}, SOSRI, StochasticDiffEq.LinearInterpolationData{Vector{Vector{Float64}}, Vector{Float64}}, DiffEqBase.DEStats}}}, Float64, Float64, Nothing}, Nothing, Tuple{}}, DiffEqParamEstim.var"#41#47"{DiffEqParamEstim.var"#37#42"{Nothing, Bool, Int64, typeof(DiffEqParamEstim.STANDARD\_PROB\_GENERATOR), Base.Pairs{Symbol, Integer, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:maxiters, :verbose, :num\_monte), Tuple{Int64, Bool, Int64}}}, EnsembleProblem{SDEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, Nothing, SDEFunction{true, var"#71#72", var"#73#74", UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, var"#73#74", Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing}, typeof(SciMLBase.DEFAULT\_PROB\_FUNC), typeof(SciMLBase.DEFAULT\_OUTPUT\_FUNC), typeof(SciMLBase.DEFAULT\_REDUCTION), Nothing}, SRIW1, L2Loss{Vector{Float64}, EnsembleSolution{Float64, 3, Vector{RODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, NoiseProcess{Float64, 2, Float64, Vector{Float64}, Vector{Float64}, Vector{Vector{Float64}}, typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_DIST), typeof(DiffEqNoiseProcess.INPLACE\_WHITE\_NOISE\_BRIDGE), true, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, ResettableStacks.ResettableStack{Tuple{Float64, Vector{Float64}, Vector{Float64}}, true}, RSWM{Float64}, Nothing, RandomNumbers.Xorshifts.Xoroshiro128Plus}, SDEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, Nothing, SDEFunction{true, typeof(lotka\_volterra!), typeof(multiplicative\_noise!), UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, typeof(multiplicative\_noise!), Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing}, SOSRI, StochasticDiffEq.LinearInterpolationData{Vector{Vector{Float64}}, Vector{Float64}}, DiffEqBase.DEStats}}}, Float64, Float64, Nothing}, Nothing, Tuple{}}}}})(storage::Vector{Float64}, x::Vector{Float64})  
@ NLSolversBase C:\Users\User.julia\packages\NLSolversBase\cfJrN\src\objective\_types\oncedifferentiable.jl:61  
[18] value\_gradient!!(obj::OnceDifferentiable{Float64, Vector{Float64}, Vector{Float64}}, x::Vector{Float64})  
@ NLSolversBase C:\Users\User.julia\packages\NLSolversBase\cfJrN\src\interface.jl:82  
[19] initial\_state(method::BFGS{LineSearches.InitialStatic{Float64}, LineSearches.HagerZhang{Float64, Base.RefValue{Bool}}, Nothing, Nothing, Optim.Flat}, options::Optim.Options{Float64, Nothing}, d::OnceDifferentiable{Float64, Vector{Float64}, Vector{Float64}}, initial\_x::Vector{Float64})  
@ Optim C:\Users\User.julia\packages\Optim\Zq1jM\src\multivariate\solvers\first\_order\bfgs.jl:94  
[20] optimize  
@ C:\Users\User.julia\packages\Optim\Zq1jM\src\multivariate\optimize\optimize.jl:36 [inlined]  
[21] #optimize#89  
@ C:\Users\User.julia\packages\Optim\Zq1jM\src\multivariate\optimize\interface.jl:142 [inlined]  
[22] optimize(f::Function, initial\_x::Vector{Float64}, method::BFGS{LineSearches.InitialStatic{Float64}, LineSearches.HagerZhang{Float64, Base.RefValue{Bool}}, Nothing, Nothing, Optim.Flat}, options::Optim.Options{Float64, Nothing}) (repeats 2 times)  
@ Optim C:\Users\User.julia\packages\Optim\Zq1jM\src\multivariate\optimize\interface.jl:141  
[23] top-level scope  
@ In[106]:3  
[24] eval  
@ .\boot.jl:373 [inlined]  
[25] include\_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)  
@ Base .\loading.jl:1196

​

---

<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:** [October 12, 2022, 4:16pm UTC](https://discourse.julialang.org/t/getting-issue-in-optim-optimize-function-while-bayesian-estimating-parameters-of-stochastic-differential-equation/88628/2 "2022-10-12T16:16:22Z")

</div>

Let’s solve things one at at time first. You still have: [Getting issue in chain\_sde while doing MCMC inference solution for SDEs](https://discourse.julialang.org/t/getting-issue-in-chain-sde-while-doing-mcmc-inference-solution-for-sdes/88613). That shows your versions are ancient, so any recent documentation will of course fail. Please share your `]st` on Julia v1.8.
