-
Notifications
You must be signed in to change notification settings - Fork 2
/
scenario_abundance.R
183 lines (169 loc) · 4.44 KB
/
scenario_abundance.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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#### Code to run scenarios - ABUNDANCE
# run all multiple times and save output
# all run as functions
# load packages needed to run in parallel
library(foreach)
library(doParallel)
# choose number of times to run
n_runs <- 1
# create a randomly generated string of seeds
# seed must be integer
seed <- sample(round(1:100000000),n_runs,replace=F)
#seed <- NULL
# set up the scenario with parameters that need to be changed
# set parameters
#source("setParams.R") # this is now redundant
source("run_scenario.R")
# change those that need changing
## ABUNDANCE
lambda <- seq(-6, -1, length.out = 10) # 10 scenarios
# structured model
mapply(FUN = run_scenario,
lambda = lambda,
parameter = lambda,
MoreArgs = list(
model_type="structured",
plotting=FALSE,
summary_results=FALSE,
seed = seed,
plot = FALSE,
n_runs = n_runs,
scenario_name = "Abundance_",
dim = c(300,300),
env.beta = 1.2,
plotdat = TRUE,
sigma2x = 0.5,
kappa = 0.05,
strata = 25,
rows = 5,
cols = 5,
probs = 0.5,
qsize = 1,
rho = 0.8,
nsamp = 150,
resolution = c(10,10))) # to use the function you must put in all parameters it is expecting
# unstructured model
mapply(FUN = run_scenario,
lambda = lambda,
parameter = lambda,
MoreArgs = list(
model_type="unstructured",
plotting=FALSE,
summary_results=FALSE,
seed = seed,
plot = FALSE,
n_runs = n_runs,
scenario_name = "Abundance_",
dim = c(300,300),
env.beta = 1.2,
plotdat = TRUE,
sigma2x = 0.5,
kappa = 0.05,
strata = 25,
rows = 5,
cols = 5,
probs = 0.5,
qsize = 1,
rho = 0.8,
nsamp = 150,
resolution = c(10,10)))
# unstructuredcov model
mapply(FUN = run_scenario,
lambda = lambda,
parameter = lambda,
MoreArgs = list(
model_type = "unstructuredcov",
plotting = FALSE,
summary_results = FALSE,
seed = seed,
plot = FALSE,
n_runs = n_runs,
scenario_name = "Abundance_",
dim = c(300,300),
env.beta = 1.2,
plotdat = TRUE,
sigma2x = 0.5,
kappa = 0.05,
strata = 25,
rows = 5,
cols = 5,
probs = 0.5,
qsize = 1,
rho = 0.8,
nsamp = 150,
resolution = c(10,10)))
# joint model
mapply(FUN = run_scenario,
lambda = lambda,
parameter = lambda,
MoreArgs = list(
model_type="joint",
plotting=FALSE,
summary_results=FALSE,
seed = seed,
plot = FALSE,
n_runs = n_runs,
scenario_name = "Abundance_",
dim = c(300,300),
env.beta = 1.2,
plotdat = TRUE,
sigma2x = 0.5,
kappa = 0.05,
strata = 25,
rows = 5,
cols = 5,
probs = 0.5,
qsize = 1,
rho = 0.8,
nsamp = 150,
resolution = c(10,10))) # to use the function you must put in all parameters it is expecting
# jointcov model
mapply(FUN = run_scenario,
lambda = lambda,
parameter = lambda,
MoreArgs = list(
model_type="jointcov",
plotting=FALSE,
summary_results=FALSE,
seed = seed,
plot = FALSE,
n_runs = n_runs,
scenario_name = "Abundance_",
dim = c(300,300),
env.beta = 1.2,
plotdat = TRUE,
sigma2x = 0.5,
kappa = 0.05,
strata = 25,
rows = 5,
cols = 5,
probs = 0.5,
qsize = 1,
rho = 0.8,
nsamp = 150,
resolution = c(10,10)))
# joint2 model
mapply(FUN = run_scenario,
lambda = lambda,
parameter = lambda,
MoreArgs = list(
model_type="joint2",
plotting=FALSE,
summary_results=FALSE,
seed = seed,
plot = FALSE,
n_runs = n_runs,
scenario_name = "Abundance_",
dim = c(300,300),
env.beta = 1.2,
plotdat = TRUE,
sigma2x = 0.5,
kappa = 0.05,
strata = 25,
rows = 5,
cols = 5,
probs = 0.5,
qsize = 1,
rho = 0.8,
nsamp = 150,
resolution = c(10,10)))