No method matching zero

Hi,
I am running a simulation using resampled individual parameter sets from a two-stage estimation. My model code is below:

pilot_fast_2cmt_katlag_ehc = @model begin
    @param begin
        σ_prop         ∈ RealDomain(lower=0.001)
        σ_add          ∈ RealDomain(lower=0.001)
    end

    @covariates iCl iVc iQ iVp iKa iLag iKpb iKgp ik0bile is_bile Form_C

    @pre begin
        Cl          = iCl
        Vc          = iVc
        Q           = iQ 
        Vp          = iVp 
        Ka          = iKa 
        Kpb         = iKpb 
        Kgp         = iKgp 
        k0bile      = (is_bile == 0) ? 0 : ik0bile
    end

    @dosecontrol begin
        lags            = (; Depot   = iLag)
    end

    @dynamics begin
    Depot'      = - Ka*Depot
    Central'    = Ka*Depot - (Cl/Vc)*Central + (Q/Vp)*Peripheral - Kpb*Central + Kgp * Gut
    Peripheral' = (Cl/Vc)*Central -  (Q/Vp)*Peripheral
    Bile'       = Kpb*Central - k0bile
    Gut'        = k0bile - Kgp * Gut
    end

    @derived begin
        cp            = @. (Central/Vc)
        Conc          ~ @. Normal(cp, sqrt(σ_add^2+(cp*σ_prop)^2))
    end
end

And when I run the simulation, I get this error message:

simobs(
        pilot_fast_2cmt_katlag_ehc,
        pop_fit_df.pop,
        param_2cmt_ehc,
        obstimes=[0.08,0.17,0.25,0.5,1.0,1.5,2.0,3.0,4.0,6.0,8.0,10.0,12.0,16.0,18.0,24.0]
        #rng=rng
    )

Error message:

ERROR: MethodError: no method matching zero(::Type{Array{Float64}})

Closest candidates are:
  zero(::Union{Type{P}, P}) where P<:Period
   @ Dates C:\Pumas-v2.4.1\Julia-1.9.2\share\julia\stdlib\v1.9\Dates\src\periods.jl:51
  zero(::Union{AbstractAlgebra.Generic.LaurentSeriesFieldElem{T}, AbstractAlgebra.Generic.LaurentSeriesRingElem{T}} where T<:AbstractAlgebra.RingElement)
   @ AbstractAlgebra C:\a\PumasSystemImages\PumasSystemImages\julia_depot\packages\AbstractAlgebra\FcxWh\src\generic\LaurentSeries.jl:466     
  zero(::Union{AbstractAlgebra.Generic.LaurentSeriesFieldElem{T}, AbstractAlgebra.Generic.LaurentSeriesRingElem{T}} where T<:AbstractAlgebra.RingElement, ::String; cached)
   @ AbstractAlgebra C:\a\PumasSystemImages\PumasSystemImages\julia_depot\packages\AbstractAlgebra\FcxWh\src\generic\LaurentSeries.jl:480     
  ...

Stacktrace:
  [1] zeros(#unused#::Type{Array{Float64}}, dims::Tuple{Int64, Int64})
    @ Base .\array.jl:585
  [2] zeros(::Type{Array{Float64}}, ::Int64, ::Int64)
    @ Base .\array.jl:580
  [3] (::var"#821#831")(_param#2926::NamedTuple{(:σ_add, :σ_prop), Tuple{Float64, Float64}}, _random#2927::NamedTuple{(), Tuple{}}, _subject#2924::Subject{NamedTuple{(:Conc,), Tuple{Vector{Union{Missing, Float64}}}}, Pumas.ConstantCovar{NamedTuple{(:iCl, :iVc, :iQ, :iVp, :iKa, :iLag, :iKpb, :iKgp, :ik0bile, :is_bile, :Form_C), Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Int64}, Vector{String15}}}}, Vector{Pumas.Event{Float64, Float64, Float64, Float64, Float64, Float64, Int64}}, Vector{Float64}})
    @ Main C:\a\PumasSystemImages\PumasSystemImages\julia_depot\packages\Pumas\VyE8h\src\dsl\model_macro.jl:822
  [4] (::Pumas.TimeDispatcher{var"#821#831", var"#822#832"})(param::NamedTuple{(:σ_add, :σ_prop), Tuple{Float64, Float64}}, randeffs::NamedTuple{(), Tuple{}}, subject::Subject{NamedTuple{(:Conc,), Tuple{Vector{Union{Missing, Float64}}}}, Pumas.ConstantCovar{NamedTuple{(:iCl, :iVc, :iQ, :iVp, :iKa, :iLag, :iKpb, :iKgp, :ik0bile, :is_bile, :Form_C), Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Int64}, Vector{String15}}}}, Vector{Pumas.Event{Float64, Float64, Float64, Float64, Float64, Float64, Int64}}, Vector{Float64}}, #unused#::Pumas.ConstantCovar{NamedTuple{(:iCl, :iVc, :iQ, :iVp, 
:iKa, :iLag, :iKpb, :iKgp, :ik0bile, :is_bile, :Form_C), Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Int64}, Vector{String15}}}})
    @ Pumas C:\a\PumasSystemImages\PumasSystemImages\julia_depot\packages\Pumas\VyE8h\src\dsl\model_macro.jl:502
  [5] (::Pumas.TimeDispatcher{var"#821#831", var"#822#832"})(param::NamedTuple{(:σ_add, :σ_prop), Tuple{Float64, Float64}}, randeffs::NamedTuple{(), Tuple{}}, subject::Subject{NamedTuple{(:Conc,), Tuple{Vector{Union{Missing, Float64}}}}, Pumas.ConstantCovar{NamedTuple{(:iCl, :iVc, :iQ, :iVp, :iKa, :iLag, :iKpb, :iKgp, :ik0bile, :is_bile, :Form_C), Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Int64}, Vector{String15}}}}, Vector{Pumas.Event{Float64, Float64, Float64, Float64, Float64, Float64, Int64}}, Vector{Float64}})
    @ Pumas C:\a\PumasSystemImages\PumasSystemImages\julia_depot\packages\Pumas\VyE8h\src\dsl\model_macro.jl:499
  [6] pre(model::PumasModel{(σ_prop = 1, σ_add = 1), 0, (:Depot, :Central, :Peripheral, :Bile, :Gut), ParamSet{NamedTuple{(:σ_prop, :σ_add), Tuple{RealDomain{Float64, TransformVariables.Infinity{true}, Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}}}, var"#820#830", Pumas.TimeDispatcher{var"#821#831", var"#822#832"}, Pumas.DCPChecker{Pumas.TimeDispatcher{var"#824#834", var"#825#835"}}, var"#827#837", Pumas.LinearODE, var"#828#838", var"#829#839", ModelingToolkit.ODESystem}, subject::Subject{NamedTuple{(:Conc,), Tuple{Vector{Union{Missing, Float64}}}}, Pumas.ConstantCovar{NamedTuple{(:iCl, :iVc, :iQ, :iVp, :iKa, :iLag, :iKpb, :iKgp, :ik0bile, :is_bile, :Form_C), Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Int64}, Vector{String15}}}}, Vector{Pumas.Event{Float64, Float64, Float64, Float64, Float64, Float64, Int64}}, Vector{Float64}}, param::NamedTuple{(:σ_add, :σ_prop), Tuple{Float64, Float64}}, randeffs::NamedTuple{(), Tuple{}})
    @ Pumas C:\a\PumasSystemImages\PumasSystemImages\julia_depot\packages\Pumas\VyE8h\src\models\model_api.jl:2167
  [7] simobs(::PumasModel{(σ_prop = 1, σ_add = 1), 0, (:Depot, :Central, :Peripheral, :Bile, :Gut), ParamSet{NamedTuple{(:σ_prop, :σ_add), Tuple{RealDomain{Float64, TransformVariables.Infinity{true}, Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}}}, var"#820#830", Pumas.TimeDispatcher{var"#821#831", var"#822#832"}, Pumas.DCPChecker{Pumas.TimeDispatcher{var"#824#834", var"#825#835"}}, var"#827#837", Pumas.LinearODE, var"#828#838", var"#829#839", ModelingToolkit.ODESystem}, ::Subject{NamedTuple{(:Conc,), Tuple{Vector{Union{Missing, Float64}}}}, Pumas.ConstantCovar{NamedTuple{(:iCl, :iVc, :iQ, :iVp, :iKa, :iLag, :iKpb, :iKgp, :ik0bile, :is_bile, :Form_C), Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Int64}, Vector{String15}}}}, Vector{Pumas.Event{Float64, Float64, Float64, Float64, Float64, Float64, Int64}}, Vector{Float64}}, ::NamedTuple{(:σ_add, :σ_prop), Tuple{Float64, Float64}}, ::Nothing; obstimes::Vector{Float64}, ensemblealg::EnsembleSerial, diffeq_options::NamedTuple{(:alg, :callback), Tuple{OrdinaryDiffEq.CompositeAlgorithm{Tuple{OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, Rosenbrock23{1, true, LinearSolve.LUFactorization{LinearAlgebra.RowMaximum}, typeof(OrdinaryDiffEq.DEFAULT_PRECS), Val{:forward}, true, nothing}}, OrdinaryDiffEq.AutoSwitch{OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, Rosenbrock23{1, true, LinearSolve.LUFactorization{LinearAlgebra.RowMaximum}, typeof(OrdinaryDiffEq.DEFAULT_PRECS), Val{:forward}, true, nothing}, Rational{Int64}, Int64}}, Nothing}}, rng::TaskLocalRNG, simulate_error::Val{true}, isfor_derived::Val{false}, return_model::Val{true})
    @ Pumas C:\a\PumasSystemImages\PumasSystemImages\julia_depot\packages\Pumas\VyE8h\src\models\model_api.jl:1532
  [8] #_simobs!#359
    @ C:\a\PumasSystemImages\PumasSystemImages\julia_depot\packages\Pumas\VyE8h\src\models\model_api.jl:1829 [inlined]
  [9] _simobs!
    @ C:\a\PumasSystemImages\PumasSystemImages\julia_depot\packages\Pumas\VyE8h\src\models\model_api.jl:1810 [inlined]
 [10] _simobs(::PumasModel{(σ_prop = 1, σ_add = 1), 0, (:Depot, :Central, :Peripheral, :Bile, :Gut), ParamSet{NamedTuple{(:σ_prop, :σ_add), Tuple{RealDomain{Float64, TransformVariables.Infinity{true}, Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}}}, var"#820#830", Pumas.TimeDispatcher{var"#821#831", var"#822#832"}, Pumas.DCPChecker{Pumas.TimeDispatcher{var"#824#834", var"#825#835"}}, var"#827#837", Pumas.LinearODE, var"#828#838", var"#829#839", ModelingToolkit.ODESystem}, ::Vector{Subject{NamedTuple{(:Conc,), Tuple{Vector{Union{Missing, Float64}}}}, Pumas.ConstantCovar{NamedTuple{(:iCl, :iVc, :iQ, :iVp, :iKa, :iLag, :iKpb, :iKgp, :ik0bile, :is_bile, :Form_C), Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Int64}, Vector{String15}}}}, Vector{Pumas.Event{Float64, Float64, Float64, Float64, Float64, Float64, Int64}}, Vector{Float64}}}, ::StaticArraysCore.SVector{1, NamedTuple{(:σ_add, :σ_prop), Tuple{Float64, Float64}}}, ::Nothing; rng::TaskLocalRNG, diffeq_options::NamedTuple{(), Tuple{}}, isfor_derived::Val{false}, simulate_error::Val{true}, obstimes::Vector{Float64}, ensemblealg::EnsembleSerial)
    @ Pumas C:\a\PumasSystemImages\PumasSystemImages\julia_depot\packages\Pumas\VyE8h\src\models\model_api.jl:2112
 [11] _simobs
    @ C:\a\PumasSystemImages\PumasSystemImages\julia_depot\packages\Pumas\VyE8h\src\models\model_api.jl:2023 [inlined]
 [12] #simobs#370
    @ C:\a\PumasSystemImages\PumasSystemImages\julia_depot\packages\Pumas\VyE8h\src\models\model_api.jl:1991 [inlined]
 [13] simobs
    @ C:\a\PumasSystemImages\PumasSystemImages\julia_depot\packages\Pumas\VyE8h\src\models\model_api.jl:1966 [inlined]
 [14] top-level scope

I am not able to understand what this error means. Any help deciphering it is appreciated. Thanks.

Can you show this object that you passed into the simobs

@vijay Here it is:

param_2cmt_ehc = (
        σ_add       = 50.0,
        σ_prop      = 0.15
        )

Can you try with this please

simobs(
        pilot_fast_2cmt_katlag_ehc,
        pop_fit_df.pop[1],
        param_2cmt_ehc,
        obstimes=[0.08,0.17,0.25,0.5,1.0,1.5,2.0,3.0,4.0,6.0,8.0,10.0,12.0,16.0,18.0,24.0]
        #rng=rng
    )

Still getting the same error.

ERROR: MethodError: no method matching zero(::Type{Array{Float64}})

Closest candidates are:
  zero(::Union{Type{P}, P}) where P<:Period
   @ Dates C:\Pumas-v2.4.1\Julia-1.9.2\share\julia\stdlib\v1.9\Dates\src\periods.jl:51
  zero(::Union{AbstractAlgebra.Generic.LaurentSeriesFieldElem{T}, AbstractAlgebra.Generic.LaurentSeriesRingElem{T}} where T<:AbstractAlgebra.RingElement)
   @ AbstractAlgebra C:\a\PumasSystemImages\PumasSystemImages\julia_depot\packages\AbstractAlgebra\FcxWh\src\generic\LaurentSeries.jl:466     
  zero(::Union{AbstractAlgebra.Generic.LaurentSeriesFieldElem{T}, AbstractAlgebra.Generic.LaurentSeriesRingElem{T}} where T<:AbstractAlgebra.RingElement, ::String; cached)
   @ AbstractAlgebra C:\a\PumasSystemImages\PumasSystemImages\julia_depot\packages\AbstractAlgebra\FcxWh\src\generic\LaurentSeries.jl:480     
  ...

If you need to see the pop_fit_df.pop this is how I have it.

    pop_fit_df = combine(
        groupby(rep_df, :REP),
        t -> (pop = read_pumas(
            t;
            id =           :id,
            observations = [:Conc],
            covariates =   [:iCl, :iVc, :iQ, :iVp, :iKa, :iLag, :iKpb, :iKgp, :ik0bile, :is_bile, :Form_C],
            time =          :time,
            amt=            :amt,
            cmt=            :cmt,
            evid =          :evid
            ),)
    )

Right now, I am running one rep.

48×2 DataFrame
 Row │ REP    pop
     │ Int64  Subject…
─────┼──────────────────────────────────
   1 │     1  Subject(id = r1fjYN, ...)
   2 │     1  Subject(id = CzySNV, ...)
   3 │     1  Subject(id = OMXW3R, ...)
   4 │     1  Subject(id = sAwVWJ, ...)
   5 │     1  Subject(id = zy0RbI, ...)
   6 │     1  Subject(id = SIt6UZ, ...)
  ⋮  │   ⋮                ⋮
  44 │     1  Subject(id = w7hmQA, ...)
  45 │     1  Subject(id = vM8N6b, ...)
  46 │     1  Subject(id = C1YBt0, ...)
  47 │     1  Subject(id = lTWD0c, ...)
  48 │     1  Subject(id = BifVDE, ...)
                         37 rows omitted

Could you please share the result of

pop_fit_df.pop[1].covariates

@andreasnoack Here it is.

Pumas.ConstantCovar{NamedTuple{(:iCl, :iVc, :iQ, :iVp, :iKa, :iLag, :iKpb, :iKgp, :ik0bile, :is_bile, :Form_C), Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Int64}, Vector{String15}}}}((iCl = [3605.0619119801404], iVc = [5443.37263296165], iQ = [6011.470769053865], iVp = [20793.580152771443], iKa = [2.0464227778328072], iLag = [0.2941399587159395], iKpb = [1.2750117011351623], iKgp = [0.8679120706896064], ik0bile = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0  …  0.0, 0.0, 0.0, 1.9915461368456517, 1.9915461368456517, 1.9915461368456517, 1.9915461368456517, 0.0, 0.0, 0.0], is_bile = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0  …  0, 0, 0, 1, 1, 1, 1, 0, 0, 0], Form_C = String15["Test"]))

FYI - I have the is_bile variable which takes a value of 1 for time between 4 to 10 hours and 0 otherwise.

Something is off with the covariates. Could you show us a bit of rep_df? What are the columns types of the covariates?

Here it is:


That is the issue. For some reason, each element in the data frame column is an array. How did you construct this data frame?

@andreasnoack Thanks for pointing out the error.
I was able to solve constructing the populations properly with internal help.

Thanks.