ERROR: MethodError: no method matching *(::ForwardDiff.Dual{ForwardDiff.Tag{Pumas.Tag, Float64}, Float64, 6}, ::typeof(time))

During the pharmacodynamic data run (in vitro test with constant concentrations) this error appeared and I cannot identify what could have happened. Can someone help me ?

model = @model begin

@param begin
    tvk ∈ RealDomain(lower=0, init=0.111)         
    tvEmax ∈ RealDomain(lower=0, init=0.784)      
    tvEC50 ∈ RealDomain(lower=0, init=1.88)       
    tvalpha ∈ RealDomain(lower=0, init=0.748)     
    tvhill ∈ RealDomain(lower=0, init=4.0)
    tvNmax ∈ RealDomain(lower=0, init=7.66)
    Ω ∈ PDiagDomain(6)                       
    σ ∈ RealDomain(lower=0, init=0.271)                 
end

@random begin                                      
    η  ~ MvNormal(Ω)                    
end

@pre begin
    k = tvk * exp(η[1])
    Emax = tvEmax * exp(η[2])
    EC50 = tvEC50 * exp(η[3])
    alpha = tvalpha * exp(η[4])
    hill = tvhill * exp(η[5])
    Nmax = tvNmax * exp(η[6])
    N0 = 4.026814
    conc = 1
    EF = Emax * (conc^(hill)) / (EC50^hill) + (conc^hill)
    delay = 1 - exp(-alpha*time)
end
  
@dynamics begin
    efeito' = (k * Nmax * delay - EF) * N0
end

@derived begin
    N ~ @. Normal(N, sqrt(σ))
end

end

init_parameters = (;
tvk = 0.111,
tvEmax = 0.784,
tvEC50 = 1.88,
tvalpha = 0.748,
tvhill = 4.0,
tvNmax = 7.66,
Ω = Diagonal([0.01,0.01,0.01,0.01,0.01,0.01]),
σ = 0.271,
)

fit_model = fit(model, pdpop, init_parameters, FOCE())

ERROR: MethodError: no method matching *(::ForwardDiff.Dual{ForwardDiff.Tag{Pumas.Tag, Float64}, Float64, 6}, ::typeof(time))

It looks like you never defined time, so Julia thinks it refers to the function Base.time that has type typeof(time). It doesn’t know how to multiply (*) a number (wrapped in a ForwardDiff.Dual for automatic differentiation) by this function, so you get the error you see.

You didn’t say what package you were using for all these model definition macros, but in any case I’m not familiar with it so can’t provide further guidance. Further, macros can do a lot so there’s some chance my answer is totally off-base.

This time should just be t.