# DataDriven Approach for recovering DAE system of governing equations

**URL:** <https://discourse.julialang.org/t/datadriven-approach-for-recovering-dae-system-of-governing-equations/88822>\
**Category:** New to Julia\
**Tags:** package, diffeq, data, regression, sparse\
**Created:** [October 17, 2022, 5:41am UTC](https://discourse.julialang.org/t/datadriven-approach-for-recovering-dae-system-of-governing-equations/88822 "2022-10-17T05:41:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CurioMath](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/curiomath/32/43603_2.png) [@CurioMath](https://discourse.julialang.org/u/CurioMath)\
**Post date:** [October 17, 2022, 5:41am UTC](https://discourse.julialang.org/t/datadriven-approach-for-recovering-dae-system-of-governing-equations/88822/1 "2022-10-17T05:41:24Z")

</div>

Can I know if data driven recovery of governing equations that can be a DAE system is possible with DMD or SINDy approach in DataDrivenDiffEq.jl? I have referred the examples in the documentation of DataDrivenDiffEq.jl but but couldn’t find any on DAE. Any possible help is appreciated…

Thanks in advance…

---

<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 17, 2022, 6:08am UTC](https://discourse.julialang.org/t/datadriven-approach-for-recovering-dae-system-of-governing-equations/88822/2 "2022-10-17T06:08:28Z")

</div>

The iSINDy (implicit SINDy) method can do it.

[https://datadriven.sciml.ai/dev/examples/6\_autoregulation/](https://datadriven.sciml.ai/dev/examples/6_autoregulation/)

---

<div class="post-metadata">

**Author:** ![CurioMath](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/curiomath/32/43603_2.png) [@CurioMath](https://discourse.julialang.org/u/CurioMath)\
**Post date:** [October 17, 2022, 10:50am UTC](https://discourse.julialang.org/t/datadriven-approach-for-recovering-dae-system-of-governing-equations/88822/3 "2022-10-17T10:50:04Z")

</div>

Thankyou Chris.

Yeah… I do look into it. But the code given in the documentation isn’t working fine with me. The trouble is with trying to create a simulation model with the obtained result. These are the package specifications I use.

Julia 1.7.1  
DataDrivenDiffEq v0.8.5  
DifferentialEquations v7.5.0  
Interpolations v0.14.6  
ModelingToolkit v8.27.0  
Plots v1.35.3

Below is the code and corresponding error message I received.

```julia
using DataDrivenDiffEq
using LinearAlgebra
using ModelingToolkit
using OrdinaryDiffEq

function slow_manifold(du, u, p, t)
    du[1] = p[1] * u[1]
    du[2] = p[2] * (u[2] - u[1]^2)
end

u0 = [3.0; -2.0]
tspan = (0.0, 5.0)
p = [-0.8; -0.7]

problem = ODEProblem(slow_manifold, u0, tspan, p)
solution = solve(problem, Tsit5(), saveat = 0.01);

prob = ContinuousDataDrivenProblem(solution)

@parameters t
@variables u[1:2](t)
Ψ = Basis([u; u[1]^2], u, independent_variable = t)
res = solve(prob, Ψ, DMDPINV(), digits = 1)
system = result(res)

sparse_res = solve(prob, Ψ, STLSQ(), digits = 1)

sparse_system = result(sparse_res)

parameter_map(res)

parameter_map(sparse_res)

@named sys = ODESystem(
    equations(sparse_system),
    get_iv(sparse_system),
    states(sparse_system),
    parameters(sparse_system)
    );

```

```julia
ArgumentError: p₁ is not a parameter.

Stacktrace:
 [1] check_parameters(ps::Vector{Sym{Real, Base.ImmutableDict{DataType, Any}}}, iv::Sym{Real, Base.ImmutableDict{DataType, Any}})
   @ ModelingToolkit C:\Users\Jisna\.julia\packages\ModelingToolkit\2nkY8\src\utils.jl:135
 [2] ODESystem(tag::UInt64, deqs::Vector{Equation}, iv::Sym{Real, Base.ImmutableDict{DataType, Any}}, dvs::Vector{Term{Real, Base.ImmutableDict{DataType, Any}}}, ps::Vector{Sym{Real, Base.ImmutableDict{DataType, Any}}}, var_to_name::Dict{Any, Any}, ctrls::Vector{Any}, observed::Vector{Equation}, tgrad::Base.RefValue{Vector{Num}}, jac::Base.RefValue{Any}, ctrl_jac::Base.RefValue{Any}, Wfact::Base.RefValue{Matrix{Num}}, Wfact_t::Base.RefValue{Matrix{Num}}, name::Symbol, systems::Vector{ODESystem}, defaults::Dict{Any, Any}, torn_matching::Nothing, connector_type::Nothing, preface::Nothing, cevents::Vector{ModelingToolkit.SymbolicContinuousCallback}, devents::Vector{ModelingToolkit.SymbolicDiscreteCallback}, metadata::Nothing, tearing_state::Nothing, substitutions::Nothing, complete::Bool; checks::Bool)
   @ ModelingToolkit C:\Users\Jisna\.julia\packages\ModelingToolkit\2nkY8\src\systems\diffeqs\odesystem.jl:136
 [3] ODESystem(deqs::Vector{Equation}, iv::Num, dvs::Vector{Num}, ps::Vector{Sym{Real, Base.ImmutableDict{DataType, Any}}}; controls::Vector{Num}, observed::Vector{Equation}, systems::Vector{ODESystem}, name::Symbol, default_u0::Dict{Any, Any}, default_p::Dict{Any, Any}, defaults::Dict{Any, Any}, connector_type::Nothing, preface::Nothing, continuous_events::Nothing, discrete_events::Nothing, checks::Bool, metadata::Nothing)
   @ ModelingToolkit C:\Users\Jisna\.julia\packages\ModelingToolkit\2nkY8\src\systems\diffeqs\odesystem.jl:197
 [4] top-level scope
   @ C:\Users\Jisna\.julia\packages\ModelingToolkit\2nkY8\src\systems\abstractsystem.jl:866

```

---

<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 22, 2022, 9:05am UTC](https://discourse.julialang.org/t/datadriven-approach-for-recovering-dae-system-of-governing-equations/88822/4 "2022-10-22T09:05:55Z")

</div>

Open an issue
