Hi Andreas,
Here attached the codes. And I didn’t have any error or warning message.
Thanks!
Anqi
@time using Distributions, Pumas, CSV, TableView, StatsPlots, DataFrames, LinearAlgebra
ped_mod = @model begin
@param begin
θ ~ Constrained(MvNormal([16.6,13.1,4.05,4.89,0.623,0,0,0],
Matrix{Float64}([0.0895 0.0167 0.00318 0.0033 0.000907 0 0 0;
0.0167 0.0655 -0.00765 0.00333 -0.000917 0 0 0;
0.00318 -0.00765 0.0238 0.0147 -0.000225 0 0 0;
0.0033 0.00333 0.0147 0.0161 -0.000243 0 0 0;
0.000907 -0.000917 -0.000225 -0.000243 0.0016 0 0 0;
0 0 0 0 0 1000000 0 0;
0 0 0 0 0 0 1000000 0;
0 0 0 0 0 0 0 1000000])),lower=[0,0,0,0,0,0,0,0])
Ω ~ InverseWishart(3, diagm([0.282, 0.149, 0.0377]))
σ_prop ∈ RealDomain(lower = 0)
end
@random begin
η ~ MvNormal(Ω)
end
@covariates WTKG CRCL
@pre begin
#--INSERT COVARIATE EFFECTS
COV1=(CRCL/100)^θ[5]
COV2=(WTKG/70)^θ[6]
COV3=(WTKG/70)^θ[7]
COV4=(WTKG/70)^θ[8]
TVCLI = θ[1]*COV1*COV4
TVCL = TVCLI
TVV1I = θ[2]*COV2
TVV1 = TVV1I
TVQI = θ[3]
TVQ = TVQI
TVV2I = θ[4]*COV3
TVV2 = TVV2I
CL = TVCL*exp(η[1])
V1 = TVV1*exp(η[2])
Q = TVQ
V2 = TVV2*exp(η[3])
Vc = V1
Vp = V2
S1 = V1
#CALCULATION OF SECONDARY PARAMETERS
KE = CL/V1
K12 = Q/V1
K21 = Q/V2
AA = KE+K12+K21
ALPH = (AA+sqrt(AA*AA-4*KE*K21))/2
BETA = (AA-sqrt(AA*AA-4*KE*K21))/2
end
@dynamics Central1Periph1 #a two compartment model
@derived begin
cp = @. 1000*(Central/Vc)
DV ~ @. Normal(cp,sqrt((cp^2*σ_prop)))
end
end
## Read Dataset
inputDataset = CSV.read("dat.csv")
## Pumas expects a dvs and id column. So map the names of the columns
df = read_pumas(inputDataset, id = :ID, dvs =[:DV], cvs=[:WTKG, :CRCL], evid=:EVID, amt=:AMT,cmt=:CMT, rate=:RATE, time=:TIME)
#Initla value for parameters
param = (
θ=([18,14.2,2.13,4.29,1,1,1,1]),
Ω = diagm([0.25,0.25,0.25]),
σ_prop = 0.04)
pkres = fit(ped_mod, df, param, Pumas.BayesMCMC(),nsamples=10000)