Parameter Estimation using Least Squares with missing data

I am trying to estimate 4 parameters for an ode that outputs as solution 4 values at any given time point. I have actual data for 2 of those values. I would like to preform parameter estimation using the available incomplete data. I have implemented it on Turing but would also like to use Least Squares for comparison, but I always get “Dimension Inconsistency” errors because the actual data is 2x120 long and the solution from the ode problem is 4x120.

So is there a way to use Least Sqaures with missing data or is there a way I can get the ODEProblem to only return the solution of the 2 values that I actually need?

Check out this example
https://diffeqflux.sciml.ai/dev/examples/optimization_ode/

You can modify the loss function

function loss(p)
  sol = solve(prob, Tsit5(), p=p, saveat = tsteps)
  loss = sum(abs2, sol.-1)
  return loss, sol
end

to calculate the distance between the states you have data for and the data.

Use save_idxs or just index to match your dataset.