hi all
i tried the below codes and not able to fit the data at end
DR1 = DosageRegimen(50,time=0,cmt=2)
#DR2 = DosageRegimen(100,time=0,cmt=2)
#DR3 = DosageRegimen(200,time=0,cmt=2)
#s1 = Subject(id=1,evs = DR1, cvs = (wt=70,))
#s2 = Subject(id=2, evs = DR2, cvs= (wt=60,))
#s3 = Subject(id=3,evs=DR3, cvs = (wt=65,))
choose_covariates() = (WT = rand(55:80),)
#pop = Population([s1,s2,s3])
pop = Population(map(i -> Subject(id = i,evs = DR1, cvs = choose_covariates()),1:24))
pop
##############################
mymodel = @model begin
@param begin
tvcl ∈ RealDomain(lower=0, init = 1.0)
tvv ∈ RealDomain(lower=0, init = 5)
tvQ ∈ RealDomain(lower = 0, init= 1)
tvv2 ∈ RealDomain(lower = 0, init = 10)
Ω ∈ PDiagDomain(init=[0.09])
σ_prop ∈ RealDomain(lower=0,init=0.04)
end
#end
@random begin
η ~ MvNormal(Ω)
end
#end
@pre begin
CL = tvcl * exp(η[1])
V = tvv
V2 = tvv2
Q = tvQ
end
#end
#@covariates WT
#end
#@dynamics ImmediateAbsorptionModel
@dynamics begin
# Depot' = -Ka*Depot
Central' = Q*(Peripheral-Central) - (CL/V)*Central
Peripheral' = Q*(Central-Peripheral)
end
#end
@derived begin
cp = @. 1000*(Central / V)
DV ~ @. Normal(cp,sqrt(cp^2*σ_prop))
end
end
#####
param = init_param(mymodel)
obs = simobs(mymodel, pop, param, obstimes=0:1:72)
plot(obs)
simdf = DataFrame(obs)
first(simdf, 6)
simdf.route = "IV"
timeu = u"hr"
concu = u"mg/L"
amtu = u"mg"
ncadf = read_nca(simdf, id=:id, time=:time, conc=:cp, amt=:amt,
route=:route,timeu=timeu, concu=concu, amtu=amtu, lloq=0.4concu)
plot(ncadf)
simdf.cmt = ifelse.(ismissing.(simdf.cmt), 2, simdf.cmt)
est_df = simdf[.!((simdf.DV .== 0.0) .& (simdf.cmt .==2)),:]
first(est_df,6)
data = read_pumas(est_df ,cvs = [:WT], dvs=[:DV])
res = fit(mymodel,data,param,Pumas.FOCEI())
error is
Typeerror: in type assert, expected forward diff.dual … and many things