Error with vpc() function

Hello I am trying to run the vpc function but I am getting the following error

julia> ufh_vpc = vpc(modfit, 500; observations = [:CONC],
                    ensemblealg=EnsembleThreads(), prediction_correction = true)
[ Info: Continuous VPC
ERROR: MethodError: Cannot `convert` an object of type Missing to an object of type Float64
Closest candidates are:
  convert(::Type{T}, ::Static.StaticFloat64{N}) where {N, T<:AbstractFloat} at /builds/PumasAI/PumasSystemImages-jl/.julia/packages/Static/pkxBE/src/float.jl:26
  convert(::Type{T}, ::LLVM.GenericValue, ::LLVM.LLVMType) where T<:AbstractFloat at /builds/PumasAI/PumasSystemImages-jl/.julia/packages/LLVM/WjSQG/src/execution.jl:39
  convert(::Type{T}, ::LLVM.ConstantFP) where T<:AbstractFloat at /builds/PumasAI/PumasSystemImages-jl/.julia/packages/LLVM/WjSQG/src/core/value/constant.jl:111
  ...
Stacktrace:
  [1] setindex!(A::Vector{Float64}, x::Missing, i1::Int64)
    @ Base ./array.jl:903
  [2] DataFrame(subject::Subject{NamedTuple{(:CONC,), Tuple{Vector{Union{Missing, Float64}}}}, Pumas.ConstantInterpolationStructArray{Vector{Float64}, NamedTuple{(:logwt, :AGE_GROUP, :logecmo, :WT, :AGE_D, :ISMALE, :SCR, :GFR, :AGEYRS, :TYPE_MODELING, :IS_BLEEDING, :IS_CIRCUIT_CHANGE, :ECMO_DAYS, :Occassions, :IS_CIRCUIT_CHANGE_UPDATE, :IS_BLEEDING_UPDATE), Tuple{Vector{Float64}, Vector{String31}, Vector{Float64}, Vector{Float64}, Vector{Int64}, Vector{Int64}, Vector{Float64}, Vector{Int64}, Vector{Float64}, Vector{Int64}, Vector{Int64}, Vector{Int64}, Vector{Int64}, Vector{Int64}, Vector{Int64}, Vector{Int64}}}, Symbol}, Vector{Pumas.Event{Float64, Float64, Float64, Float64, Float64, Float64, Int64}}, Vector{Float64}}; include_covariates::Bool, include_observations::Bool, include_events::Bool, extra_time::Vector{Float64})
    @ Pumas /builds/PumasAI/PumasSystemImages-jl/.julia/packages/Pumas/MxXdQ/src/data_parsing/io.jl:1180

Any idea why I am getting this error ?

Thanks

Unfortunately, it’s the same bug as Error with DataFrame function when using output from predict function since the vpc function is hitting that method. I’ll try to see if there is a workaround. In any case, this will be fixed in the upcoming release.

1 Like

Hello, I’m getting the same error when trying read_nca using data i got from the predict function. Would that be the same bug here?
Thank you.

Can you share the full error message please and the code you ran.

julia> pop = read_nca(dfNCA,
                       id      = :id,
                       ii      = :ii,
                       ss      = :ss,
                       time    = :time,
                       observations = :Cparent_ipred,
                       amt          = :amt,
                       route        = :route,
                       group         = [:id, :DOSE_N] )
ERROR: MethodError: Cannot `convert` an object of type Missing to an object of type Float64
Closest candidates are:
  convert(::Type{T}, ::ColorTypes.Gray24) where T<:Real at /build/_work/PumasSystemImages/PumasSystemImages/julia_depot/packages/ColorTypes/1dGw6/src/conversions.jl:114
  convert(::Type{T}, ::ColorTypes.Gray) where T<:Real at /build/_work/PumasSystemImages/PumasSystemImages/julia_depot/packages/ColorTypes/1dGw6/src/conversions.jl:113
  convert(::Type{T}, ::Gain) where T<:Real at /build/_work/PumasSystemImages/PumasSystemImages/julia_depot/packages/Unitful/ApCuY/src/logarithm.jl:62
  ...
Stacktrace:
  [1] NCADose(time::Float64, amt::Float64, duration::Missing, route::NCA.Route, ii::Int64, ss::Bool)
    @ NCA /build/_work/PumasSystemImages/PumasSystemImages/julia_depot/packages/NCA/CDayS/src/type.jl:37
  [2] _broadcast_getindex_evalf
    @ ./broadcast.jl:670 [inlined]
  [3] _broadcast_getindex
    @ ./broadcast.jl:643 [inlined]
  [4] getindex
    @ ./broadcast.jl:597 [inlined]
  [5] copy
    @ ./broadcast.jl:875 [inlined]
  [6] materialize(bc::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{0}, Nothing, Type{NCADose}, Tuple{Float64, Float64, Base.RefValue{Missing}, Base.RefValue{NCA.Route}, Int64, Bool}})
    @ Base.Broadcast ./broadcast.jl:860
  [7] (::NCA.var"#292#303"{Nothing, Symbol, Symbol, Symbol, Symbol, Vector{Pair{String, String}}, Bool, Bool, Bool, Bool, Bool, Nothing, Nothing, Nothing, Nothing, Vector{Union{Missing, Float64}}, Vector{Union{Missing, Int64}}, Vector{Int64}, Bool})(::Tuple{Int64, String})
    @ NCA /build/_work/PumasSystemImages/PumasSystemImages/julia_depot/packages/NCA/CDayS/src/data_parsing.jl:287
  [8] iterate
    @ ./generator.jl:47 [inlined]
  [9] collect(itr::Base.Generator{Base.Iterators.Enumerate{Vector{String}}, NCA.var"#292#303"{Nothing, Symbol, Symbol, Symbol, Symbol, Vector{Pair{String, String}}, Bool, Bool, Bool, Bool, Bool, Nothing, Nothing, Nothing, Nothing, Vector{Union{Missing, Float64}}, Vector{Union{Missing, Int64}}, Vector{Int64}, Bool}})
    @ Base ./array.jl:724
 [10] map(f::Function, A::Base.Iterators.Enumerate{Vector{String}})
    @ Base ./abstractarray.jl:2896
 [11] ___read_nca(df::DataFrame; id::Symbol, time::Symbol, observations::Symbol, nominal_time::Symbol, start_time::Symbol, end_time::Symbol, volume::Symbol, amt::Symbol, route::Symbol, duration::Symbol, blq::Symbol, ii::Symbol, ss::Symbol, group::Vector{Pair{String, String}}, concu::Bool, timeu::Bool, amtu::Bool, volumeu::Bool, verbose::Bool, sparse::Bool, lambdazidxs::Nothing, lambdazslopetimes::Nothing, concblq::Nothing, llq::Nothing, missingconc::Nothing, missingvolume::Nothing)
    @ NCA /build/_work/PumasSystemImages/PumasSystemImages/julia_depot/packages/NCA/CDayS/src/data_parsing.jl:230
 [12] (::NCA.var"#284#286"{Vector{Symbol}, Base.Pairs{Symbol, Symbol, NTuple{7, Symbol}, NamedTuple{(:id, :ii, :ss, :time, :observations, :amt, :route), NTuple{7, Symbol}}}})(df::SubDataFrame{DataFrame, DataFrames.Index, Vector{Int64}})
    @ NCA /build/_work/PumasSystemImages/PumasSystemImages/julia_depot/packages/NCA/CDayS/src/data_parsing.jl:68
 [13] mapreduce_impl(f::NCA.var"#284#286"{Vector{Symbol}, Base.Pairs{Symbol, Symbol, NTuple{7, Symbol}, NamedTuple{(:id, :ii, :ss, :time, :observations, :amt, :route), NTuple{7, Symbol}}}}, op::typeof(vcat), A::Vector{Any}, ifirst::Int64, ilast::Int64, blksize::Int64)
    @ Base ./reduce.jl:244
 [14] mapreduce_impl
    @ ./reduce.jl:259 [inlined]
 [15] _mapreduce(f::NCA.var"#284#286"{Vector{Symbol}, Base.Pairs{Symbol, Symbol, NTuple{7, Symbol}, NamedTuple{(:id, :ii, :ss, :time, :observations, :amt, :route), NTuple{7, Symbol}}}}, op::typeof(vcat), #unused#::IndexLinear, A::Vector{Any})
    @ Base ./reduce.jl:417
 [16] _mapreduce_dim
    @ ./reducedim.jl:330 [inlined]
 [17] #mapreduce#731
    @ ./reducedim.jl:322 [inlined]
 [18] mapreduce
    @ ./reducedim.jl:322 [inlined]
 [19] read_nca(df::DataFrame; group::Vector{Symbol}, kwargs::Base.Pairs{Symbol, Symbol, NTuple{7, Symbol}, NamedTuple{(:id, :ii, :ss, :time, :observations, :amt, :route), NTuple{7, Symbol}}})
    @ NCA /build/_work/PumasSystemImages/PumasSystemImages/julia_depot/packages/NCA/CDayS/src/data_parsing.jl:62
 [20] top-level scope
    @ ~/data/code/SEL/SEL_pumas.jl:33