Pumas Model fitting: Error

Greetings,

I Am getting the following error with fitting with FOCEI. Kindly explain the error and give the solution how to resolve the same.

Warning: Terminated early due to NaN in gradient.
└ @ Optim /build/_work/PumasSystemImages/PumasSystemImages/julia_depot/packages/Optim/V8ZEC/src/multivariate/optimize/optimize.jl:98
ERROR: cannot assign a value to imported variable StatsAPI.fit from module Main

Can you please post your model and how you are calling the fit function?

Model:

clopi = @model begin
@param begin
tvka ∈ RealDomain(lower = 0.0001)
tvvc ∈ RealDomain(lower = 0.0001)
tvcl ∈ RealDomain(lower=0.0001 )
Ω ∈ PDiagDomain(3)
σ²_add ∈ RealDomain(lower=0.0001)
σ²_prop ∈ RealDomain(lower=0.0001)
end
@random begin
η ~ MvNormal(Ω)
end
@pre begin
Ka = tvka* exp(η[1])
Vc = tvvc * exp(η[2])
CL = tvcl*exp(η[3])
end

@dynamics  Depots1Central1     


@derived begin
  CONC = @. Central/Vc
 
  DV ~ @. Normal(CONC, sqrt(((abs(CONC)^2)*σ²_prop) + σ²_add))
end

end

params = (tvcl = 0.1, tvvc = 0.1,tvka=0.1,σ²_add=0.1,σ²_prop=0.1, Ω = Diagonal([0.20,0.20,0.20]))
data = CSV. read(joinpath(“/home/jrun/data/code/aswathy/Clopidogrel.csv”), DataFrame, missingstrings = [“”, “.”, “NA”, “BQL”])
pop = read_pumas(data; observations=Symbol[:DV],
id=:ID, time=:TIME, evid=:EVID, amt=:AMT,
cmt=:CMT, event_data=true)

fit = fit(clopi,
pop,
params,
Pumas.FOCE(), ensemblealg = EnsembleThreads(),
)

Hi,

The warning is not necessary a problem. The optimiser just got inte a bad place of the parameter space and often finds its way out of there just fine. The problem here is that you’re trying to overwrite the fit function with the fit result when you call fit = fit(.....). Try simply using a different name to assign the fit output to.

Hope that helps!
/Niklas

2 Likes

Problem has been resolved.
Thanks for the help

But can you give a detailed explanation, why it happens?

Thanks in advance.