Estimate parameters of a Delay Differential Equation

Hi!
I am new to Julia and I’m trying to fit my data to a DDE, but have a problem with optimize(). It is not recognized, here is my code, and the error.
I would appreciate if anyone could provide a toy example for how to estimate parameters of a DDE.

Thank you!

############### The error ####################

Inappropriate solve command. The arguments do not make sense. Likely, you gave an algorithm which does not actually exist (or does not <:DiffEqBase.DEAlgorithm)

Stacktrace:
[1] error(::String) at .\error.jl:33
[2] #__solve#1(::Bool, ::Base.Iterators.Pairs{Symbol,Int64,Tuple{Symbol},NamedTuple{(:maxiters,),Tuple{Int64}}}, ::Function, ::DDEProblem{Array{Float64,1},Tuple{Float64,Float64},Array{Float64,1},Array{Any,1},true,Array{Float64,1},DDEFunction{true,typeof(pg2),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(h),Nothing}, ::LinRange{Float64}) at C:\Users\farna.julia\packages\DifferentialEquations\SubON\src\default_solve.jl:3
[3] (::getfield(DiffEqBase, Symbol("#kw##__solve")))(::NamedTuple{(:maxiters,),Tuple{Int64}}, ::typeof(DiffEqBase.__solve), ::DDEProblem{Array{Float64,1},Tuple{Float64,Float64},Array{Float64,1},Array{Any,1},true,Array{Float64,1},DDEFunction{true,typeof(pg2),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(h),Nothing}, ::LinRange{Float64}) at .\none:0
[4] #solve#456(::Base.Iterators.Pairs{Symbol,Int64,Tuple{Symbol},NamedTuple{(:maxiters,),Tuple{Int64}}}, ::Function, ::DDEProblem{Array{Float64,1},Tuple{Float64,Float64},Array{Float64,1},Array{Any,1},true,Array{Float64,1},DDEFunction{true,typeof(pg2),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(h),Nothing}, ::LinRange{Float64}) at C:\Users\farna.julia\packages\DiffEqBase\6ewdP\src\solve.jl:41
[5] (::getfield(DiffEqBase, Symbol("#kw##solve")))(::NamedTuple{(:maxiters,),Tuple{Int64}}, ::typeof(solve), ::DDEProblem{Array{Float64,1},Tuple{Float64,Float64},Array{Float64,1},Array{Any,1},true,Array{Float64,1},DDEFunction{true,typeof(pg2),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(h),Nothing}, ::LinRange{Float64}) at .\none:0
[6] (::getfield(DiffEqParamEstim, Symbol("##29#34")){Nothing,Bool,Int64,typeof(DiffEqParamEstim.STANDARD_PROB_GENERATOR),Base.Iterators.Pairs{Symbol,Int64,Tuple{Symbol},NamedTuple{(:maxiters,),Tuple{Int64}}},DDEProblem{Array{Float64,1},Tuple{Float64,Float64},Array{Float64,1},Array{Any,1},true,Nothing,DDEFunction{true,typeof(pg2),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(h),Nothing},LinRange{Float64},DataFrames.DataFrame,Tsit5})(::Array{Float64,1}) at C:\Users\farna.julia\packages\DiffEqParamEstim\mNjO8\src\build_loss_objective.jl:42
[7] (::DiffEqObjective{getfield(DiffEqParamEstim, Symbol("##29#34")){Nothing,Bool,Int64,typeof(DiffEqParamEstim.STANDARD_PROB_GENERATOR),Base.Iterators.Pairs{Symbol,Int64,Tuple{Symbol},NamedTuple{(:maxiters,),Tuple{Int64}}},DDEProblem{Array{Float64,1},Tuple{Float64,Float64},Array{Float64,1},Array{Any,1},true,Nothing,DDEFunction{true,typeof(pg2),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(h),Nothing},LinRange{Float64},DataFrames.DataFrame,Tsit5},getfield(DiffEqParamEstim, Symbol("##33#39"))})(::Array{Float64,1}) at C:\Users\farna.julia\packages\DiffEqParamEstim\mNjO8\src\build_loss_objective.jl:24
[8] #optimize#8(::Symbol, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::DiffEqObjective{getfield(DiffEqParamEstim, Symbol("##29#34")){Nothing,Bool,Int64,typeof(DiffEqParamEstim.STANDARD_PROB_GENERATOR),Base.Iterators.Pairs{Symbol,Int64,Tuple{Symbol},NamedTuple{(:maxiters,),Tuple{Int64}}},DDEProblem{Array{Float64,1},Tuple{Float64,Float64},Array{Float64,1},Array{Any,1},true,Nothing,DDEFunction{true,typeof(pg2),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},typeof(h),Nothing},LinRange{Float64},DataFrames.DataFrame,Tsit5},getfield(DiffEqParamEstim, Symbol("##33#39"))}, ::Array{Float64,1}, ::Dogleg{LeastSquaresOptim.QR}) at C:\Users\farna.julia\packages\LeastSquaresOptim\Wvhro\src\types.jl:141
[9] optimize(::Function, ::Array{Float64,1}, ::Dogleg{LeastSquaresOptim.QR}) at C:\Users\farna.julia\packages\LeastSquaresOptim\Wvhro\src\types.jl:141
[10] top-level scope at In[15]:30

You gave an ODE solver method to a DDEProblem. You need to give a method for DDEs to solve a DDEProblem. For example, MethodOfSteps(Tsit5()).

Thank you for your reply,
Could you please elaborate on how to use it?
like sol = solve(prob, Tsit5()) and I have to pass the solution to the MethodOfSteps? What package has to be installed for MethodOfSteps? I searched and read the documentation page of it, but I still couldn’t find.

Thank you,

sol = solve(prob, MethodOfSteps(Tsit5())). See http://docs.juliadiffeq.org/latest/tutorials/dde_example.html

Thank you

Hello,
I am trying to estimate parameters of a DDE, when I call optimize(), 90/100 times it throws this error:

Constant lags and time direction do not match. Exiting.

I am also estimating constant delays here. Changed initial guesses many times, just works sometimes and I haven’t figured out what the problem is, or what the time direction means. Could anyone help me with this?
Thanks,

If you’re estimating the delay h(t-tau), and tau goes negative, then this can be thrown. So you’d need to make sure that the optimizer keeps values positive that you expect to be positive.

1 Like