Fitting multiple observalbles

I have a data set with multiple observable values:
Ctot, Cfree, and Blocker

Leaving Blocker out for the time being. My dose doses Ctot and Cfree is supposed to be a diminishing fraction of Ctot.

I built a simple model -


WhyDrop = @model begin

    @param begin
        
      θ ∈ RealDomain(lower=0.0001,init=1, upper=200000) 
      Ω ∈ RealDomain(init=0.09)
      σ_prop ∈ RealDomain(init=0.09, lower=0.01, upper=1)
    end

    @random begin
      η ~ Normal(Ω)
    end

    @pre begin
        k         =  θ[1]*exp(η[1])
    end
    
    @covariates begin
        CLS
        V1S
    end

    @init begin
        X = 1
    end

    @dynamics begin
        a1'  =  -CLS*ctot
        X'   =  -k*X            
     end
    
    @vars begin
        ctot :=  a1/V1S
        cfree:= X*ctot
    end
    
    @derived begin
        A1               = a1
        Cfree            = cfree
        
        Ctot ~ @.Normal(ctot,sqrt(ctot^2*σ_prop+ eps()))  
        dv ~ @.Normal(Cfree,sqrt(Cfree^2*σ_prop+ eps()))
        
    end
end

My Pumas_data is generated as:

dfP1=read_pumas(df9 ,id=:Subject, evid=:evid, time=:Time,amt=:Dosenmol, cmt=:cmt, rate=:Ratenmolday, cvs=[:CLS,:V1S], dvs=[:Ctot,:dv])

My question are simple:

  1. How do I make sure my dose is applied to Ctot and not Cfree? I tried to define a :cmt in the df9 filling it with a1 instead of numbers but readPumas requires an integer. Is there any way to ensure that the dose goes to a1, other than making a1 the first equation?

  2. I assume that fitting will be do by matching column names in the PumasFrame to the name of variable in the model? Is there anything else that I need to do to ensure that the data is matching to the right model variable when I have more than one observable?

Finally, whem I try to fit the model.
Using BayesMCMC() yieds result, but using FOCEI() or LapalceI() results in error:


param5=init_param(SEABCMAWhy5)
res5 = fit(SEABCMAWhy5,dfP1,param5,Pumas.LaplaceI())

PosDefException: matrix is not positive definite; Cholesky factorization failed.
Is this due to multiple observables? The documentations says LaplaceI should work, but it gives the same error as FOCEI.

Thanks,

A

You can specify the cmt as a Symbol and not just a number (see below, cmt = :a1). This allows you to keep the ordering of the @dyanmics independent of the cmt numbering. Using your model above, I added the following lines of code (note the dose and covariate values are arbitrary numbers). You can check with this simulation and try different options out to see what works for you.

s1 = Subject(id=1, evs=DosageRegimen(100,cmt=:a1), cvs=(CLS=1,V1S=1))
param5=init_param(WhyDrop)
sims = simobs(WhyDrop, s1, param5)

plot(sims)

So - this works well in this case, but does not seems to work well when I do:

sims5=simobs(Whydrop,dfP1)

because dfP1 can not be built using symbol for “:cmt”

df9.Dosenmol = df9.Dosemg.*(1E9/150E6)#./20
df9.Ratenmolday = df9.Ratemgday.*(1E9/150E6)
df9.SEABCMAnmolL = df9.SEABCMAngml./150
df9.Ctot = df9.PKngml./150
df9[!,:cmt] .= :a1
rename!(df9,Dict(:SEABCMAnmolL=>:dv))

dfP1=read_pumas(df9 ,id=:Subject, evid=:evid, time=:Time,amt=:Dosenmol, cmt=:cmt, rate=:Ratenmolday, cvs=[:CLS,:V1S], dvs=[:Ctot,:dv])

returns the following error:

MethodError: no method matching Int64(::Symbol)
Closest candidates are:
Int64(!Matched::Union{Bool, Int32, Int64, UInt32, UInt64, UInt8, Int128, Int16, Int8, UInt128, UInt16}) at boot.jl:710
Int64(!Matched::Ptr) at boot.jl:720
Int64(!Matched::Float32) at float.jl:700

Stacktrace:
[1] Subject(::SubDataFrame{DataFrame,DataFrames.Index,Array{Int64,1}}, ::Array{Symbol,1}, ::Symbol, ::Symbol, ::Symbol, ::Symbol, ::Symbol, ::Symbol, ::Symbol, ::Symbol, ::Symbol, ::Array{Symbol,1}, ::Array{Symbol,1}, ::Bool) at C:\Users\awolf-yadlin.juliapro\JuliaPro_v1.2.0-1\packages\Pumas\0Bex7\src\data_parsing\data_types.jl:251
[2] (::getfield(Pumas, Symbol("##37#38")){Symbol,Symbol,Symbol,Symbol,Symbol,Symbol,Symbol,Symbol,Symbol,Bool,Array{Symbol,1}})(::SubDataFrame{DataFrame,DataFrames.Index,Array{Int64,1}}) at .\none:0
[3] collect(::Base.Generator{GroupedDataFrame{DataFrame},getfield(Pumas, Symbol("##37#38")){Symbol,Symbol,Symbol,Symbol,Symbol,Symbol,Symbol,Symbol,Symbol,Bool,Array{Symbol,1}}}) at .\generator.jl:47
[4] #read_pumas#36(::Array{Symbol,1}, ::Array{Symbol,1}, ::Symbol, ::Symbol, ::Symbol, ::Symbol, ::Symbol, ::Symbol, ::Symbol, ::Symbol, ::Symbol, ::Symbol, ::Bool, ::typeof(read_pumas), ::DataFrame) at C:\Users\awolf-yadlin.juliapro\JuliaPro_v1.2.0-1\packages\Pumas\0Bex7\src\data_parsing\data_read.jl:63
[5] (::getfield(Pumas, Symbol("#kw##read_pumas")))(::NamedTuple{(:id, :evid, :time, :amt, :cmt, :rate, :cvs, :dvs),Tuple{Symbol,Symbol,Symbol,Symbol,Symbol,Symbol,Array{Symbol,1},Array{Symbol,1}}}, ::typeof(read_pumas), ::DataFrame) at .\none:0
[6] top-level scope at In[542]:100:

This can only be fixed by:

df9[!,:cmt] .= 1

I hope this clarify my issue is probably arising from pumas_read and not from building subjects or populations from scratch. Dose that makes sense?

Ale

Aha… let me check…