-
Notifications
You must be signed in to change notification settings - Fork 2
/
Transition_Effects.R
325 lines (276 loc) · 19.1 KB
/
Transition_Effects.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
EffectsTransition<-function(P_effects, b)
{
if(P_effects=="test")
{
# here we assume that the probability that a site occupied is being replaced, colonized or extinct by a species is independent of the the other species dynamics
# POCHERS EXTINCTION independent of the presence of prey
epsilonAB <- exp(b[13]) / (1+exp(b[13])+exp(b[14])+exp(b[15]))
trans13 <- exp(b[5]) / (1+exp(b[4])+exp(b[5])+exp(b[6])) # gammaB-gammaAB
gammaAB <- exp(b[6]) / (1+exp(b[4])+exp(b[5])+exp(b[6]))
trans42 <- exp(b[14]) / (1+exp(b[13])+exp(b[14])+exp(b[15])) # epsilonB-epsilonAB
trans43 <- exp(b[15]) / (1+exp(b[13])+exp(b[14])+exp(b[15]))
trans12 <- exp(b[4]) / (1+exp(b[4])+exp(b[5])+exp(b[6]))
nuB <- trans42
omegaAB <- exp(b[8]) / (1+exp(b[15])+exp(b[8])+exp(b[9]))
etaB <- exp(b[9]) / (1+exp(b[7])+exp(b[8])+exp(b[9]))
nuA <- exp(b[7]) / (1+exp(b[7])+exp(b[8])+exp(b[9]))
omegaBA <- exp(b[11]) / (1+exp(b[14])+exp(b[11])+exp(b[12]))
etaA <- exp(b[12]) / (1+exp(b[14])+exp(b[11])+exp(b[12]))
}
else if(P_effects=="no prey effect")
{
# POCHERS EXTINCTION independent of the presence of prey
trans42 <- exp(b[14]) / (1+exp(b[13])+exp(b[14])+exp(b[15])) # epsilonB-epsilonAB
# POCHERS colonisation independent of the presence of prey
gammaAB <- exp(b[6]) / (1+exp(b[4])+exp(b[5])+exp(b[6]))
trans12 <- exp(b[4]) / (1+exp(b[4])+exp(b[5])+exp(b[6])) # gammaA-gammaAB
etaA <- trans12
# PREYS colonisation and extinction dependent of presence of poacher
epsilonAB <- exp(b[13]) / (1+exp(b[13])+exp(b[14])+exp(b[15]))
trans43 <- exp(b[15]) / (1+exp(b[13])+exp(b[14])+exp(b[15])) # epsilonA-epsilonAB
nuA <- trans43
trans13 <- exp(b[5]) / (1+exp(b[4])+exp(b[5])+ exp(b[6])) # gammaB-gammaAB
nuB <- exp(b[10]) / (1+exp(b[10])+ exp(b[11])+ exp(b[4])) # to be checked with Oliver
omegaBA <- exp(b[11]) / (1+exp(b[10])+exp(b[11]) + exp(b[4])) # to be checked with Oliver
omegaAB <- exp(b[8]) / (1+exp(b[9])+ exp(b[8]) + exp(b[15]))
etaB <- exp(b[9]) / (1+exp(b[15])+exp(b[8])+exp(b[9]))
}
else if(P_effects=="species interaction")
{
epsilonAB <- exp(b[13]) / (1+exp(b[13])+exp(b[14])+exp(b[15]))
trans13 <- exp(b[5]) / (1+exp(b[4])+exp(b[5])+exp(b[6])) # gammaB-gammaAB
gammaAB <- exp(b[6]) / (1+exp(b[4])+exp(b[5])+exp(b[6]))
trans42 <- exp(b[14]) / (1+exp(b[13])+exp(b[14])+exp(b[15])) # epsilonB-epsilonAB
trans43 <- exp(b[15]) / (1+exp(b[13])+exp(b[14])+exp(b[15]))
trans12 <- exp(b[4]) / (1+exp(b[4])+exp(b[5])+exp(b[6]))
nuA <- exp(b[7]) / (1+exp(b[7])+exp(b[8])+exp(b[9]))
omegaAB <- exp(b[8]) / (1+exp(b[7])+exp(b[8])+exp(b[9]))
etaB <- exp(b[9]) / (1+exp(b[7])+exp(b[8])+exp(b[9]))
nuB <- exp(b[10]) / (1+exp(b[10])+exp(b[11])+exp(b[12]))
omegaBA <- exp(b[11]) / (1+exp(b[10])+exp(b[11])+exp(b[12]))
etaA <- exp(b[12]) / (1+exp(b[10])+exp(b[11])+exp(b[12]))
}
else if(P_effects=="poachers performance")
{
# colonisation of poachers depend on the presence of prey
trans12 <- exp(b[4]) / (1+exp(b[4])+exp(b[5])+exp(b[6])) # gammaA-gammaAB
trans13 <- exp(b[5]) / (1+exp(b[4])+exp(b[5])+exp(b[6])) # gammaB-gammaAB
gammaAB <- exp(b[6]) / (1+exp(b[4])+exp(b[5])+exp(b[6]))
# colonisation of prey independent of poachers
omegaAB <- exp(b[8]) / (1+exp(b[5])+exp(b[8])+exp(b[14]))
etaB <- trans13
nuB <- exp(b[10]) / (1+exp(b[10])+exp(b[11])+exp(b[12]))
omegaBA <- exp(b[11]) / (1+exp(b[10])+exp(b[11])+exp(b[12]))
etaA <- exp(b[12]) / (1+exp(b[10])+exp(b[11])+exp(b[12]))
# extinction of poachers is independent of prey (poachers are doing a better job than ranger)
epsilonAB <- exp(b[13]) / (1+exp(b[13])+exp(b[14])+exp(b[15]))
trans42 <- exp(b[14]) / (1+exp(b[13])+exp(b[14])+exp(b[15])) # epsilonB-epsilonAB
trans43 <- exp(b[15]) / (1+exp(b[13])+exp(b[14])+exp(b[15])) # epsilonA-epsilonAB
nuA <- trans43
}
else if(P_effects=="prey counteracting behaviour")
{
# POACHERS EXTINCTION dependent of the presence of prey
epsilonAB <- exp(b[13]) / (1+exp(b[13])+exp(b[14])+exp(b[15]))
trans42 <- exp(b[14]) / (1+exp(b[13])+exp(b[14])+exp(b[15])) # epsilonB-epsilonAB
omegaAB <- exp(b[8]) / (1+exp(b[8])+exp(b[7])+exp(b[9]))
nuA <- exp(b[7]) / (1+exp(b[8])+exp(b[7])+exp(b[9]))
# POACHERS colonisation independent of the presence of prey
gammaAB <- exp(b[6]) / (1+exp(b[6])+exp(b[4])+exp(b[5]))
trans12 <- exp(b[4]) / (1+exp(b[6])+exp(b[4])+exp(b[5])) # gammaA-gammaAB
etaA <- trans12
# PREYS colonisation dependent of presence of poachers
trans13 <- exp(b[5]) / (1+exp(b[6])+exp(b[5])+exp(b[4])) # gammaB-gammaAB
etaB <- exp(b[9]) / (1+exp(b[8])+exp(b[7])+exp(b[9]))
# PREYS extinction independent on occupancy of poachers
trans43 <- exp(b[15]) / (1+exp(b[13])+exp(b[14])+exp(b[15])) # epsilonA-epsilonAB
nuB <- trans42
omegaBA <- exp(b[11]) / (1+exp(b[14])+exp(b[11])+exp(b[4]))
}
if(P_effects=="spatial effects of ranger on poachers")
{
nuA<-matrix(0, nrow=R, ncol=N)
omegaAB<-matrix(0, nrow=R, ncol=N)
omegaBA<-matrix(0, nrow=R, ncol=N)
etaA<-matrix(0, nrow=R, ncol=N)
nuB<-matrix(0, nrow=R, ncol=N)
etaB<-matrix(0, nrow=R, ncol=N)
epsilonAB <- matrix(0, nrow=R, ncol=N)
trans13 <- matrix(0, nrow=R, ncol=N) # gammaB-gammaAB
gammaAB <- matrix(0, nrow=R, ncol=N)
trans42 <- matrix(0, nrow=R, ncol=N) # epsilonB-epsilonAB
trans43 <- matrix(0, nrow=R, ncol=N)
trans12 <- matrix(0, nrow=R, ncol=N)
for(s in 1:R)
{
epsilonAB[s,] <- exp(b[13] + b[25]*tempcov[s,]) / (1+exp(b[13] + b[25]*tempcov[s,])+exp(b[14] + b[26]*tempcov[s,])+exp(b[15]+ b[27]*tempcov[s,]))
trans13[s,] <- exp(b[5]) / (1+exp(b[4])+exp(b[5])+exp(b[6])) # gammaB-gammaAB
gammaAB[s,] <- exp(b[6]) / (1+exp(b[4])+exp(b[5])+exp(b[6]))
trans42[s,] <- exp(b[14] + b[26]*tempcov[s,]) / (1+exp(b[13] + b[25]*tempcov[s,])+exp(b[14] + b[26]*tempcov[s,]) + exp(b[15]+ b[27]*tempcov[s,])) # epsilonB-epsilonAB
trans43[s,] <- exp(b[15] + b[27]*tempcov[s,]) / (1+exp(b[13] + b[25]*tempcov[s,])+exp(b[14] + b[26]*tempcov[s,]) + exp(b[15]+ b[27]*tempcov[s,]))
trans12[s,] <- exp(b[4] ) / (1+exp(b[4])+exp(b[5]) + exp(b[6]))
nuA[s,] <- exp(b[7]) / (1+exp(b[7])+exp(b[8])+exp(b[9]))
omegaAB[s,] <- exp(b[8]) / (1+exp(b[7])+exp(b[8])+exp(b[9]))
etaB[s,] <- exp(b[9]) / (1+exp(b[7])+exp(b[8])+exp(b[9]))
nuB[s,] <- exp(b[10]+ b[25]*tempcov[s,]) / (1+exp(b[10] + b[25]*tempcov[s,])+exp(b[11] + b[26]*tempcov[s,])+exp(b[12] + b[27]*tempcov[s,]))
omegaBA[s,] <- exp(b[11] + b[26]*tempcov[s,]) / (1+exp(b[10] + b[25]*tempcov[s,])+exp(b[11]+ b[26]*tempcov[s,])+exp(b[12] + b[27]*tempcov[s,]))
etaA[s,] <- exp(b[12] + b[27]*tempcov[s,]) / (1+exp(b[10] + b[25]*tempcov[s,])+exp(b[11]+ b[26]*tempcov[s,])+exp(b[12] + b[27]*tempcov[s,]))
}
}
if(P_effects=="temporal effects of ranger on poachers")
{
nuA<-matrix(0, nrow=R, ncol=N)
omegaAB<-matrix(0, nrow=R, ncol=N)
omegaBA<-matrix(0, nrow=R, ncol=N)
etaA<-matrix(0, nrow=R, ncol=N)
nuB<-matrix(0, nrow=R, ncol=N)
etaB<-matrix(0, nrow=R, ncol=N)
epsilonAB <- matrix(0, nrow=R, ncol=N)
trans13 <- matrix(0, nrow=R, ncol=N) # gammaB-gammaAB
gammaAB <- matrix(0, nrow=R, ncol=N)
trans42 <- matrix(0, nrow=R, ncol=N) # epsilonB-epsilonAB
trans43 <- matrix(0, nrow=R, ncol=N)
trans12 <- matrix(0, nrow=R, ncol=N)
for(t in 1:(N-1))
{
epsilonAB[,t+1] <- exp(b[13] + b[25]*tempcov[,t]) / (1+exp(b[13] + b[25]*tempcov[,t]) + exp(b[14] + b[26]*tempcov[,t]) + exp(b[15]+ b[27]*tempcov[,t]))
trans13[,t+1] <- exp(b[5]) / (1+exp(b[4])+exp(b[5])+exp(b[6])) # gammaB-gammaAB
gammaAB[,t+1] <- exp(b[6]) / (1+exp(b[4])+exp(b[5])+exp(b[6]))
trans42[,t+1] <- exp(b[14] + b[26]*tempcov[,t]) / (1+exp(b[13] + b[25]*tempcov[,t])+exp(b[14] + b[26]*tempcov[,t]) + exp(b[15]+ b[27]*tempcov[,t])) # epsilonB-epsilonAB
trans43[,t+1] <- exp(b[15] + b[27]*tempcov[,t]) / (1+exp(b[13] + b[25]*tempcov[,t])+exp(b[14] + b[26]*tempcov[,t]) + exp(b[15]+ b[27]*tempcov[,t]))
trans12[,t+1] <- exp(b[4] ) / (1+exp(b[4])+exp(b[5]) + exp(b[6]))
nuA[,t+1] <- exp(b[7]) / (1+exp(b[7])+exp(b[8])+exp(b[9]))
omegaAB[,t+1] <- exp(b[8]) / (1+exp(b[7])+exp(b[8])+exp(b[9]))
etaB[,t+1] <- exp(b[9]) / (1+exp(b[7])+exp(b[8])+exp(b[9]))
nuB[,t+1] <- exp(b[10]+ b[15]*tempcov[,t]) / (1+exp(b[10] + b[25]*tempcov[,t])+exp(b[11] + b[26]*tempcov[,t])+exp(b[12] + b[27]*tempcov[,t]))
omegaBA[,t+1] <- exp(b[11] + b[26]*tempcov[,t]) / (1+exp(b[10] + b[25]*tempcov[,t])+exp(b[11]+ b[26]*tempcov[,t])+exp(b[12] + b[27]*tempcov[,t]))
etaA[,t+1] <- exp(b[12] + b[27]*tempcov[,t]) / (1+exp(b[10] + b[25]*tempcov[,t])+exp(b[11]+ b[26]*tempcov[,t])+exp(b[12] + b[27]*tempcov[,t]))
}
}
if(P_effects=="space")
{
nuA<-matrix(0, nrow=R, ncol=N)
omegaAB<-matrix(0, nrow=R, ncol=N)
omegaBA<-matrix(0, nrow=R, ncol=N)
etaA<-matrix(0, nrow=R, ncol=N)
nuB<-matrix(0, nrow=R, ncol=N)
etaB<-matrix(0, nrow=R, ncol=N)
epsilonAB <- matrix(0, nrow=R, ncol=N)
trans13 <- matrix(0, nrow=R, ncol=N) # gammaB-gammaAB
gammaAB <- matrix(0, nrow=R, ncol=N)
trans42 <- matrix(0, nrow=R, ncol=N) # epsilonB-epsilonAB
trans43 <- matrix(0, nrow=R, ncol=N)
trans12 <- matrix(0, nrow=R, ncol=N)
for(s in 1:R)
{
epsilonAB[s,] <- exp(b[13] + b[25]*tempcov[s,]) / (1+exp(b[13] + b[25]*tempcov[s,])+exp(b[14] + b[26]*tempcov[s,])+exp(b[15] + b[27]*tempcov[s,]))
trans13[s,] <- exp(b[5] + b[26]*tempcov[s,]) / (1+exp(b[4] + b[25]*tempcov[s,])+exp(b[5] + b[26]*tempcov[s,])+exp(b[6] + b[27]*tempcov[s,]))# gammaB-gammaAB
gammaAB[s,] <- exp(b[6] + b[27]*tempcov[s,]) / (1+exp(b[4] + b[25]*tempcov[s,])+exp(b[5] + b[26]*tempcov[s,])+exp(b[6] + b[27]*tempcov[s,]))
trans42[s,] <- exp(b[14] + b[26]*tempcov[s,]) / (1+exp(b[13] + b[25]*tempcov[s,])+exp(b[14] + b[26]*tempcov[s,])+exp(b[15]+ b[27]*tempcov[s,])) # epsilonB-epsilonAB
trans43[s,] <- exp(b[15] + b[27]*tempcov[s,]) / (1+exp(b[13] + b[25]*tempcov[s,])+exp(b[14] + b[26]*tempcov[s,]) + exp(b[15] + b[27]*tempcov[s,]))
trans12[s,] <- exp(b[4] + b[25]*tempcov[s,]) / (1+exp(b[4] + b[25]*tempcov[s,])+exp(b[5] + b[26]*tempcov[s,])+exp(b[6] + b[27]*tempcov[s,]))
nuA[s,] <- exp(b[7] + b[25]*tempcov[s,]) / (1+exp(b[7] + b[25]*tempcov[s,])+exp(b[8]+ b[26]*tempcov[s,])+exp(b[9] + b[27]*tempcov[s,]))
omegaAB[s,] <- exp(b[8] + b[26]*tempcov[s,]) / (1+exp(b[7] + b[25]*tempcov[s,])+exp(b[8]+ b[26]*tempcov[s,])+exp(b[9] + b[27]*tempcov[s,]))
etaB[s,] <- exp(b[9] + b[27]*tempcov[s,]) / (1+exp(b[7] + b[25]*tempcov[s,])+exp(b[8]+ b[26]*tempcov[s,])+exp(b[9] + b[27]*tempcov[s,]))
nuB[s,] <- exp(b[10] + b[25]*tempcov[s,]) / (1+exp(b[10] + b[25]*tempcov[s,])+exp(b[11]+ b[26]*tempcov[s,])+exp(b[12] + b[27]*tempcov[s,]))
omegaBA[s,] <- exp(b[11] + b[26]*tempcov[s,]) / (1+exp(b[10] + b[25]*tempcov[s,])+exp(b[11]+ b[26]*tempcov[s,])+exp(b[12] + b[27]*tempcov[s,]))
etaA[s,] <- exp(b[12] + b[27]*tempcov[s,]) / (1+exp(b[10] + b[25]*tempcov[s,])+exp(b[11]+ b[26]*tempcov[s,])+exp(b[12] + b[27]*tempcov[s,]))
}
}
if(P_effects=="time cov")
{
nuA<-matrix(0, nrow=R, ncol=N)
omegaAB<-matrix(0, nrow=R, ncol=N)
omegaBA<-matrix(0, nrow=R, ncol=N)
etaA<-matrix(0, nrow=R, ncol=N)
nuB<-matrix(0, nrow=R, ncol=N)
etaB<-matrix(0, nrow=R, ncol=N)
epsilonAB <- matrix(0, nrow=R, ncol=N)
trans13 <- matrix(0, nrow=R, ncol=N) # gammaB-gammaAB
gammaAB <- matrix(0, nrow=R, ncol=N)
trans42 <- matrix(0, nrow=R, ncol=N) # epsilonB-epsilonAB
trans43 <- matrix(0, nrow=R, ncol=N)
trans12 <- matrix(0, nrow=R, ncol=N)
for(t in 1:(N-1))
{
epsilonAB[,t+1] <- exp(b[13] + b[25]*tempcov[,t]) / (1+exp(b[13] + b[25]*tempcov[,t])+exp(b[14] + b[26]*tempcov[,t])+exp(b[15] + b[27]*tempcov[,t]))
trans13[,t+1] <- exp(b[5] + b[26]*tempcov[,t]) / (1+exp(b[4] + b[25]*tempcov[,t])+exp(b[5] + b[26]*tempcov[,t])+exp(b[6] + b[27]*tempcov[,t]))# gammaB-gammaAB
gammaAB[,t+1] <- exp(b[6] + b[27]*tempcov[,t]) / (1+exp(b[4] + b[25]*tempcov[,t])+exp(b[5] + b[26]*tempcov[,t])+exp(b[6] + b[27]*tempcov[,t]))
trans42[,t+1] <- exp(b[14] + b[26]*tempcov[,t]) / (1+exp(b[13] + b[25]*tempcov[,t])+exp(b[14] + b[26]*tempcov[,t])+exp(b[15]+ b[27]*tempcov[,t])) # epsilonB-epsilonAB
trans43[,t+1] <- exp(b[15] + b[27]*tempcov[,t]) / (1+exp(b[13] + b[25]*tempcov[,t])+exp(b[14] + b[26]*tempcov[,t]) + exp(b[15] + b[27]*tempcov[,t]))
trans12[,t+1] <- exp(b[4] + b[25]*tempcov[,t]) / (1+exp(b[4] + b[25]*tempcov[,t])+exp(b[5] + b[26]*tempcov[,t])+exp(b[6] + b[27]*tempcov[,t]))
nuA[,t+1] <- exp(b[7] + b[25]*tempcov[,t]) / (1+exp(b[7] + b[25]*tempcov[,t])+exp(b[8]+ b[26]*tempcov[,t])+exp(b[9] + b[27]*tempcov[,t]))
omegaAB[,t+1] <- exp(b[8] + b[26]*tempcov[,t]) / (1+exp(b[7] + b[25]*tempcov[,t])+exp(b[8]+ b[26]*tempcov[,t])+exp(b[9] + b[27]*tempcov[,t]))
etaB[,t+1] <- exp(b[9] + b[27]*tempcov[,t]) / (1+exp(b[7] + b[25]*tempcov[,t])+exp(b[8]+ b[26]*tempcov[,t])+exp(b[9] + b[27]*tempcov[,t]))
nuB[,t+1] <- exp(b[10] + b[25]*tempcov[,t]) / (1+exp(b[10] + b[25]*tempcov[,t])+exp(b[11]+ b[26]*tempcov[,t])+exp(b[12] + b[27]*tempcov[,t]))
omegaBA[,t+1] <- exp(b[11] + b[26]*tempcov[,t]) / (1+exp(b[10] + b[25]*tempcov[,t])+exp(b[11]+ b[26]*tempcov[,t])+exp(b[12] + b[27]*tempcov[,t]))
etaA[,t+1] <- exp(b[12] + b[27]*tempcov[,t]) / (1+exp(b[10] + b[25]*tempcov[,t])+exp(b[11]+ b[26]*tempcov[,t])+exp(b[12] + b[27]*tempcov[,t]))
}
}
if(P_effects=="both delay")
{
nuA<-matrix(0, nrow=R, ncol=N)
omegaAB<-matrix(0, nrow=R, ncol=N)
omegaBA<-matrix(0, nrow=R, ncol=N)
etaA<-matrix(0, nrow=R, ncol=N)
nuB<-matrix(0, nrow=R, ncol=N)
etaB<-matrix(0, nrow=R, ncol=N)
epsilonAB <- matrix(0, nrow=R, ncol=N)
trans13 <- matrix(0, nrow=R, ncol=N) # gammaB-gammaAB
gammaAB <- matrix(0, nrow=R, ncol=N)
trans42 <- matrix(0, nrow=R, ncol=N) # epsilonB-epsilonAB
trans43 <- matrix(0, nrow=R, ncol=N)
trans12 <- matrix(0, nrow=R, ncol=N)
for(s in 1:R)
{ for(t in 1:(N-1))
{
epsilonAB[s,t+1] <- exp(b[13] + b[28]*tempcov[s,t]) / (1+exp(b[13] + b[28]*tempcov[s,t])+exp(b[14] + b[29]*tempcov[s,t])+exp(b[15] + b[30]*tempcov[s,t]))
trans13[s,t+1] <- exp(b[5] + b[32]*tempcov[s,t]) / (1+exp(b[4] + b[31]*tempcov[s,t])+exp(b[5] + b[32]*tempcov[s,t])+exp(b[6] + b[33]*tempcov[s,t]))# gammaB-gammaAB
gammaAB[s,t+1] <- exp(b[6] + b[33]*tempcov[s,t]) / (1+exp(b[4] + b[31]*tempcov[s,t])+exp(b[5] + b[32]*tempcov[s,t])+exp(b[6] + b[33]*tempcov[s,t]))
trans42[s,t+1] <- exp(b[14] + b[29]*tempcov[s,t]) / (1+exp(b[13] + b[28]*tempcov[s,t])+exp(b[14] + b[29]*tempcov[s,t])+exp(b[15]+ b[30]*tempcov[s,t])) # epsilonB-epsilonAB
trans43[s,t+1] <- exp(b[15] + b[30]*tempcov[s,t]) / (1+exp(b[13] + b[28]*tempcov[s,t])+exp(b[14] + b[29]*tempcov[s,t]) + exp(b[15] + b[30]*tempcov[s,t]))
trans12[s,t+1] <- exp(b[4] + b[31]*tempcov[s,t]) / (1+exp(b[4] + b[31]*tempcov[s,t])+exp(b[5] + b[32]*tempcov[s,t])+exp(b[6] + b[33]*tempcov[s,t]))
nuA[s,t+1] <- exp(b[7] + b[25]*tempcov[s,t]) / (1+exp(b[7] + b[25]*tempcov[s,t])+exp(b[8]+ b[26]*tempcov[s,t])+exp(b[9] + b[27]*tempcov[s,t]))
omegaAB[s,t+1] <- exp(b[8] + b[26]*tempcov[s,t]) / (1+exp(b[7] + b[25]*tempcov[s,t])+exp(b[8]+ b[26]*tempcov[s,t])+exp(b[9] + b[27]*tempcov[s,t]))
etaB[s,t+1] <- exp(b[9] + b[27]*tempcov[s,t]) / (1+exp(b[7] + b[25]*tempcov[s,t])+exp(b[8]+ b[26]*tempcov[s,t])+exp(b[9] + b[27]*tempcov[s,t]))
nuB[s,t+1] <- exp(b[10] + b[33]*tempcov[s,t]) / (1+exp(b[10] + b[33]*tempcov[s,t])+exp(b[11]+ b[34]*tempcov[s,t])+exp(b[12] + b[35]*tempcov[s,t]))
omegaBA[s,t+1] <- exp(b[11] + b[34]*tempcov[s,t]) / (1+exp(b[10] + b[33]*tempcov[s,t])+exp(b[11]+ b[34]*tempcov[s,t])+exp(b[12] + b[35]*tempcov[s,t]))
etaA[s,t+1] <- exp(b[12] + b[35]*tempcov[s,t]) / (1+exp(b[10] + b[33]*tempcov[s,t])+exp(b[11]+ b[34]*tempcov[s,t])+exp(b[12] + b[35]*tempcov[s,t]))
}
}
}
if(P_effects=="both")
{
nuA<-matrix(0, nrow=R, ncol=N)
omegaAB<-matrix(0, nrow=R, ncol=N)
omegaBA<-matrix(0, nrow=R, ncol=N)
etaA<-matrix(0, nrow=R, ncol=N)
nuB<-matrix(0, nrow=R, ncol=N)
etaB<-matrix(0, nrow=R, ncol=N)
epsilonAB <- matrix(0, nrow=R, ncol=N)
trans13 <- matrix(0, nrow=R, ncol=N) # gammaB-gammaAB
gammaAB <- matrix(0, nrow=R, ncol=N)
trans42 <- matrix(0, nrow=R, ncol=N) # epsilonB-epsilonAB
trans43 <- matrix(0, nrow=R, ncol=N)
trans12 <- matrix(0, nrow=R, ncol=N)
for(s in 1:R)
{
for(t in 1: N)
{
epsilonAB[s,t] <- exp(b[13] + b[28]*tempcov[s,t]) / (1+exp(b[13] + b[28]*tempcov[s,t])+exp(b[14] + b[29]*tempcov[s,t])+exp(b[15] + b[30]*tempcov[s,t]))
trans13[s,t] <- exp(b[5] + b[32]*tempcov[s,t]) / (1+exp(b[4] + b[31]*tempcov[s,t])+exp(b[5] + b[32]*tempcov[s,t])+exp(b[6] + b[33]*tempcov[s,t]))# gammaB-gammaAB
gammaAB[s,t] <- exp(b[6] + b[33]*tempcov[s,t]) / (1+exp(b[4] + b[31]*tempcov[s,t])+exp(b[5] + b[32]*tempcov[s,t])+exp(b[6] + b[33]*tempcov[s,t]))
trans42[s,t] <- exp(b[14] + b[29]*tempcov[s,t]) / (1+exp(b[13] + b[28]*tempcov[s,t])+exp(b[14] + b[29]*tempcov[s,t])+exp(b[15]+ b[30]*tempcov[s,t])) # epsilonB-epsilonAB
trans43[s,t] <- exp(b[15] + b[30]*tempcov[s,t]) / (1+exp(b[13] + b[28]*tempcov[s,t])+exp(b[14] + b[29]*tempcov[s,t]) + exp(b[15] + b[30]*tempcov[s,t]))
trans12[s,t] <- exp(b[4] + b[31]*tempcov[s,t]) / (1+exp(b[4] + b[31]*tempcov[s,t])+exp(b[5] + b[32]*tempcov[s,t])+exp(b[6] + b[33]*tempcov[s,t]))
nuA[s,t] <- exp(b[7] + b[25]*tempcov[s,t]) / (1+exp(b[7] + b[25]*tempcov[s,t])+exp(b[8]+ b[26]*tempcov[s,t])+exp(b[9] + b[27]*tempcov[s,t]))
omegaAB[s,t] <- exp(b[8] + b[26]*tempcov[s,t]) / (1+exp(b[7] + b[25]*tempcov[s,t])+exp(b[8]+ b[26]*tempcov[s,t])+exp(b[9] + b[27]*tempcov[s,t]))
etaB[s,t] <- exp(b[9] + b[27]*tempcov[s,t]) / (1+exp(b[7] + b[25]*tempcov[s,t])+exp(b[8]+ b[26]*tempcov[s,t])+exp(b[9] + b[27]*tempcov[s,t]))
nuB[s,t] <- exp(b[10] + b[33]*tempcov[s,t]) / (1+exp(b[10] + b[33]*tempcov[s,t])+exp(b[11]+ b[34]*tempcov[s,t])+exp(b[12] + b[35]*tempcov[s,t]))
omegaBA[s,t] <- exp(b[11] + b[34]*tempcov[s,t]) / (1+exp(b[10] + b[33]*tempcov[s,t])+exp(b[11]+ b[34]*tempcov[s,t])+exp(b[12] + b[35]*tempcov[s,t]))
etaA[s,t] <- exp(b[12] + b[35]*tempcov[s,t]) / (1+exp(b[10] + b[33]*tempcov[s,t])+exp(b[11]+ b[34]*tempcov[s,t])+exp(b[12] + b[35]*tempcov[s,t]))
}
}
}
return(list(epsilonAB, trans42, nuA, omegaAB, trans12, etaA, gammaAB, trans43, nuB, omegaBA, trans13, etaB))
}