-
Notifications
You must be signed in to change notification settings - Fork 1
/
model_nimble_compPFA.r
1364 lines (1070 loc) · 34 KB
/
model_nimble_compPFA.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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
model.nimble <- paste("","
model.nimble <- nimbleCode({
# -------------------------------------------------------------------------
# ATLANTIC SALMON LIFE CYLE MODEL
# Etienne RIVOT & Maxime OLMOS
## @ Max Olmos
## Version 3/10/2020
# -------------------------------------------------------------------------
",sep="")
model.nimble <- paste(model.nimble,
"
# -------------------------------------------------------------------------
# Guide to principal variable names (critical stages and transitions)
# -------------------------------------------------------------------------
# Index
# -----------------------------
# t = 1:n - years
# r = 1,...,N : stock units
# N = 24
# N.NAC = 6
# N.NEAC = 18
# N1[t,r] Eggs
# N2[t,r] Total smolt produced by the spawning deposition N1[t,r]
# N3[t,k,r] Smolts of age k migrating year t
# N3.tot[t,r] Total smolts migrating year t (sum over ages k)
# N4[t,r] PFA
# N5[t,r] / N8[t,r] Maturing / non maturing PFA
# theta3[t,r] Survival N3.tot --> N4
# theta4[t,r] Proportion maturing N4 --> (N5 / N8)
# both theta3 and theta4 are modelled as multivariate random walk in the logit scale
# Maturing PFA --> Spawners 1SW
# -----------------------------
# N5[t,r] --> N6[t,r] Maturing PFA --> 1SW returns
# C5.NEAC... C5.NAC... Sequential catches on maturing fish from NEAC and NAC (see below)
# h5.NEAC... h5.NEAC... Associated harvest rates
# Different for NEAC and NAC (see below)
# N6[t,r] --> N7[t,r] Returns 1SW --> spawners 1SW
# Chw.1SW[t,r] h.hw.1SW[t,r] Homewater catches 1SW and harvest rates
# Non maturing PFA --> Spawners 2SW
# -----------------------------
# N8[t,r] --> N9[t,r] Non maturing PFA --> 2SW returns
# N8.1[t,r] Escapement fishery before WG
# N8.2[t,r] Escapement Greenland fishery
# C8.NEAC... C8.NAC... Sequential catches on maturing fish (see below)
# Different for NEAC and NAC (see below)
# h8.NEAC... h8.NEAC... Associated harvest rates
# N9[t,r] --> N10[t,r] Returns 2SW --> spawners 2SW
# Chw.2SW[t,r] h.hw.2SW[t,r] Homewater catches 2SW and harvest rates
# Catches, Harvest rates and escapement for sequential fisheries at sea
# Different for NEAC and NAC
# -----------------------------
# NEAC
# ----
# Maturing
# C5.NEAC.1[t,r] h5.NEAC.1[t,r] Faroes 1SW mature
# Non maturing
# C8.NEAC.1[t,r] h8.NEAC.1[t,r] Faroes fishery 1SW non mature
# C8.2[t,r] h8.2[t,r] Greenland fishery on 2SW (common with NAC)
# C8.NEAC.3[t+1,r] h8.NEAC.3[t,r] Faroes fishery on 2SW
# NAC
# ---
# Maturing
# C5.NAC.1[t,r] h5.NAC.1[t] NFL fishery on 1SW mature (harvest rate homogeneous among SU)
# C5.NAC.2[t,r] h5.NAC.2[t,r] LB fishery on 1SW mature
# C5.NAC.3[t,r] h5.NAC.3[t,r] Saint-Pierre et Miquelon fishery on 1SW mature # deleted in CYCLE PFA
# Non maturing
# C8.NAC.1[t,r] h8.NAC.1[t] NFL fishery on 1SW non mature (harvest rate homogeneous among SU)
# C8.2[t,r] h8.2[t,r] Greenland on 2SW (common with NEAC)
# C8.NAC.3[t+1,r] h8.NAC.3[t] NFL fishery on 2SW (harvest rate homogeneous among SU)
# C8.NAC.4[t,r] h8.NAC.4[t,r] LB fishery on 2SW
# C8.NAC.5[t,r] h8.NAC.5[t,r] SPM fishery on 2SW
# --------------------------------------------------------------------------
# --------------------------------------------------------------------------
# FIXED PARAMETERS AND TIGHT INFORMATIVE PRIORS
# --------------------------------------------------------------------------
# --------------------------------------------------------------------------
# Precision of additional logNormal noise on some demographic transitions
# modeled using logNormal process noise with a variance arbitrarily fixed
# to a very low value corresponding to a coefficient of variation
# CV.dummy = 0.01 (in the Constants)
tau.dummy <- 1/log(CV.dummy*CV.dummy + 1)
# Precision for LogNormal random noise on the average proportion of smolts ages
# CV.psm fixed to an arbitrary very low value CV.psm = 0.01 (in the Constants)
tau.psm <- 1/log(CV.psm*CV.psm + 1)
# Precision for logNormal obs error on Homewater catches
# Arbitrarily set to relatively low value in the data CV.hw = 0.05 (in the Constants)
tau.hw <- 1/log(CV.hw*CV.hw + 1)
# M = Monthly natural mortality rate M
# Considered constant after PFA
# Is applied for all stages between PFA and returns using duration deltat..
M <- E.M
# One can also use a tight informative prior
# ~LogNormal with E.M and CV.M fixed in the data
# tau.log.M <- 1/log(CV.M*CV.M + 1)
# E.log.M <- log(E.M) - 0.5/tau.log.M
# M ~ dlnorm(E.log.M,tau.log.M)
# Inter-annual stochasticity
# Eggs N1 --> total Smolts per cohorts N2
# CV.theta1 fixed to an arbitrarily value (in the Constants)
# Default value: CV.Theta1 = 0.4
tau.theta1 <- 1/log(CV.dummy*CV.dummy + 1)
",sep="")
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Prior on post-smolts survival - theta3 : Smolt N3.tot[t] --> PFA N4[t+1]
# and probability to mature the first year at sea - theta4 : N4[t] --> N5[t] + N8[t]
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
if(Cov==T)
{
model.nimble <- paste(model.nimble,"
# Time series modeled as MultiNormal with NxN variance-covariance matrix
# Note :
# Variance - covariance matrix is only estimated starting at year 6
# Year 1:5 - estimates are sensitive to prior on number of fish (smolts)
# not generated by the model
# --> Temporal variations modelled through independent random terms
# Variance-covariance not estimated
# Year 6:n : Start of multivariate random walk
# Post-smolts survival theta3 : N3.tot[t] --> N4[t+1]
# --------------------------------------------------------
# Year 1
for (r in 1:N)
{
for (t in 1:5)
{
logit.theta3[t,r] ~ dnorm(0,1)
}
}
# Years in 6:n
# Prior on the variance-covariance matrix
# Wishart prior on the precision (Omega and ddl fixed in the Constants
# Omega = identity(N) and ddl=N
tau.theta3[1:N, 1:N] ~ dwish(omega[1:N, 1:N],N)
# Multivariate random walk in the logit scale
for (t in 5:(n-1))
{
logit.theta3[t+1, 1:N] ~ dmnorm(logit.theta3[t,1:N], tau.theta3[1:N,1:N])
}
# Back to natural scale
for (r in 1:N)
{
for (t in 1:n)
{
logit(theta3[t,r]) <- logit.theta3[t,r]
}
}
# Probability early maturing PFA N4[t] --> N5[t] + N8[t]
# ------------------------------------------------------------
# Year 1
for (r in 1:N)
{
for (t in 1:5)
{
logit.theta4[t,r] ~ dnorm(0,1)
}
}
# Years in 6:n
# Prior on the variance-covariance matrix
# Wishart prior on the precision (Omega and ddl fixed in the Constants
# Omega = identity(N) and ddl=N
tau.theta4[1:N, 1:N] ~ dwish(omega[1:N, 1:N],N)
# Multivariate random walk in the logit scale
for (t in 5:(n-1))
{
logit.theta4[t+1, 1:N] ~ dmnorm(logit.theta4[t,1:N], tau.theta4[1:N,1:N])
}
# Back to natural scale
for (r in 1:N)
{
for (t in 1:n)
{
logit(theta4[t,r]) <- logit.theta4[t,r]
}
}
",sep="")
}# end if
if(noCov==T)
{
model.nimble<-paste(model.nimble,"
# Post-smolts survival theta3 : N3.tot[t] --> N4[t+1]
# --------------------------------------------------------
# Year 1
for (r in 1:N)
{
for (t in 1:5)
{
logit.theta3[t,r] ~ dnorm(0,1)
}
# Years in 6:n
sigma.theta3[r] ~ dunif(0,1)
tau.theta3[r] <- 1/pow(sigma.theta3[r],2)
# Multivariate random walk in the logit scale
for (t in 5:(n-1))
{
logit.theta3[t+1, r] ~ dnorm(logit.theta3[t,r], tau.theta3[r])
}
# Back to natural scale
for (t in 1:n)
{
logit(theta3[t,r]) <- logit.theta3[t,r]
}
}
# Probability early maturing PFA N4[t] --> N5[t] + N8[t]
# ------------------------------------------------------------
# Year 1
for (r in 1:N)
{
for (t in 1:5)
{
logit.theta4[t,r] ~ dnorm(0,1)
}
}
# Years in 6:n
# Prior on the variance-covariance matrix
for (r in 1:N)
{
sigma.theta4[r] ~ dunif(0,1)
tau.theta4[r] <- 1/pow(sigma.theta4[r],2)
# Multivariate random walk in the logit scale
for (t in 5:(n-1))
{
logit.theta4[t+1, r] ~ dnorm(logit.theta4[t,r], tau.theta4[r])
}
# Back to natural scale
for (t in 1:n)
{
logit(theta4[t,r]) <- logit.theta4[t,r]
}
}
",sep="")
} # end if
model.nimble<-paste(model.nimble,"
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# POPULATION DYNAMICS
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# N7, N10 = Number of spawners 1SW and 2SW respectively
# defined as = returns (N6 and N9, respect.) - Homewater catches
# ---------------------------------------------------------
# Harvest rate - Homewater fishery
# n is the last year of data for 2SW
# then (n-1) is the last year for which returns are updated by data
for (r in 1:N)
{
for (t in 1:(n-1))
{
h.hw.1SW[t,r] ~ dbeta(1,2)
}
for (t in 1:n)
{
h.hw.2SW[t,r] ~ dbeta(1,2)
}
}
# Harvest rate on delayed spawners
# Null for all SU except r=23 (RU.KW)
# Only r = 23 has a likelihood for those catches
for (t in 1:(n-1))
{
h.hw.1SW.delSp[t,23] ~ dbeta(1,2)
for (r in 1:22)
{
h.hw.1SW.delSp[t,r] <- 0
}
for (r in 24:N)
{
h.hw.1SW.delSp[t,r] <- 0
}
}
for (t in 1:n)
{
h.hw.2SW.delSp[t,23] ~ dbeta(1,2)
for (r in 1:22)
{
h.hw.2SW.delSp[t,r] <- 0
}
for (r in 24:N)
{
h.hw.2SW.delSp[t,r] <- 0
}
}
# Harvest rate for supplementary mortality in freshwater: only Scotland
# Null for all SUs
# except for EA_SC and WE_SC
for (t in 1:(n-1))
{
h.hw.sc.mort.1SW[t,12] ~ dbeta(1,2)
h.hw.sc.mort.1SW[t,13] ~ dbeta(1,2)
for (r in 1:11)
{
h.hw.sc.mort.1SW[t,r] <- 0
}
for (r in 14:N)
{
h.hw.sc.mort.1SW[t,r] <- 0
}
}
for (t in 1:(n))
{
h.hw.sc.mort.2SW[t,12] ~ dbeta(1,2)
h.hw.sc.mort.2SW[t,13] ~ dbeta(1,2)
for (r in 1:11)
{
h.hw.sc.mort.2SW[t,r] <- 0
}
for (r in 14:N)
{
h.hw.sc.mort.2SW[t,r] <- 0
}
}
# Catches and escapement
# -------------------------------
for (r in 1:N)
{
# 1SW
# --------
# Spawners (escapement)
# delspawn1SW is the proportion of fish that returns to homewated but spawns the year after (delayed spawners)
# must be considered AFTER the HW catches (see Run Reconstruction model NEAC, lines 3470)
# (1-delspawn1SW)*(N6[t] - HWcatches[t]) = number of fish N6[t] that will spawn year t
# delspawn1SW*(N6[t-1]-HWcatches[t-1]) = number of returns of the previous year (N6[t-1]) that will spawn year t (delayed)
# Those delayed spawners are subject to additional catches (only for r = 23 = RU.KW)
# First year
#N7[1,r] <- N6[1,r]*(1- h.hw.1SW[1,r])
N7[1,r] <- scot.pct.mort[1,r]*N6[1,r]*(1- h.hw.1SW[1,r])*(1-h.hw.sc.mort.1SW[1,r])
for (t in 2:(n-1))
{
# N7[t,r] <- N6[t,r]*(1- h.hw.1SW[t,r])*(1 - prop.delSp.1SW[t,r]) + N6[t-1,r]*(1- h.hw.1SW[t-1,r])*prop.delSp.1SW[t-1,r]*(1-h.hw.1SW.delSp[t,r])
N7[t,r] <-scot.pct.mort[t,r]*(N6[t,r]*(1- h.hw.1SW[t,r])*(1-h.hw.sc.mort.1SW[t,r])*(1 - prop.delSp.1SW[t,r]) + N6[t-1,r]*(1- h.hw.1SW[t-1,r])*prop.delSp.1SW[t-1,r]*(1-h.hw.1SW.delSp[t,r]))
}
# Homewater catches (likelihood until t = (n-1) only)
for (t in 1:(n-1))
{
Chw.1SW[t,r] <- h.hw.1SW[t,r] * N6[t,r]
}
# Catches on delayed spawners
# Will be 0 for all r except r = 23 = RU.KW
Chw.1SW.delSp[1,r] <- 1 # Dummy - No delayed spawners defined for the first year
for (t in 2:(n-1))
{
Chw.1SW.delSp[t,r] <- N6[t-1,r]*(1- h.hw.1SW[t-1,r])*prop.delSp.1SW[t-1,r]*h.hw.1SW.delSp[t,r]
}
# Catches on fish from scotland : freshwater mortality + EW catches specific on Scottish fish
for (t in 1:(n-1))
{
Chw.SC.killed1SW.m[t,r] <-scot.pct.mort[t,r] *N6[t,r]*(1- h.hw.1SW[t,r])*h.hw.sc.mort.1SW[t,r]
}
# 2SW
# --------
# Spawners (escapement)
# Idem as 1SW
# Additional stocking for USA (all 0 except r=6=USA)
# First year
#N10[1,r] <- N9[1,r]*(1-h.hw.2SW[1,r])
N10[1,r] <- scot.pct.mort[1,r]*N9[1,r]*(1-h.hw.2SW[1,r])*(1-h.hw.sc.mort.2SW[1,r])
for(t in 2:n)
{
#N10[t,r] <- N9[t,r]*(1- h.hw.2SW[t,r])*(1 - prop.delSp.2SW[t,r]) + N9[t-1,r]*(1- h.hw.2SW[t-1,r])*prop.delSp.2SW[t-1,r]*(1-h.hw.2SW.delSp[t,r]) + Stocking.2SW[t,r]
N10[t,r] <- scot.pct.mort[t,r]*(N9[t,r]*(1- h.hw.2SW[t,r])*(1 - prop.delSp.2SW[t,r])*(1-h.hw.sc.mort.2SW[t,r]) + N9[t-1,r]*(1- h.hw.2SW[t-1,r])*prop.delSp.2SW[t-1,r]*(1-h.hw.2SW.delSp[t,r])) + Stocking.2SW[t,r]
}
# Homewater catches (likelihood until t = n)
for (t in 1:n)
{
Chw.2SW[t,r] <- h.hw.2SW[t,r]*N9[t,r]
}
# Catches on delayed spawners 2SW
# Will be 0 for all r except r = 23 = RU.KW
Chw.2SW.delSp[1,r] <- 1 # Dummy - No delayed spawners defined for the first year
for (t in 2:n)
{
Chw.2SW.delSp[t,r] <- N9[t-1,r]*(1- h.hw.2SW[t-1,r])*prop.delSp.2SW[t-1,r]*h.hw.2SW.delSp[t,r]
}
# Catches on fish from scotland : freshwater mortality + EW catches specific on Scottish fish
for (t in 1:(n))
{
Chw.SC.killed2SW.m[t,r] <- scot.pct.mort[t,r]*N9[t,r]*(1- h.hw.2SW[t,r])*h.hw.sc.mort.2SW[t,r]
}
}
# N1: Number of eggs from spawners --> N2: total Smolts per cohort
# ---------------------------------------------------------
for (r in 1:N)
{
for (t in 1:(n-1))
{
# N1: nb eggs
# -----------------
N1[t,r] <- N7[t,r]*eggs[1,r,t] + N10[t,r]*eggs[2,r,t]
N2[t,r] <- E.theta1*N1[t,r]
# N1 --> N2 (Smolts)
# -----------------
# Mean survival known and fixed to E.theta1 (Constants)
# CV.theta1 fixed in the data set (Constants)
# Without density dependence
#log.N2.m[t,r] <- log(a*N1[t,r]) - 0.5/tau.theta1
#log.N2.m[t,r] <- log(N1[t,r]) - 0.5/tau.theta1
# With density dependence
# theta1.ddp[t,r] <- a/(1+B[r]*N1[t,r])
# log.N2.m[t,r] <- log(theta1.ddp[t,r]*N1[t,r]) - 0.5/tau.theta1
#N2[t,r] ~ dlnorm(log.N2.m[t,r],tau.theta1)
# Surv.eggs is for monitoring
#Surv.eggs[t,r] <- N2[t,r]/N1[t,r]
}
}
# N3: Smolts distribution by age class (6 age classes)
# ---------------------------------------------------------
# Dirichlet Informative prior
# Information equivalent to the one gained with a sample size = N.Sample.sm
# N.Sample.sm fixed to 100 in the Constants
# To improve computational speed, the Dirichlet is written with Gamma
for (r in 1:N)
{
# Proportion of smolts ages
# k = smolt ages from 1 to nSm=6
for (k in 1:nSm)
{
# +1 is needed to avoid mu.psm = 0 (would eventually crash the gamma()
mu.psm[k,r] <- p.smolt[k,r]*N.Sample.sm + 1
for (t in 1:n)
{
# psm.stoch[t,1:nSm,r] ~ ddirich(mu.psm[1:nSm,r])
prop_gamma[t,k,r] ~ dgamma(mu.psm[k,r],1)
psm.stoch[t,k,r] <- prop_gamma[t,k,r]/sum(prop_gamma[t,1:nSm,r])
}
}
# N3
for (t in 1:(n-1))
{
for (k in 1:nSm)
{
N3[t+1+k,k,r] <- psm.stoch[t,k,r]*N2[t,r]
}
# N3 tot : Total smolt migrating each year t
N3.tot[t,r] <- sum(N3[t,1:nSm,r])
}
# Dummy - not used in the model - no effect on the model
# Just to be sure the array N3 has values in all cells (no cells with NA)
for (s in 1:(nSm-1))
{
for (k in 1:s)
{
N3[n+1+s,k,r] <- 99
}
}
}
# N4 : Smolt --> PFA (N4)
# From N3.tot and survival theta3
# ---------------------------------------------------------
for (r in 1:N)
{
for (t in 1:(n-1))
{
log.N4.m[t+1,r] <- log(theta3[t,r]*N3.tot[t,r]) - 0.5/tau.dummy
N4[t+1,r] ~ dlnorm(log.N4.m[t+1,r], tau.dummy)
}
}
# N5 : PFA maturing during the first year at sea
# From N4 (PFA) and theta4 = proba. maturing the first year at sea
# ---------------------------------------------------------
for (r in 1:N)
{
for (t in 1:n)
{
log.N5.m[t,r] <- log(N4[t,r] * theta4[t,r]) - 0.5/tau.dummy
N5[t,r] ~ dlnorm(log.N5.m[t,r], tau.dummy)
# N8 : PFA non maturing after the first year at sea
# From N4 (PFA) and (1-theta4)
# ---------------------------------------------------------
log.N8.m[t,r] <- log(N4[t,r] * (1-theta4[t,r])) - 0.5/tau.dummy
N8[t,r] ~ dlnorm(log.N8.m[t,r], tau.dummy)
}
}
# N5 -> N6
# MATURING FISH returning in homewater as 1SW fish
# ---------------------------------------------------------
# NEAC - Faroes fisheries and returns to N6
# -----------------------------------------
# Natural mortality between sequential fisheries
# PFA -> Faroes m
theta5.1.NEAC <- exp(-M*deltat.5.1.NEAC)
# Faroes -> returns
theta5.2.NEAC <- exp(-M*(deltat.5.2.NEAC))
# Exploitation rate - Faroes 1SWm
# Separate for each SU
for (r in 1:N.NEAC)
{
for(t in 1:(n-1))
{
h5.NEAC.1[t,r] ~ dbeta(1,2)
}
}
# Catches Faroes 1SWm
for (t in 1:(n-1))
{
for (r in 1:N.NEAC)
{
# Catches
C5.NEAC.1[t,r] <- theta5.1.NEAC * h5.NEAC.1[t,r] * N5[t,(r+N.NAC)]
# Proportion to allocate the catches transformed as
# parameter for the Dirichlet likelihood
mu.F1.NEAC.m[t,r] <- (C5.NEAC.1[t,r]/C5.NEAC.1.tot[t])*N.Sample[t]
}
# Total Catches Faroes 1SW maturing
C5.NEAC.1.tot[t] <- sum(C5.NEAC.1[t,1:N.NEAC])
}
# N6 : Returns 1SW NEAC
for (r in 1:N.NEAC)
{
for(t in 1:(n-1))
{
N6[t,r+N.NAC] <- theta5.2.NEAC * theta5.1.NEAC * (1-h5.NEAC.1[t,r]) * N5[t,r+N.NAC]
}
}
# NAC - LB/NF and SPM fisheries and returns to N6
# ------------------------------------------------
# Natural mortality between sequential fisheries
# PFA to Labrador/NFDL 1SWm
theta5.1.NAC <- exp(-deltat.5.1.NAC*M)
# Labrador/NFDL -> SPM
theta5.2.NAC <- exp(-deltat.5.2.NAC*M)
# Prior for harvest rates
for (t in 1:(n-1))
{
# NFL fishery on 1SW mature (harvest rate homogeneous among SU)
# h5.NAC.1[t]
h5.NAC.1[t] ~ dbeta(1,2)
# LB fishery on 1SW mature
# h5.NAC.2[t,r]
# h homogeneous among all r except separate h for Labrador (r=1)
h5.NAC.2.other[t] ~ dbeta(1,2)
h5.NAC.2.lab[t] ~ dbeta(1,2)
for(r in 2:N.NAC)
{
h5.NAC.2[t,r] <- h5.NAC.2.other[t]
}
# Separate h for Labrador (r=1)
h5.NAC.2[t,1] <- h5.NAC.2.lab[t]
# Saint-Pierre et Miquelon fishery on 1SW mature
# h5.NAC.3[t,r]
# h homogeneous among all r except h=0 for Labrador (r=1)
#h5.NAC.3.other[t] ~ dbeta(1,2)
#for(r in 2:N.NAC)
#{
#h5.NAC.3[t,r] <- h5.NAC.3.other[t]
#}
# Separate h for Labrador (r=1)
#h5.NAC.3[t,1] <- 0
}
# Sequential catches at sea
for (t in 1:(n-1))
{
for (r in 1:N.NAC)
{
# PFA --> NFL fishery on 1SW mature
C5.NAC.1[t,r] <- h5.NAC.1[t] * theta5.1.NAC * N5[t,r]
# LB fishery on 1SW mature
C5.NAC.2[t,r] <- h5.NAC.2[t,r] * (1-h5.NAC.1[t]) * theta5.1.NAC * N5[t,r]
}
# Total catches
C5.NAC.1.tot[t] <- sum(C5.NAC.1[t,1:N.NAC])
C5.NAC.2.other[t] <- sum(C5.NAC.2[t,2:N.NAC])
C5.NAC.2.lab[t] <- C5.NAC.2[t,1]
}
# N6: Returns 1SW NAC
# Survival after sequential catches + natural mortality theta5.1
for (r in 1:N.NAC)
{
for (t in 1:(n-1))
{
N6[t,r] <- theta5.2.NAC * (1-h5.NAC.2[t,r]) * (1-h5.NAC.1[t]) * theta5.1.NAC * N5[t,r]
}
}
# NON MATURING FISH
# N8 -> N8.1 (escapement before Greenland Fishery)
# ---------------------------------------------------------
# NEAC
# Survival rate theta8.1.NEAC for the transition PFA --> Faroes
# followed by Faroes fisheries on non mature fish 1SWnm
# Harvest rate h8.SNEAC.1, variable across r
# ------------------------------------------
# Survival rate before Faroes fishery
theta8.1.NEAC <- exp(-M*(deltat.8.1.NEAC))
# Prior on exploitation rate
# Separate for all regions r
for (t in 1:(n-1))
{
for (r in 1:N.NEAC)
{
h8.NEAC.1[t,r] ~ dbeta(1,2)
}
}
# Catches Faroes 1SW non maturing
for (t in 1:(n-1))
{
for (r in 1:N.NEAC)
{
# Catches
C8.NEAC.1[t,r] <- h8.NEAC.1[t,r] * theta8.1.NEAC * N8[t,r+N.NAC]
# Proportion to allocate the catches transformed as
# parameters for the Dirichlet likelihood
mu.F1.NEAC.nm[t,r] <- (C8.NEAC.1[t,r]/C8.NEAC.1.tot[t]) * N.Sample[t]
}
# Total catches
C8.NEAC.1.tot[t] <- sum(C8.NEAC.1[t,1:N.NEAC])
}
# Transition N8 --> N8.1
for (t in 1:(n-1))
{
for (r in 1:N.NEAC)
{
N8.1[t,r+N.NAC] <- theta8.1.NEAC * (1-h8.NEAC.1[t,r]) * N8[t,r+N.NAC]
}
}
# NAC
# Survival theta8.1.NAC for the transition PFA --> LBandNF
# followed by LBandNF fisheries on 1SW non maturing
# Harvest rate h8.NAC.1, homogeneous across r
# ---------------------------------------------
# Survival rate
theta8.1.NAC <- exp(-M * deltat.8.1.NAC)
# Prior on exploitation rate
# h homogeneous across the 6 regions
for (t in 1:(n-1))
{
h8.NAC.1[t] ~ dbeta(1,2)
}
# Catches 1SW non maturing
for (t in 1:(n-1))
{
for (r in 1:N.NAC)
{
C8.NAC.1[t,r] <- h8.NAC.1[t] * theta8.1.NAC * N8[t,r]
}
# Total catches
C8.NAC.1.tot[t] <- sum(C8.NAC.1[t,1:N.NAC])
}
# Transitions N8 --> N8.1
for (t in 1:(n-1))
{
for (r in 1:N.NAC)
{
N8.1[t,r] <- (1-h8.NAC.1[t]) * theta8.1.NAC * N8[t,r]
}
}
# N8.1 --> N8.2
# Survival theta8.2[r] for NAC and NEAC
# Followed by Greenland Fisheries on NAC + NEAC stocks
# Harvest rate h8.2
# ---------------------------------------------------------
# Survival rate before Greenland Fishery - theta8.2[r]
# calculated with deltat.8.2.NAC and deltat.8.2.NEAC
for (r in 1:N.NAC)
{
theta8.2[r] <- exp(-M * (deltat.8.2.NAC))
}
for (r in 1:N.NEAC)
{
theta8.2[N.NAC+r] <- exp(-M * (deltat.8.2.NEAC))
}
# Proportion to allocate the catches between NEAC and NAC complexes
for (t in 1:(n-1))
{
for (k in 1:2)
{
mu.Gld.comp[t,k] <- (C8.2.comp[t,k]/C8.2.tot[t])*N.Sample[t]
}
#Total catches
C8.2.tot[t] <- sum(C8.2.comp[t,1:2])
}
# Exploitation rates at West Greenland Fishery
# harvest rates all different for SUs NAC + NEAC
# NAC
for(t in 1:(n-1))
{
for (r in 1:N)
{
h8.2[t,r] ~ dbeta(1,2)
}
}
for (t in 1:(n-1))
{
for (r in 1:N.NAC)
{
mu.Gld.NAC[t,r] <- (C8.2[t,r]/(C8.2.comp[t,2]))*N.Sample[t]
}
for (r in 1:N.NEAC)
{
mu.Gld.NEAC[t,r] <- (C8.2[t,(r+N.NAC)]/(C8.2.comp[t,1]))*N.Sample[t]
}
}
# Catches Greenland per SU
for (t in 1:(n-1))
{
for (r in 1:N)
{
C8.2[t,r] <- h8.2[t,r] * N8.1[t,r]*theta8.2[r]
}
# Total catches per complexe
C8.2.comp[t,2] <- sum(C8.2[t,1:N.NAC])
C8.2.comp[t,1] <- sum(C8.2[t,(1+N.NAC):N])
}
# Escapement W Greenland fishery N8.1 --> N8.2
for (t in 1:(n-1))
{
for (r in 1:N)
{
N8.2[t,r] <- theta8.2[r] * (1-h8.2[t,r]) * N8.1[t,r]
}
}
# AFTER Greenland Fisheries
# From N8.2 to returns as 2SW fish N9
# ---------------------------------------------------------
# NEAC
# Faroes 2SW fisheries and return
# ---------------------------------------------------------
# Survival rate
# Greenland -> Faroes 2SW
theta8.2.1.NEAC <- exp(-M * (deltat.8.2.1.NEAC))
# Faroes -> Returns
theta8.2.2.NEAC <- exp(-M * (deltat.8.2.2.NEAC))
# Exploitation rate different for all stock units
# t = 1 are not used
for (r in 1:N.NEAC)
{
for(t in 1:n)
{
h8.NEAC.3[t,r] ~ dbeta(1,2)
}
}
# Catches
for (r in 1:N.NEAC)
{
for(t in 1:(n-1))
{
C8.NEAC.3[t+1,r] <- h8.NEAC.3[t+1,r] * theta8.2.1.NEAC * N8.2[t,r+N.NAC]
}
}
# Total catches
for(t in 1:(n-1))
{
C8.NEAC.3.tot[t+1] <- sum(C8.NEAC.3[t+1,1:N.NEAC])
}
# Proportion to allocate the catches transformed as
# parameters for the Dirichlet likelihood
# Starts only at year t=2
for(t in 1:(n-1))
{
for ( r in 1:N.NEAC)
{
mu.F2.NEAC[t+1,r] <- (C8.NEAC.3[t+1,r]/C8.NEAC.3.tot[t+1])*N.Sample[t+1]
}
}
# Returns 2SW NEAC
for (r in 1: N.NEAC)
{
for(t in 1:(n-1))
{
N9[t+1,r+N.NAC] <- theta8.2.2.NEAC * theta8.2.1.NEAC * (1-h8.NEAC.3[t+1,r]) * N8.2[t,r+N.NAC]
}
}
# Dummy - not used - just to avoid NA in array
for (r in 1:N.NEAC)
{
C8.NEAC.3[1,r] <- 99
mu.F2.NEAC[1,r] <- C8.NEAC.3[1,r]/C8.NEAC.3.tot[1]
}
C8.NEAC.3.tot[1] <- sum(C8.NEAC.3[1,1:N.NEAC])
# NAC
# Sequential fisheries LB/NF and SPM
# ----------------------------------------------
# Greenland -> Labrador/NF 2SW
theta8.2.1.NAC <- exp(-M * deltat.8.2.1.NAC)
# Labrador -> SPM 2SW
theta8.2.2.NAC <- exp(-M * deltat.8.2.2.NAC)
# SPM -> returns 2SW
#theta8.2.3.NAC <- exp(-M * deltat.8.2.3.NAC)
# NF on 2SW
# h8.NAC.3
# Homogeneous across the 6 regions