# DataDrivenDiffEq.jl for estimating DAE system of equations from data

**URL:** <https://discourse.julialang.org/t/datadrivendiffeq-jl-for-estimating-dae-system-of-equations-from-data/72672>\
**Category:** New to Julia\
**Tags:** package, diffeq, sciml\
**Created:** [December 6, 2021, 6:30pm UTC](https://discourse.julialang.org/t/datadrivendiffeq-jl-for-estimating-dae-system-of-equations-from-data/72672 "2021-12-06T18:30:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jisnajohnson27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jisnajohnson27/32/30186_2.png) [@jisnajohnson27](https://discourse.julialang.org/u/jisnajohnson27)\
**Post date:** [December 6, 2021, 6:30pm UTC](https://discourse.julialang.org/t/datadrivendiffeq-jl-for-estimating-dae-system-of-equations-from-data/72672/1 "2021-12-06T18:30:52Z")

</div>

I have been experimenting DataDrivenDiffEq.jl for retrieval of system of differential equations from a dataset( where data is generated by solving that differential equation system). But unlike ODESystem, I find it cumbersome to estimate DAESystem of equations from underlying data.

I have a simple classical case of index 1 DAE - Roberts Equation , whose solution data is used to retrieve corresponding DAESystem, which gives wrong estimates . Here is the code for the same.

```julia
using DataDrivenDiffEq
using ModelingToolkit
using OrdinaryDiffEq
using LinearAlgebra , DifferentialEquations

function f(du, u, p, t)
    du[1] = -p[1]*u[1] + p[2]*u[2]*u[3]
    du[2] = p[1]*u[1] - p[2]*u[2]*u[3] - p[3]*u[2]*u[2]
    du[3] = u[1] + u[2] + u[3] - 1.
end
M = [1 0 0; 0 1 0; 0 0 0.]
p = [0.04, 10^4, 3e7]
u0 = [1.,0.,0.]
tspan = (0., 1e6)
prob = ODEProblem(ODEFunction(f, mass_matrix = M), u0, tspan, p)
sol1 = solve(prob,saveat=10.0, Rodas5())

ddprob = ContinuousDataDrivenProblem(sol1)
@variables t x(t) y(t) 
u = [x;y]

basis = Basis(polynomial_basis(u,3), u, iv = t)
opt = STLSQ()
ddsol = solve(ddprob,DMDSVD(), normalize = true)
print(ddsol, Val{true})

```

Is there a way to retreive original DAESystem providing appropriate basis in this case?  
Thanking 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:** [December 7, 2021, 5:49am UTC](https://discourse.julialang.org/t/datadrivendiffeq-jl-for-estimating-dae-system-of-equations-from-data/72672/2 "2021-12-07T05:49:33Z")

</div>

Did you try the implicit SINDy? The mass matrix form will be much more stable.
