-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunMorris_SS.r
More file actions
147 lines (131 loc) · 4.64 KB
/
Copy pathrunMorris_SS.r
File metadata and controls
147 lines (131 loc) · 4.64 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
library(rootSolve)
library(sensitivity)
source("model_eqns_baseSS.r")
source("computeSS_1var.r")
source("computeSS_all.r")
source("set_params.r")
# get testpars, parsbinf, parsbsup
p <- set_params()
source("set_morris.r")
set.seed(151)
rval = 10000
# plasma concentration
start_all <- Sys.time()
start_pconc <- Sys.time()
print(start_pconc)
print('start plas conc morris method')
x_plasconc <- morris(model = computeSS_plasconc,
factors = testpars,
r = rval,
design = list(type = "oat",
levels = 10,
grid.jump = 1),
binf = parsbinf,
bsup = parsbsup,
scale = TRUE)
end_pconc <- Sys.time()
print(end_pconc)
print(difftime(end_pconc, start_pconc, units= "secs"))
# compute mu, mu*, sigma
x <- x_plasconc
x_plasconc$mu <- apply(x$ee, 2, mean)
x_plasconc$mu.star <- apply(x$ee, 2, function(x) mean(abs(x)))
x_plasconc$sigma <- apply(x$ee, 2, sd)
# NOTE: can used x_plasconc$ee to get the elementary effects
# NOTE: I can get X by using x_plasconc$X
# interstitial space conc
start_iconc <- Sys.time()
print(start_iconc)
print('start inter conc morris method')
x_interconc <- morris(model = computeSS_interconc,
factors = testpars,
r = rval,
design = list(type = "oat",
levels = 10,
grid.jump = 1),
binf = parsbinf,
bsup = parsbsup,
scale = TRUE)
end_iconc <- Sys.time()
print(end_iconc)
print(difftime(end_iconc, start_iconc, units= "secs"))
# compute mu, mu*, sigma
x <- x_interconc
x_interconc$mu <- apply(x$ee, 2, mean)
x_interconc$mu.star <- apply(x$ee, 2, function(x) mean(abs(x)))
x_interconc$sigma <- apply(x$ee, 2, sd)
# muscle concentration
start_mconc <- Sys.time()
print(start_mconc)
print('start muscle conc morris method')
x_muscle <- morris(model = computeSS_muscleconc,
factors = testpars,
r = rval,
design = list(type = "oat",
levels = 10,
grid.jump = 1),
binf = parsbinf,
bsup = parsbsup,
scale = TRUE)
end_mconc <- Sys.time()
print(end_mconc)
print(difftime(end_mconc, start_mconc, units= "secs"))
# compute mu, mu*, sigma
x <- x_muscle
x_muscle$mu <- apply(x$ee, 2, mean)
x_muscle$mu.star <- apply(x$ee, 2, function(x) mean(abs(x)))
x_muscle$sigma <- apply(x$ee, 2, sd)
# amount gut
start_agut <- Sys.time()
print(start_agut)
print('start amt gut morris method')
x_amtgut <- morris(model = computeSS_amtgut,
factors = testpars,
r = rval,
design = list(type = "oat",
levels = 10,
grid.jump = 1),
binf = parsbinf,
bsup = parsbsup,
scale = TRUE)
end_amtgut <- Sys.time()
print(end_amtgut)
print(difftime(end_amtgut, start_agut, units= "secs"))
# compute mu, mu*, sigma
x <- x_amtgut
x_amtgut$mu <- apply(x$ee, 2, mean)
x_amtgut$mu.star <- apply(x$ee, 2, function(x) mean(abs(x)))
x_amtgut$sigma <- apply(x$ee, 2, sd)
# compute based on all variables
start_allvars <- Sys.time()
print(start_allvars)
print('start all morris method')
x_all <- morrisMultOut(model = computeSS_all,
factors = testpars,
r = 100,
design = list(type = "oat",
levels = 10,
grid.jump = 1),
binf = parsbinf,
bsup = parsbsup,
scale = TRUE)
print('all morris complete')
end <- Sys.time()
print(end)
print(difftime(end, start_all, units= "mins"))
# compute mu, mu*, sigma
x <- x_all
x_all$mu <- apply(x$ee, 2, mean)
x_all$mu.star <- apply(x$ee, 2, function(x) mean(abs(x)))
x_all$sigma <- apply(x$ee, 2, sd)
save_info = 1
if (save_info) {
today <- Sys.Date()
fname <- paste(today,
"_MorrisAnalysis_SS",
".RData",
sep = "")
save.image(fname)
print("results saved to:")
print(sprintf("%s", fname))
}