Error while using predict function

Hi,
for a data when I try using a specific model to predict I get the following error. the predict function runs but gives and error when I am trying to convert it into a dataframe.


I checked the rows it had mentioned but was unable to find any missing values. Can anyone tell me what is going wrong.

Could you please let us know which version of Pumas that you are using and where you are running Pumas?

This should probably be 2.2.1 from Juliahub.com

Yes, I have been using this version from Juliahub

Sorry for this inconvenience, we have identified the issue. I have a solution for you below that you can use until the issue is resolved in a future version of Pumas.

using Pumas
sub1 = Subject(id = 1, events = DosageRegimen(100, rate = 100), time = 0.0:0.25:4)
sub2 = Subject(id = 2, time = 0.0:0.25:4)
mdlminimal = @model begin
@pre begin
  CL = 0.8
  Vc = 1.1
end
@dynamics Central1
@derived begin
  μ := @. Central / Vc
  y ~ @. Normal(μ, 0.1)
end
end
sim_sub = Subject.(simobs(mdlminimal, [sub1, sub2], (;)))

df_simobs = DataFrame(sim_sub)

df_pred = DataFrame(predict(mdlminimal, sim_sub, (;)))

This gives the same issue as you showed.

julia> df_pred = DataFrame(predict(mdlminimal, sim_sub, (;)))
ERROR: ArgumentError: column(s) amt, cmt, rate, duration, ss, ii, route and tad are missing from argument(s) 2
Stacktrace:
 [1] _vcat(dfs::Vector{AbstractDataFrame}; cols::Symbol)
   @ DataFrames ~/.julia/packages/DataFrames/JZ7x5/src/abstractdataframe/abstractdataframe.jl:1841
 [2] #reduce#130
   @ ~/.julia/packages/DataFrames/JZ7x5/src/abstractdataframe/abstractdataframe.jl:1761 [inlined]
 [3] reduce(::typeof(vcat), dfs::Vector{DataFrame})
   @ DataFrames ~/.julia/packages/DataFrames/JZ7x5/src/abstractdataframe/abstractdataframe.jl:1761
 [4] DataFrame(vpred::Vector{Pumas.SubjectPrediction{NamedTuple{(:y,), Tuple{Vector{Float64}}}, NamedTuple{(:y,), Tuple{Vector{Float64}}}, Nothing}}; include_covariates::Bool, include_observations::Bool, include_events::Bool)
   @ Pumas ~/.julia/dev/Pumas/src/estimation/diagnostics.jl:312
 [5] DataFrame(vpred::Vector{Pumas.SubjectPrediction{NamedTuple{(:y,), Tuple{Vector{Float64}}}, NamedTuple{(:y,), Tuple{Vector{Float64}}}, Nothing}})
   @ Pumas ~/.julia/dev/Pumas/src/estimation/diagnostics.jl:312
 [6] top-level scope
   @ REPL[26]:1

What I could do to work around this in my case is

mdl_pred = predict(mdlminimal, sim_sub, (;))
df_pred = reduce(vcat, DataFrame.(mdl_pred); cols=:union)

I am using DataFrame on the individual predictions and vertical concatenation (vcat) with the cols=:union keyword. You should similarly be able to write

df_pred = reduce(vcat, DataFrame.(Kartaza_pred); cols=:union)

Hope this helps.

1 Like

It works!! Thank you