DifferentialEquations and Parameter Estimation with Indicator Variables

Hi I am new to Julia, sorry for this basic question, I am doing some
parameter fitting, and would like to use a binary indicator variable (0/1)
to differentiate groups from my data. I have the following code:

     f_Eprod = @ode_def Eprod begin
         dE = p1*exp(t*(p2+p2d*Ind_Var))
     end p1 p2 p2d Ind_Var

    p=[20,-0.02,0.005,1.0]
    prob = ODEProblem(f_Eprod,[0.0],[0.0,7],p)
    sol=solve(prob)

Below I substitute the value of 1 in the parameter array by IndVar[i] to account for
grouping in the data. This array contains 0 and 1’s.

   function prob_func(prob,i,repeat)
     ODEProblem(prob.f,initial_conditions[i],tspan[i],[20,-0.02,0.005,IndVar[i],saveat=tspan[i][2])
   end

   monte_prob = MonteCarloProblem(prob,prob_func=prob_func)

After setting a loss function, I am not sure how to set Optim.optimizer to avoid having Ind_Var being treated as a parameter to be optimized. Is there a way to handle this prior to the optimization? Thank you.

You’d make a loss function of 3 variables and in the loss function append IndVar and solve.

Hi Chris, thank you for your answer, I am a bit lost on how to implement this loss function you mention, would you provide some hints or point me to an example. Thank you in advance for any help.

(p)->f([p;IndVar])

Thank you