# How to fit ODE system only on one @variables

Hello,
I have a small system of 2 differential equations whose `@variables` are `N1` and `N2`, with 3 `@parameters` `a, b, c`. I have evolution data (experimental measurements) for the variable `N1` only, named (time, data).
I would like to use `DiffEqParamEstim.jl` to fit my model on my data and to estimate the optimal `a,b,c` parameters.
How can I change the following cost function (and in particular the L2Loss I think) to fit the data only on `N1` and not on `N2` ?

``````cost_function = build_loss_objective(prob, Tsit5(), L2Loss(time, data),
Optimization.AutoForwardDiff(),
maxiters=10000,verbose=false)

optprob = Optimization.OptimizationProblem(cost_function, [0.0005, 0.009, 0.09])
result_bfgs = solve(optprob, BFGS())
``````

Tanks !
fdekerm

For instance, the `DiffEqParamEstim.jl` documentation give example of fit with synthetic data generated from the ODE system, so there is data for all `@variables`.

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

Let me up the discussion one last time. It’s probably not very complicated (maybe even trivial), but I really don’t see how to do it. I’d like to avoid having to do a loss function “by hand”, but maybe it’s necessary.

2 Likes