SAEM in Pumas: ERROR: TaskFailedException

Hi, guys

I’m trying to use SAEM to evaluate my pre-clinical data. I tried to do my analysis using FOCE, but it did not work. I thought it might be because of the high variability in my profiles and the small number of samples.

So, I used this valuable topic of discussion as a reference to adapt my model (SAEM algorithm parameters - #8 by bobbrown) beyond the standard documentation of the Pumas of course.

I’m working with the following code:

mdl_2cmp_prop_saem = @ emmodel begin
@ param begin
tvcl ~ 1 | LogNormal #when FC == 1
tvv ~ 1 | LogNormal
tvq ~ 1 | LogNormal
tvvp ~ 1 | LogNormal
beta_Cl_FC_2 ~ 1 | Normal # when FC == 2
beta_V1_FC_2 ~ 1 | Normal
beta_Q_FC_2 ~ 1 | Normal
end

@ random begin # Previously I found IVV only in Cl, Vc, and Q, but not in Vp (Monolix)
η1 ~ 1 | Normal
η2 ~ 1 | Normal
η3 ~ 1 | Normal 
end

@ covariance (3)
@ covariates FC
@ pre begin #here I'm evaluating my categorical COV (1 or 2, where 1 is the standard)
CL = tvcl *  beta_Cl_FC_2 * (FC ==2)* exp(η1)
Vc = tvv *  beta_V1_FC_2 * (FC ==2)* exp(η2)
Q = tvq * beta_Q_FC_2 * (FC ==2)* exp(η3)
 Vp = tvvp
end

@dynamics 
#Central1Periph1  - I've tried using it as a library but it was the same
    Central'    = -(CL+Q)/Vc*Central + Q/Vp*Peripheral
    Peripheral' = Q/Vc*Central - Q/Vp*Peripheral

@post begin
  cp = @. Central / Vc
end

@error begin
  DV ~ Normal(cp)
end

end

params_2cmp_prop_saem = (
tvcl = 7119.54,
tvv = 1795.2,
tvq = 3471.5,
Ω = (0.1, 0.1, 0.1),
tvvp =7124.9,
σ = 1,
η1 = 0.1,
η2 = 0.1,
η3 = 0.1,
beta_Cl_FC_2 = 1,
beta_V1_FC_2 = 1,
beta_Q_FC_2 = 1,
)

SAEM_fit = fit(mdl_2cmp_prop_saem, pop1, params_2cmp_prop_saem, Pumas.SAEM())

And after countless attempts at correction, I have this error:

ERROR: TaskFailedException

nested task error: UndefVarError: `Central` not defined
Stacktrace:
  [1] macro expansion
    @ c:\Users\Ana\.julia\Curcumina\popPK IV\popPK iv 2cpt_monolix to pumas.jl:274 [inlined]
  [2] (::var"#18#20")(t::Float64, param::NamedTuple{(:tvcl, :tvv, :tvq, :tvvp, :beta_Cl_FC_2, :beta_V1_FC_2, :beta_Q_FC_2, :η1, :η2, :η3, :FC, :CL, :Vc, :Q, :Vp), Tuple{Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Int64, Vararg{Float64, 4}}})
    @ Main C:\a\PumasSystemImages\PumasSystemImages\julia_depot\packages\Pumas\Zl9W3\src\dsl\emmodel_macro.jl:38
  [3] _calc_expectations_loop!

I would appreciate it if you could suggest something!