-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathday1-05-absorption_models.jl
134 lines (107 loc) · 2.91 KB
/
day1-05-absorption_models.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
using Pumas
using PharmaDatasets
using DataFramesMeta
pkdata = dataset("po_md_2")
pop_oral = read_pumas(pkdata)
pop_dur = read_pumas(@rtransform pkdata :rate = -2)
# First-Order Absorption
foabs = @model begin
@param begin
tvcl ∈ RealDomain(lower = 0)
tvvc ∈ RealDomain(lower = 0)
tvka ∈ RealDomain(lower = 0)
Ω ∈ PDiagDomain(3)
σ ∈ RealDomain(lower = 0)
end
@random begin
η ~ MvNormal(Ω)
end
@pre begin
CL = tvcl * exp(η[1])
Vc = tvvc * exp(η[2])
Ka = tvka * exp(η[3])
end
@dynamics begin
Depot' = -Ka * Depot
Central' = Ka * Depot - (CL / Vc) * Central
end
@derived begin
cp := @. 1000 * Central / Vc
dv ~ @. Normal(cp, σ)
end
end
param_foabs = (tvcl = 5, tvvc = 20, tvka = 1, Ω = Diagonal([0.04, 0.04, 0.04]), σ = 1.0)
fit_foabs = fit(foabs, pop_oral, param_foabs, FOCE())
# Zero-Order Absorption
zoabs = @model begin
@param begin
tvcl ∈ RealDomain(lower = 0)
tvvc ∈ RealDomain(lower = 0)
tvdur ∈ RealDomain(lower = 0)
Ω ∈ PDiagDomain(3)
σ ∈ RealDomain(lower = 0)
end
@random begin
η ~ MvNormal(Ω)
end
@pre begin
CL = tvcl * exp(η[1])
Vc = tvvc * exp(η[2])
end
@dosecontrol begin
duration = (Central = tvdur * exp(η[3]),)
end
@dynamics begin
Central' = -(CL / Vc) * Central
end
@derived begin
cp := @. 1000 * Central / Vc
dv ~ @. Normal(cp, σ)
end
end
param_zoabs = (tvcl = 5, tvvc = 20, tvdur = 0.3, Ω = Diagonal([0.04, 0.04, 0.04]), σ = 1.0)
fit_zoabs = fit(zoabs, pop_dur, param_zoabs, FOCE())
# Two Parallel First-Order Processes
two_parallel_foabs = @model begin
@param begin
tvcl ∈ RealDomain(lower = 0)
tvvc ∈ RealDomain(lower = 0)
tvka1 ∈ RealDomain(lower = 0)
tvka2 ∈ RealDomain(lower = 0)
tvbio ∈ RealDomain(lower = 0, upper = 1)
Ω ∈ PDiagDomain(5)
σ ∈ RealDomain(lower = 0)
end
@random begin
η ~ MvNormal(Ω)
end
@pre begin
CL = tvcl * exp(η[1])
Vc = tvvc * exp(η[2])
Ka1 = tvka1 * exp(η[3])
Ka2 = tvka2 * exp(η[4])
end
@dosecontrol begin
bioav = (IR = tvbio * exp(η[5]), SR = (1 - tvbio) * exp(η[5]))
end
@dynamics begin
IR' = -Ka1 * IR # Immediate Release
SR' = -Ka2 * SR # Sustained Release
Central' = Ka1 * IR + Ka2 * SR - Central * CL / Vc
end
@derived begin
cp := @. 1000 * Central / Vc
dv ~ @. Normal(cp, σ)
end
end
param_two_parallel_foabs = (
tvcl = 5,
tvvc = 50,
tvka1 = 0.8,
tvka2 = 0.6,
tvbio = 0.5,
Ω = Diagonal([0.04, 0.04, 0.36, 0.36, 0.04]),
σ = 1.0,
)
fit_two_parallel_foabs =
fit(two_parallel_foabs, pop_oral, param_two_parallel_foabs, FOCE())