Not able to get VPC plot

Hi I am trying fit three different variables , this is how my derived block look like

    @derived begin
        ubp = @. Central/V2
        DV ~ @. Normal(ubp, ubp*(σ1_p))

        bp = @. Peripheral/ V3*pub
        BDV ~ @. Normal(bp,bp *(σ2_p))

        tc = @. (ubp + bp)
        PHNY ~ @. Normal(tc,tc*σ3_p)

    end 

I have used this VPC code.

pk_vpc = vpc(res_inspect_fm , 200; observations = [:DV,:BDV,:PHNY],
            # stratify_by = [:Dose],
             ensemblealg=EnsembleThreads())

here is the error

ERROR: MethodError: no method matching vpc(::Pumas.FittedPumasModelInspection{Pumas.FittedPumasModel{PumasModel{(TVK23 = 1, TVCL = 1, TVV2 = 1, TVV3 = 1, TVQ = 1, Ω = 3, σ1_p = 1, σ2_p = 1, σ3_p = 1, TVPUB = 1, θ = 4), 3, ParamSet{NamedTuple{(:TVK23, :TVCL, :TVV2, :TVV3, :TVQ, :Ω, :σ1_p, :σ2_p, :σ3_p, :TVPUB, :θ), Tuple{RealDomain{Int64, TransformVariables.Infinity{true}, Int64}, RealDomain{Int64, TransformVariables.Infinity{true}, Int64}, RealDomain{Int64, TransformVariables.Infinity{true}, Int64}, RealDomain{Int64, TransformVariables.Infinity{true}, Int64}, RealDomain{Int64, TransformVariables.Infinity{true}, Int64}, PDiagDomain{PDMats.PDiagMat{Float64, Vector{Float64}}}, RealDomain{Int64, TransformVariables.Infinity{true}, Int64}, RealDomain{Int64, TransformVariables.Infinity{true}, Int64}, RealDomain{Int64, TransformVariables.Infinity{true}, Int64}, RealDomain{Int64, TransformVariables.Infinity{true}, Int64}, VectorDomain{Vector{TransformVariables.Infinity{false}}, Vector{TransformVariables.Infinity{true}}, Vector{Float64}}}}}, Serialization.__deserialized_types__.var"#805#837", Serialization.__deserialized_types__.var"#806#838", Serialization.__deserialized_types__.var"#808#840", Serialization.__deserialized_types__.var"#810#842", Pumas.LinearODE, Serialization.__deserialized_types__.var"#811#843", Serialization.__deserialized_types__.var"#824#856", ModelingToolkit.ODESystem}, Vector{Subject{NamedTuple{(:DV, :BDV, :PHNY), Tuple{Vector{Union{Missing, Float64}}, Vector{Union{Missing, Float64}}, Vector{Union{Missing, Float64}}}}, T2, Vector{Pumas.Event{Float64, Float64, Float64, Float64, Float64, Float64, Int64}}, Vector{Float64}} where T2}, Optim.MultivariateOptimizationResults{Optim.BFGS{LineSearches.InitialStatic{Float64}, LineSearches.BackTracking{Float64, Int64}, Nothing, Float64, Optim.Flat}, Vector{Float64}, Float64, Float64, Vector{Optim.OptimizationState{Float64, Optim.BFGS{LineSearches.InitialStatic{Float64}, LineSearches.BackTracking{Float64, Int64}, Nothing, Float64, Optim.Flat}}}, Bool, NamedTuple{(:f_limit_reached, :g_limit_reached, :h_limit_reached, :time_limit, :callback, :f_increased), NTuple{6, Bool}}}, Pumas.FOCE, Vector{Vector{Float64}}, NamedTuple{(:optimize_fn, :constantcoef, :omegas, :ensemblealg, :diffeq_options), Tuple{Pumas.DefaultOptimizeFN{Nothing, NamedTuple{(:show_trace, :store_trace, :extended_trace, :g_tol, :allow_f_increases), Tuple{Bool, Bool, Bool, Float64, Bool}}}, NamedTuple{(:TVV3, :TVQ), Tuple{Float64, Int64}}, Tuple{}, EnsembleThreads, NamedTuple{(), Tuple{}}}}, ParamSet{NamedTuple{(:TVK23, :TVCL, :TVV2, :TVV3, :TVQ, :Ω, :σ1_p, :σ2_p, :σ3_p, :TVPUB, :θ), Tuple{RealDomain{Int64, TransformVariables.Infinity{true}, Int64}, RealDomain{Int64, TransformVariables.Infinity{true}, Int64}, RealDomain{Int64, TransformVariables.Infinity{true}, Int64}, Pumas.ConstDomain{Float64}, Pumas.ConstDomain{Int64}, PDiagDomain{PDMats.PDiagMat{Float64, Vector{Float64}}}, RealDomain{Int64, TransformVariables.Infinity{true}, Int64}, RealDomain{Int64, TransformVariables.Infinity{true}, Int64}, RealDomain{Int64, TransformVariables.Infinity{true}, Int64}, RealDomain{Int64, TransformVariables.Infinity{true}, Int64}, VectorDomain{Vector{TransformVariables.Infinity{false}}, Vector{TransformVariables.Infinity{true}}, Vector{Float64}}}}}}, Vector{Pumas.SubjectPrediction{NamedTuple{(:ubp, :DV, :bp, :BDV, :tc, :PHNY), NTuple{6, Vector{Float64}}}, NamedTuple{(:ubp, :DV, :bp, :BDV, :tc, :PHNY), NTuple{6, Vector{Float64}}}, Nothing}}, Vector{Pumas.SubjectResidual{NamedTuple{(:DV, :BDV, :PHNY), Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}}}, NamedTuple{(:DV, :BDV, :PHNY), Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}}}, T3, Pumas.FOCE} where T3}, NamedTuple{(:ebes,), Tuple{Vector{NamedTuple{(:η,), Tuple{Vector{Float64}}}}}}, Nothing, Vector{Pumas.ConstantInterpolationStructArray{Vector{Float64}, StructArrays.StructVector{NamedTuple{(:id, :albonpub, :alb_cl, :scr_cl, :wt_pub, :pub, :k23, :CL, :V2, :V3, :Q, Symbol("##A##"), Symbol("##b##")), Tuple{String, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, StaticArrays.SMatrix{3, 3, Float64, 9}, StaticArrays.SVector{3, Int64}}}, NamedTuple{(:id, :albonpub, :alb_cl, :scr_cl, :wt_pub, :pub, :k23, :CL, :V2, :V3, :Q, Symbol("##A##"), Symbol("##b##")), Tuple{Vector{String}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{Float64}, Vector{StaticArrays.SMatrix{3, 3, Float64, 9}}, Vector{StaticArrays.SVector{3, Int64}}}}, Int64}, Symbol}}, Vector{Pumas.ConstantInterpolationStructArray{Vector{Float64}, StructArrays.StructVector{NamedTuple{(:id,), Tuple{String}}, NamedTuple{(:id,), Tuple{Vector{String}}}, Int64}, Symbol}}}, ::Int64; observations=[:DV, :BDV, :PHNY], ensemblealg=EnsembleThreads())
Closest candidates are:
  vpc(::Pumas.AbstractFittedPumasModel, ::Integer; samples, kwargs...) at /builds/PumasAI/PumasSystemImages-jl/.julia/packages/Pumas/Ozwn0/src/estimation/vpc.jl:820
Stacktrace:
 [1] top-level scope
   @ ~/data/code/june_30_phenytoin/hennig.jl:3138

can some one help me to solve this error.

Thank you.

hi @sai_matcha - as the error states, it is a method error, which means that the function received an input that does not match the expected signature. vpc currently takes two kinds of inputs,

  1. vpc(fit)
  2. vpc(model, data, param)

You provided an inspect object to the vpc and hence it errored.

Second - the observations argument of vpc is there to specify which observation do you want to do a vpc for. You cannot run a vpc on all of them at the same time. if you look at the documentation of vpc here you will notice the following statement -

  • observations: The name of the dependent variable to use for the VPCs, passed in as a Symbol wrapped in an array. The default is the first dependent variable in the population. Even though the argument takes an array note that only a single derived variable at a time is supported.
2 Likes

Is thre a way to get “time after recent dose vs observations” vpc ?

Thanks

Hi Sai,

If the time for the recent (last dose) is identical for all the subjects, you can set the time points using the obstimes argument for the VPC.

If the time of dosing for all the subjects is not identical, you can use time after last dose as time for the estimation and then run a VPC. It might help.

Hi @nikksramwani1, Thanks for your response. I have mutliple doses for each subjects. If i set tad as time , then each subjects will have many dosing events at time 0. How to handle that ?

Hi @sai_matcha ,

You can filter the dataset for the recent (last dose), as you mentioned you want a VPC only for the last dose. Thank you.

1 Like