-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.R
61 lines (35 loc) · 1.32 KB
/
functions.R
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
creat_calc <- function(age, gender, creat, weight) {
if (gender == "мужской") {
return((140 - age)/creat * weight/72)
} else if ( gender == "женский" ) {
return((140 - age)/creat * weight/72*0.85)
}
}
kel_creat <- function(clear_creat) {
return(0.00083 * clear_creat + 0.0044)
}
kel_conc <- function(peak, trough, gap) {
return(log(trough/peak)/-gap)
}
auc_by_creat <- function(weight, height, age, gender, creat, dose, tau, inf_time) {
bw = 50 + 2.3 * (height/2.53 - 60)
if(height/2.53 < 60){
bw = 0.4 * (weight - bw) + bw
}
cr_cl = creat_calc(age = age, gender = gender, creat = creat, weight = bw)
k_el = 0.00083 * cr_cl + 0.0044
V_d = 0.7 * weight
c_peak = dose * (1 - exp(-k_el * inf_time)) / (inf_time * V_d * k_el * (1 - exp(-k_el*tau)))
c_trough = c_peak*exp(-k_el * (tau - inf_time))
lin_trap = (c_peak + c_trough) * inf_time / 2
log_trap = (c_peak - c_trough) * (tau - inf_time)/ log(c_peak/c_trough)
auc = (log_trap + lin_trap) * 2
return(auc)
}
auc_by_conc = function(peak, trough, tau, inf_time){
k_el = kel_conc(peak = peak,trough = trough, gap = tau)
lin_trap = (peak + trough) * inf_time / 2
log_trap = (peak - trough) * (tau - inf_time)/ log(peak/trough)
auc = (log_trap + lin_trap) * 2
return(auc)
}