-
Notifications
You must be signed in to change notification settings - Fork 0
/
Goti_et_al.bug
58 lines (37 loc) · 1.76 KB
/
Goti_et_al.bug
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
model
{
# Prior probability densities
eta1~dnorm(0,pow(omega[1], -2))
eta2~dnorm(0,pow(omega[2], -2))
eta3~dnorm(0,pow(omega[3], -2))
# calculate concentrations using 2-cmt model with zero order infusion
for(x in 1:length(times)){
Cl[x] <- theta[1]*( (CLCR[x]/120)^theta[5]) * (theta[6]^DIAL[x])*exp(eta1)
V1[x] <- theta[2]*(WT[x]/70) * (theta[7]^DIAL[x])*exp(eta2)
V2[x] <- theta[3] * exp(eta3)
Q[x] <- theta[4]
k[x]=Cl[x]/V1[x]
k12[x] = Q[x]/V1[x]
k21[x] = Q[x]/V2[x]
beta[x] = 0.5 * (k12[x] + k21[x] + k[x] - sqrt((k12[x] + k21[x] + k[x])^2 - 4 * k21[x] * k[x]))
alpha[x] = (k21[x] * k[x]) / beta[x]
A[x] = 1/V1[x] *(alpha[x]-k21[x])/(alpha[x]-beta[x])
B[x] = 1/V1[x] *(beta[x]-k21[x])/(beta[x]-alpha[x])
for(i in 1:length(amt)) {
a[x, i]<- ifelse((times[x]-dosing_time[i]) <= 0,
0 ,
ifelse(times[x]-dosing_time[i] <= t_inf[i],
amt[i]/t_inf[i] * ( (A[x]/alpha[x])*(1-exp(-alpha[x]*(times[x]-dosing_time[i]))) + (B[x]/beta[x]) * (1-exp(-beta[x]*(times[x]-dosing_time[i])))),
amt[i]/t_inf[i] * ( (A[x]/alpha[x])*(1-exp(-alpha[x]*t_inf[i]) )*exp(-alpha[x]*(times[x]-dosing_time[i]-t_inf[i])) + (B[x]/beta[x])*(1-exp(-beta[x]*t_inf[i]) )*exp(-beta[x]*(times[x]-dosing_time[i]-t_inf[i])) )
)
)
}
mu[x] <- sum(a[x,])
}
for(z in 1: length(tdm_times)){
res_var[z] <- pow(mu[tdm_times[z]],2) * pow(sigma[1],2) + pow(sigma[2],2)
tau[z] <- 1/res_var[z]
# likelihood of the data, given the provided error model
c[z]~dnorm(mu[tdm_times[z]], tau[z])
}
}