Hello
I have the following Bayesian Model
BAYESIAN_PKPD = @model begin
@param begin
tvKTV1 ~ LogNormal(log(0.4), 1.0)
tvKTV2 ~ LogNormal(log(0.1), 1.0)
tvecmo ~ Normal(-0.7, 1.0)
tvCL1 ~ LogNormal(log(0.9), 1.0)
tvCL2 ~ LogNormal(log(0.8), 1.0)
tvcircuit ~ LogNormal(log(1.2), 1.0)
tvVc1 ~ LogNormal(log(1.8), 0.1)
tvVc2 ~ LogNormal(log(3.0), 0.1)
σ_prop_1 ~ truncated(Cauchy(0, 0.18), 0.0, 1.0)
σ_prop_2 ~ truncated(Cauchy(0, 0.02), 0.0, 1.0)
σ_prop_3 ~ truncated(Cauchy(0, 0.04), 0.0, 1.0)
σ_add ~ truncated(Cauchy(0, 5000.0), 0.0, Inf)
ω²KTV ~ Constrained(Normal(0.0, 1.0); lower = 0.0, init = 1.8)
ω²CL ~ Constrained(Normal(0.0, 1.0); lower = 0.0, init = 0.2)
ω²Vc ~ Constrained(Normal(0.0, 1.0); lower = 0.0, init = 0.9)
end
@random begin
ηKTV ~ Normal(0.0, sqrt(ω²KTV))
ηCL ~ Normal(0.0, sqrt(ω²CL))
ηVc ~ Normal(0.0, sqrt(ω²Vc))
end
@covariates WT ECMO_DAYS IS_CIRCUIT_CHANGE site T
@pre begin
# PK parameters
siteeffect_1 = if site==1
σ_prop_1
elseif site==2
σ_prop_2
else
σ_prop_3
end
siteeffect_2 = site==2 ? σ_add : 0.0
tvKTV = site == 1 ? tvKTV1 : tvKTV2*(ECMO_DAYS/6)^tvecmo
KTV = tvKTV*exp(ηKTV)
TVCL = site == 1 ? tvCL1 * (WT/10)^0.75 : tvCL2* (WT/10)^0.75 * tvcircuit^IS_CIRCUIT_CHANGE
CL = TVCL * exp(ηCL)*(1-exp(-KTV*T))
TVVc = site == 1 ? tvVc1 * (WT/10)^1 : tvVc2 * (WT/10)^1
Vc = TVVc * exp(ηVc)
end
@dynamics begin
Central' = -(CL/Vc) * Central
end
@derived begin
CP = @. Central / Vc
CONC = @. Normal(CP, sqrt(CP^2*siteeffect_1 + siteeffect_2))
end
end
However, when I try to run it, I get the following error:
result_PKPD = @time fit(BAYESIAN_PKPD, estimation, init_params(BAYESIAN_PKPD), Pumas.BayesMCMC(nsamples=2000, nadapts=1000,nchains =4,target_accept = 0.8,ensemblealg = EnsembleThreads()))
ERROR: MethodError: no method matching iterate(::TransformVariables.Infinity{true})
Closest candidates are:
iterate(::Union{LinRange, StepRangeLen}) at /opt/julia-1.7.3/share/julia/base/range.jl:826
iterate(::Union{LinRange, StepRangeLen}, ::Integer) at /opt/julia-1.7.3/share/julia/base/range.jl:826
iterate(::T) where T<:Union{Base.KeySet{<:Any, <:Dict}, Base.ValueIterator{<:Dict}} at /opt/julia-1.7.3/share/julia/base/dict.jl:695
...
Stacktrace:
[1] _zip_iterate_some
@ ./iterators.jl:358 [inlined]
[2] _zip_iterate_some (repeats 2 times)
@ ./iterators.jl:360 [inlined]
[3] _zip_iterate_all
@ ./iterators.jl:350 [inlined]
[4] iterate
@ ./iterators.jl:340 [inlined]
[5] _all(f::Pumas.var"#176#177", itr::Base.Iterators.Zip{Tuple{ForwardDiff.Dual{ForwardDiff.Tag{Pumas.Tag, Float64}, Float64, 6}, Float64, TransformVariables.Infinity{true}}}, #unused#::Colon)
@ Base ./reduce.jl:1156
[6] all(f::Function, itr::Base.Iterators.Zip{Tuple{ForwardDiff.Dual{ForwardDiff.Tag{Pumas.Tag, Float64}, Float64, 6}, Float64, TransformVariables.Infinity{true}}})
@ Base ./reduce.jl:1152
[7] logpdf(d::Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}, x::ForwardDiff.Dual{ForwardDiff.Tag{Pumas.Tag, Float64}, Float64, 6})
@ Pumas /build/_work/PumasSystemImages/PumasSystemImages/julia_depot/packages/Pumas/Td3Jp/src/models/params.jl:561
[8] _lpdf(d::Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}, x::ForwardDiff.Dual{ForwardDiff.Tag{Pumas.Tag, Float64}, Float64, 6})
@ Pumas /build/_work/PumasSystemImages/PumasSystemImages/julia_depot/packages/Pumas/Td3Jp/src/estimation/likelihoods.jl:555
[9] macro expansion
@ /build/_work/PumasSystemImages/PumasSystemImages/julia_depot/packages/Pumas/Td3Jp/src/estimation/likelihoods.jl:0 [inlined]
[10] _core_lpdf(lpdf::typeof(Pumas._lpdf), reduce::typeof(+), ds::NamedTuple{(:tvKTV1, :tvKTV2, :tvecmo, :tvCL1, :tvCL2, :tvcircuit, :tvVc1, :tvVc2, :σ_prop_1, :σ_prop_2, :σ_prop_3, :σ_add, :ω²KTV, :ω²CL, :ω²Vc), Tuple{LogNormal{Float64}, LogNormal{Float64}, Normal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}}}, xs::NamedTuple{(:tvKTV1, :tvKTV2, :tvecmo, :tvCL1, :tvCL2, :tvcircuit, :tvVc1, :tvVc2, :σ_prop_1, :σ_prop_2, :σ_prop_3, :σ_add, :ω²KTV, :ω²CL, :ω²Vc), NTuple{15, ForwardDiff.Dual{ForwardDiff.Tag{Pumas.Tag, Float64}, Float64, 6}}})
@ Pumas /build/_work/PumasSystemImages/PumasSystemImages/julia_depot/packages/Pumas/Td3Jp/src/estimation/likelihoods.jl:578
[11] _lpdf(ds::NamedTuple{(:tvKTV1, :tvKTV2, :tvecmo, :tvCL1, :tvCL2, :tvcircuit, :tvVc1, :tvVc2, :σ_prop_1, :σ_prop_2, :σ_prop_3, :σ_add, :ω²KTV, :ω²CL, :ω²Vc), Tuple{LogNormal{Float64}, LogNormal{Float64}, Normal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}}}, xs::NamedTuple{(:tvKTV1, :tvKTV2, :tvecmo, :tvCL1, :tvCL2, :tvcircuit, :tvVc1, :tvVc2, :σ_prop_1, :σ_prop_2, :σ_prop_3, :σ_add, :ω²KTV, :ω²CL, :ω²Vc), NTuple{15, ForwardDiff.Dual{ForwardDiff.Tag{Pumas.Tag, Float64}, Float64, 6}}})
@ Pumas /build/_work/PumasSystemImages/PumasSystemImages/julia_depot/packages/Pumas/Td3Jp/src/estimation/likelihoods.jl:575
[12] (::Pumas._L_param{TransformVariables.TransformTuple{NamedTuple{(:tvKTV1, :tvKTV2, :tvecmo, :tvCL1, :tvCL2, :tvcircuit, :tvVc1, :tvVc2, :σ_prop_1, :σ_prop_2, :σ_prop_3, :σ_add, :ω²KTV, :ω²CL, :ω²Vc), Tuple{Pumas.LogNormalTransform{LogNormal{Float64}}, Pumas.LogNormalTransform{LogNormal{Float64}}, Pumas.NormalTransform{Normal{Float64}}, Pumas.LogNormalTransform{LogNormal{Float64}}, Pumas.LogNormalTransform{LogNormal{Float64}}, Pumas.LogNormalTransform{LogNormal{Float64}}, Pumas.LogNormalTransform{LogNormal{Float64}}, Pumas.LogNormalTransform{LogNormal{Float64}}, TransformVariables.ScaledShiftedLogistic{Float64}, TransformVariables.ScaledShiftedLogistic{Float64}, TransformVariables.ScaledShiftedLogistic{Float64}, TransformVariables.ShiftedExp{true, Float64}, TransformVariables.ShiftedExp{true, Float64}, TransformVariables.ShiftedExp{true, Float64}, TransformVariables.ShiftedExp{true, Float64}}}}, ParamSet{NamedTuple{(:tvKTV1, :tvKTV2, :tvecmo, :tvCL1, :tvCL2, :tvcircuit, :tvVc1, :tvVc2, :σ_prop_1, :σ_prop_2, :σ_prop_3, :σ_add, :ω²KTV, :ω²CL, :ω²Vc), Tuple{LogNormal{Float64}, LogNormal{Float64}, Normal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}}}}})(u::Vector{ForwardDiff.Dual{ForwardDiff.Tag{Pumas.Tag, Float64}, Float64, 6}})
@ Pumas /build/_work/PumasSystemImages/PumasSystemImages/julia_depot/packages/Pumas/Td3Jp/src/estimation/bayes/logdensity.jl:203
[13] chunk_mode_gradient!(result::DiffResults.MutableDiffResult{1, Float64, Tuple{Vector{Float64}}}, f::Pumas._L_param{TransformVariables.TransformTuple{NamedTuple{(:tvKTV1, :tvKTV2, :tvecmo, :tvCL1, :tvCL2, :tvcircuit, :tvVc1, :tvVc2, :σ_prop_1, :σ_prop_2, :σ_prop_3, :σ_add, :ω²KTV, :ω²CL, :ω²Vc), Tuple{Pumas.LogNormalTransform{LogNormal{Float64}}, Pumas.LogNormalTransform{LogNormal{Float64}}, Pumas.NormalTransform{Normal{Float64}}, Pumas.LogNormalTransform{LogNormal{Float64}}, Pumas.LogNormalTransform{LogNormal{Float64}}, Pumas.LogNormalTransform{LogNormal{Float64}}, Pumas.LogNormalTransform{LogNormal{Float64}}, Pumas.LogNormalTransform{LogNormal{Float64}}, TransformVariables.ScaledShiftedLogistic{Float64}, TransformVariables.ScaledShiftedLogistic{Float64}, TransformVariables.ScaledShiftedLogistic{Float64}, TransformVariables.ShiftedExp{true, Float64}, TransformVariables.ShiftedExp{true, Float64}, TransformVariables.ShiftedExp{true, Float64}, TransformVariables.ShiftedExp{true, Float64}}}}, ParamSet{NamedTuple{(:tvKTV1, :tvKTV2, :tvecmo, :tvCL1, :tvCL2, :tvcircuit, :tvVc1, :tvVc2, :σ_prop_1, :σ_prop_2, :σ_prop_3, :σ_add, :ω²KTV, :ω²CL, :ω²Vc), Tuple{LogNormal{Float64}, LogNormal{Float64}, Normal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}}}}}, x::Vector{Float64}, cfg::ForwardDiff.GradientConfig{ForwardDiff.Tag{Pumas.Tag, Float64}, Float64, 6, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Pumas.Tag, Float64}, Float64, 6}}})
@ ForwardDiff /build/_work/PumasSystemImages/PumasSystemImages/julia_depot/packages/ForwardDiff/pDtsf/src/gradient.jl:150
[14] gradient!(result::DiffResults.MutableDiffResult{1, Float64, Tuple{Vector{Float64}}}, f::Pumas._L_param{TransformVariables.TransformTuple{NamedTuple{(:tvKTV1, :tvKTV2, :tvecmo, :tvCL1, :tvCL2, :tvcircuit, :tvVc1, :tvVc2, :σ_prop_1, :σ_prop_2, :σ_prop_3, :σ_add, :ω²KTV, :ω²CL, :ω²Vc), Tuple{Pumas.LogNormalTransform{LogNormal{Float64}}, Pumas.LogNormalTransform{LogNormal{Float64}}, Pumas.NormalTransform{Normal{Float64}}, Pumas.LogNormalTransform{LogNormal{Float64}}, Pumas.LogNormalTransform{LogNormal{Float64}}, Pumas.LogNormalTransform{LogNormal{Float64}}, Pumas.LogNormalTransform{LogNormal{Float64}}, Pumas.LogNormalTransform{LogNormal{Float64}}, TransformVariables.ScaledShiftedLogistic{Float64}, TransformVariables.ScaledShiftedLogistic{Float64}, TransformVariables.ScaledShiftedLogistic{Float64}, TransformVariables.ShiftedExp{true, Float64}, TransformVariables.ShiftedExp{true, Float64}, TransformVariables.ShiftedExp{true, Float64}, TransformVariables.ShiftedExp{true, Float64}}}}, ParamSet{NamedTuple{(:tvKTV1, :tvKTV2, :tvecmo, :tvCL1, :tvCL2, :tvcircuit, :tvVc1, :tvVc2, :σ_prop_1, :σ_prop_2, :σ_prop_3, :σ_add, :ω²KTV, :ω²CL, :ω²Vc), Tuple{LogNormal{Float64}, LogNormal{Float64}, Normal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}}}}}, x::Vector{Float64}, cfg::ForwardDiff.GradientConfig{ForwardDiff.Tag{Pumas.Tag, Float64}, Float64, 6, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Pumas.Tag, Float64}, Float64, 6}}}, ::Val{false})
@ ForwardDiff /build/_work/PumasSystemImages/PumasSystemImages/julia_depot/packages/ForwardDiff/pDtsf/src/gradient.jl:39
[15] _logdensitygrad(b::Pumas.ThreadedBayesLogDensity{PumasModel{(tvKTV1 = 1, tvKTV2 = 1, tvecmo = 1, tvCL1 = 1, tvCL2 = 1, tvcircuit = 1, tvVc1 = 1, tvVc2 = 1, σ_prop_1 = 1, σ_prop_2 = 1, σ_prop_3 = 1, σ_add = 1, ω²KTV = 1, ω²CL = 1, ω²Vc = 1), 3, (:Central,), ParamSet{NamedTuple{(:tvKTV1, :tvKTV2, :tvecmo, :tvCL1, :tvCL2, :tvcircuit, :tvVc1, :tvVc2, :σ_prop_1, :σ_prop_2, :σ_prop_3, :σ_add, :ω²KTV, :ω²CL, :ω²Vc), Tuple{LogNormal{Float64}, LogNormal{Float64}, Normal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}}}}, var"#747#754", Pumas.TimeDispatcher{var"#748#755", var"#749#756"}, Nothing, var"#751#758", Pumas.LinearODE, var"#752#759", var"#753#760", ModelingToolkit.ODESystem}, NamedTuple{(:tvKTV1, :tvKTV2, :tvecmo, :tvCL1, :tvCL2, :tvcircuit, :tvVc1, :tvVc2, :σ_prop_1, :σ_prop_2, :σ_prop_3, :σ_add, :ω²KTV, :ω²CL, :ω²Vc), NTuple{15, Float64}}, Vector{Subject{NamedTuple{(:CONC,), Tuple{Vector{Union{Missing, Float64}}}}, Pumas.ConstantInterpolationStructArray{Vector{Float64}, NamedTuple{(:WT, :ECMO_DAYS, :IS_CIRCUIT_CHANGE, :site, :T), Tuple{Vector{Float64}, Vector{Float64}, Vector{Int64}, Vector{Int64}, Vector{Float64}}}, Symbol}, Vector{Pumas.Event{Float64, Float64, Float64, Float64, Float64, Float64, Int64}}, Vector{Float64}}}, Vector{Vector{Float64}}, Vector{Vector{Float64}}, Vector{ForwardDiff.GradientConfig{ForwardDiff.Tag{Pumas.Tag, Float64}, Float64, 6, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Pumas.Tag, Float64}, Float64, 6}}}}, Vector{DiffResults.MutableDiffResult{1, Float64, Tuple{Vector{Float64}}}}, NamedTuple{(), Tuple{}}}, v::Vector{Float64})
@ Pumas /build/_work/PumasSystemImages/PumasSystemImages/julia_depot/packages/Pumas/Td3Jp/src/estimation/bayes/logdensity.jl:359
[16] logdensitygrad(b::Pumas.ThreadedBayesLogDensity{PumasModel{(tvKTV1 = 1, tvKTV2 = 1, tvecmo = 1, tvCL1 = 1, tvCL2 = 1, tvcircuit = 1, tvVc1 = 1, tvVc2 = 1, σ_prop_1 = 1, σ_prop_2 = 1, σ_prop_3 = 1, σ_add = 1, ω²KTV = 1, ω²CL = 1, ω²Vc = 1), 3, (:Central,), ParamSet{NamedTuple{(:tvKTV1, :tvKTV2, :tvecmo, :tvCL1, :tvCL2, :tvcircuit, :tvVc1, :tvVc2, :σ_prop_1, :σ_prop_2, :σ_prop_3, :σ_add, :ω²KTV, :ω²CL, :ω²Vc), Tuple{LogNormal{Float64}, LogNormal{Float64}, Normal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, LogNormal{Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Truncated{Cauchy{Float64}, Continuous, Float64}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}, Constrained{Normal{Float64}, RealDomain{Float64, TransformVariables.Infinity{true}, Float64}}}}}, var"#747#754", Pumas.TimeDispatcher{var"#748#755", var"#749#756"}, Nothing, var"#751#758", Pumas.LinearODE, var"#752#759", var"#753#760", ModelingToolkit.ODESystem}, NamedTuple{(:tvKTV1, :tvKTV2, :tvecmo, :tvCL1, :tvCL2, :tvcircuit, :tvVc1, :tvVc2, :σ_prop_1, :σ_prop_2, :σ_prop_3, :σ_add, :ω²KTV, :ω²CL, :ω²Vc), NTuple{15, Float64}}, Vector{Subject{NamedTuple{(:CONC,), Tuple{Vector{Union{Missing, Float64}}}}, Pumas.ConstantInterpolationStructArray{Vector{Float64}, NamedTuple{(:WT, :ECMO_DAYS, :IS_CIRCUIT_CHANGE, :site, :T), Tuple{Vector{Float64}, Vector{Float64}, Vector{Int64}, Vector{Int64}, Vector{Float64}}}, Symbol}, Vector{Pumas.Event{Float64, Float64, Float64, Float64, Float64, Float64, Int64}}, Vector{Float64}}}, Vector{Vector{Float64}}, Vector{Vector{Float64}}, Vector{ForwardDiff.GradientConfig{ForwardDiff.Tag{Pumas.Tag, Float64}, Float64, 6, Vector{ForwardDiff.Dual{ForwardDiff.Tag{Pumas.Tag, Float64}, Float64, 6}}}}, Vector{DiffResults.MutableDiffResult{1, Float64, Tuple{Vector{Float64}}}}, NamedTuple{(), Tuple{}}}, v::Vector{Float64})
The model runs when I define the omegas
in @param
block as following:
ω ∈ Constrained(
MvNormal(zeros(3), Diagonal([1.0,0.2,1.0])),
lower=zeros(3),
upper=fill(Inf, 3),
init=ones(3),
)
I am not able to interpret the error. I appreciate your help.
Thanks!