-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLandscapeProject.R
684 lines (481 loc) · 20.5 KB
/
LandscapeProject.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
#### Spatial Ecology Project ####
#### Libraries ####
library(dplyr)
######## Activity Centers Per Individual and Densities Per Species Per Site #########
####### Site A, CPIC ########
# Load MCMC Data
load("Results/JAGS/cpic_A_mcmc.RData")
# combine chains
df_mcmc_cpic_A <- as.data.frame(cpic_A_mcmc[[1]])
for(i in 2:length(cpic_A_mcmc)) {
df_mcmc_cpic_A <- bind_rows(df_mcmc_cpic_A, as.data.frame(cpic_A_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cpic_A <- df_mcmc_cpic_A %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cpic_A <- centers_cpic_A[1:36, ]
hist(centers[1:36, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cpic_A <- df_mcmc_cpic_A$density[501:1000] #densities per iteration after burnin
mean_density_cpic_A <- mean(densities_cpic_A) # Mean # turtles per 100 meters
estimated_N_cpic_A <- df_mcmc_cpic_A$N[501:1000]
mean_est_N_cpic_A <- mean(estimated_N_cpic_A) # Mean # turtles over trap area (+ boundary)
mean_est_N_cpic_A/mean_density_cpic_A
###################################################
############ Site A, CSER ##############
load("Results/JAGS/cser_A_mcmc.RData")
# combine chains
df_mcmc_cser_A <- as.data.frame(cser_A_mcmc[[1]])
for(i in 2:length(cser_A_mcmc)) {
df_mcmc_cser_A <- bind_rows(df_mcmc_cser_A, as.data.frame(cser_A_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cser_A <- df_mcmc_cser_A %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cser_A <- centers_cser_A[1:36, ]
hist(centers[1:n_indA, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cser_A <- df_mcmc_cser_A$density[501:1000] #densities per iteration after burnin
mean_density_cser_A <- mean(densities_cser_A) # Mean # turtles per 100 meters
estimated_N_cser_A <- df_mcmc_cser_A$N[501:1000]
mean_est_N_cser_A <- mean(estimated_N_cser_A) # Mean # turtles over trap area (+ boundary)
mean_est_N_cser_A/mean_density_cser_A
####### Site C, CPIC ########
# Load MCMC Data
load("Results/JAGS/cpic_C_mcmc.RData")
# combine chains
df_mcmc_cpic_C <- as.data.frame(cpic_C_mcmc[[1]])
for(i in 2:length(cpic_C_mcmc)) {
df_mcmc_cpic_C <- bind_rows(df_mcmc_cpic_C, as.data.frame(cpic_C_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cpic_C <- df_mcmc_cpic_C %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cpic_C <- centers_cpic_C[1:n_indC, ]
hist(centers[1:n_indC, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cpic_C <- df_mcmc_cpic_C$density[501:1000] #densities per iteration after burnin
mean_density_cpic_C <- mean(densities_cpic_C) # Mean # turtles per 100 meters
estimated_N_cpic_C <- df_mcmc_cpic_C$N[501:1000]
mean_est_N_cpic_C <- mean(estimated_N_cpic_C) # Mean # turtles over trap area (+ boundary)
mean_est_N_cpic_C/mean_density_cpic_C
####### Site C, CSER ########
# Load MCMC Data
load("Results/JAGS/cser_C_mcmc.RData")
# combine chains
df_mcmc_cser_C <- as.data.frame(cser_C_mcmc[[1]])
for(i in 2:length(cser_C_mcmc)) {
df_mcmc_cser_C <- bind_rows(df_mcmc_cser_C, as.data.frame(cser_C_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cser_C <- df_mcmc_cser_C %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cser_C <- centers_cser_C[1:n_indC, ]
hist(centers[1:n_indC, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cser_C <- df_mcmc_cser_C$density[501:1000] #densities per iteration after burnin
mean_density_cser_C <- mean(densities_cser_C) # Mean # turtles per 100 meters
estimated_N_cser_C <- df_mcmc_cser_C$N[501:1000]
mean_est_N_cser_C <- mean(estimated_N_cser_C) # Mean # turtles over trap area (+ boundary)
mean_est_N_cser_C/mean_density_cser_C
####### Site D, CPIC ########
load("Results/JAGS/cpic_D_mcmc.RData")
# combine chains
df_mcmc_cpic_D <- as.data.frame(cpic_D_mcmc[[1]])
for(i in 2:length(cpic_D_mcmc)) {
df_mcmc_cpic_D <- bind_rows(df_mcmc_cpic_D, as.data.frame(cpic_D_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cpic_D <- df_mcmc_cpic_D %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cpic_D <- centers_cpic_D[1:n_indD, ]
hist(centers[1:n_indD, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cpic_D <- df_mcmc_cpic_D$density[501:1000] #densities per iteration after burnin
mean_density_cpic_D <- mean(densities_cpic_D) # Mean # turtles per 100 meters
estimated_N_cpic_D <- df_mcmc_cpic_D$N[501:1000]
mean_est_N_cpic_D <- mean(estimated_N_cpic_D) # Mean # turtles over trap area (+ boundary)
mean_est_N_cpic_D/mean_density_cpic_D
####### Site E, CPIC ########
load("Results/JAGS/cpic_E_mcmc.RData")
# combine chains
df_mcmc_cpic_E <- as.data.frame(cpic_E_mcmc[[1]])
for(i in 2:length(cpic_E_mcmc)) {
df_mcmc_cpic_E <- bind_rows(df_mcmc_cpic_E, as.data.frame(cpic_E_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cpic_E <- df_mcmc_cpic_E %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cpic_E <- centers_cpic_E[1:n_indE, ]
hist(centers[1:n_indE, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cpic_E <- df_mcmc_cpic_E$density[501:1000] #densities per iteration after burnin
mean_density_cpic_E <- mean(densities_cpic_E) # Mean # turtles per 100 meters
estimated_N_cpic_E <- df_mcmc_cpic_E$N[501:1000]
mean_est_N_cpic_E <- mean(estimated_N_cpic_E) # Mean # turtles over trap area (+ boundary)
mean_est_N_cpic_E/mean_density_cpic_E
####### Site E, CSER ########
load("Results/JAGS/cser_E_mcmc.RData")
# combine chains
df_mcmc_cser_E <- as.data.frame(cser_E_mcmc[[1]])
for(i in 2:length(cser_E_mcmc)) {
df_mcmc_cser_E <- bind_rows(df_mcmc_cser_E, as.data.frame(cser_E_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cser_E <- df_mcmc_cser_E %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cser_E <- centers_cser_E[1:n_indE, ]
hist(centers[1:n_indE, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cser_E <- df_mcmc_cser_E$density[501:1000] #densities per iteration after burnin
mean_density_cser_E <- mean(densities_cser_E) # Mean # turtles per 100 meters
estimated_N_cser_E <- df_mcmc_cser_E$N[501:1000]
mean_est_N_cser_E <- mean(estimated_N_cser_E) # Mean # turtles over trap area (+ boundary)
mean_est_N_cser_E/mean_density_cser_E
####### Site F, CSER ########
load("Results/JAGS/cser_F_mcmc.RData")
# combine chains
df_mcmc_cser_F <- as.data.frame(cser_F_mcmc[[1]])
for(i in 2:length(cser_F_mcmc)) {
df_mcmc_cser_F <- bind_rows(df_mcmc_cser_F, as.data.frame(cser_F_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cser_F <- df_mcmc_cser_F %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cser_F <- centers_cser_F[1:n_indF, ]
hist(centers[1:n_indF, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cser_F <- df_mcmc_cser_F$density[501:1000] #densities per iteration after burnin
mean_density_cser_F <- mean(densities_cser_F) # Mean # turtles per 100 meters
estimated_N_cser_F <- df_mcmc_cser_F$N[501:1000]
mean_est_N_cser_F <- mean(estimated_N_cser_F) # Mean # turtles over trap area (+ boundary)
mean_est_N_cser_F/mean_density_cser_F
####### Site F, CPIC ########
load("Results/JAGS/cpic_F_mcmc.RData")
# combine chains
df_mcmc_cpic_F <- as.data.frame(cpic_F_mcmc[[1]])
for(i in 2:length(cpic_F_mcmc)) {
df_mcmc_cpic_F <- bind_rows(df_mcmc_cpic_F, as.data.frame(cpic_F_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cpic_F <- df_mcmc_cpic_F %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cpic_F <- centers_cpic_F[1:n_indF, ]
hist(centers[1:n_indF, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cpic_F <- df_mcmc_cpic_F$density[501:1000] #densities per iteration after burnin
mean_density_cpic_F <- mean(densities_cpic_F) # Mean # turtles per 100 meters
estimated_N_cpic_F <- df_mcmc_cpic_F$N[501:1000]
mean_est_N_cpic_F <- mean(estimated_N_cpic_F) # Mean # turtles over trap area (+ boundary)
mean_est_N_cpic_F/mean_density_cpic_F
####### Site G, CPIC ########
load("Results/JAGS/cpic_G_mcmc.RData")
# combine chains
df_mcmc_cpic_G <- as.data.frame(cpic_G_mcmc[[1]])
for(i in 2:length(cpic_G_mcmc)) {
df_mcmc_cpic_G <- bind_rows(df_mcmc_cpic_G, as.data.frame(cpic_G_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cpic_G <- df_mcmc_cpic_G %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cpic_G <- centers_cpic_G[1:n_indG, ]
hist(centers[1:n_indG, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cpic_G <- df_mcmc_cpic_G$density[501:1000] #densities per iteration after burnin
mean_density_cpic_G <- mean(densities_cpic_G) # Mean # turtles per 100 meters
estimated_N_cpic_G <- df_mcmc_cpic_G$N[501:1000]
mean_est_N_cpic_G <- mean(estimated_N_cpic_G) # Mean # turtles over trap area (+ boundary)
mean_est_N_cpic_G/mean_density_cpic_G
####### Site G, CSER ########
load("Results/JAGS/cser_G_mcmc.RData")
# combine chains
df_mcmc_cser_G <- as.data.frame(cser_G_mcmc[[1]])
for(i in 2:length(cser_G_mcmc)) {
df_mcmc_cser_G <- bind_rows(df_mcmc_cser_G, as.data.frame(cser_G_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cser_G <- df_mcmc_cser_G %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cser_G <- centers_cser_G[1:n_indG, ]
hist(centers[1:n_indG, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cser_G <- df_mcmc_cser_G$density[501:1000] #densities per iteration after burnin
mean_density_cser_G <- mean(densities_cser_G) # Mean # turtles per 100 meters
estimated_N_cser_G <- df_mcmc_cser_G$N[501:1000]
mean_est_N_cser_G <- mean(estimated_N_cser_G) # Mean # turtles over trap area (+ boundary)
mean_est_N_cser_G/mean_density_cser_G
####### Site J, CPIC ########
load("Results/JAGS/cpic_J_mcmc.RData")
# combine chains
df_mcmc_cpic_J <- as.data.frame(cpic_J_mcmc[[1]])
for(i in 2:length(cpic_J_mcmc)) {
df_mcmc_cpic_J <- bind_rows(df_mcmc_cpic_J, as.data.frame(cpic_J_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cpic_J <- df_mcmc_cpic_J %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cpic_J <- centers_cpic_J[1:n_indJ, ]
hist(centers[1:n_indJ, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cpic_J <- df_mcmc_cpic_J$density[501:1000] #densities per iteration after burnin
mean_density_cpic_J <- mean(densities_cpic_J) # Mean # turtles per 100 meters
estimated_N_cpic_J <- df_mcmc_cpic_J$N[501:1000]
mean_est_N_cpic_J <- mean(estimated_N_cpic_J) # Mean # turtles over trap area (+ boundary)
mean_est_N_cpic_J/mean_density_cpic_J
####### Site J, CSER ########
load("Results/JAGS/cser_J_mcmc.RData")
# combine chains
df_mcmc_cser_J <- as.data.frame(cser_J_mcmc[[1]])
for(i in 2:length(cser_J_mcmc)) {
df_mcmc_cser_J <- bind_rows(df_mcmc_cser_J, as.data.frame(cser_J_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cser_J <- df_mcmc_cser_J %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cser_J <- centers_cser_J[1:n_indJ, ]
hist(centers[1:n_indJ, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cser_J <- df_mcmc_cser_J$density[501:1000] #densities per iteration after burnin
mean_density_cser_J <- mean(densities_cser_J) # Mean # turtles per 100 meters
estimated_N_cser_J <- df_mcmc_cser_J$N[501:1000]
mean_est_N_cser_J <- mean(estimated_N_cser_J) # Mean # turtles over trap area (+ boundary)
mean_est_N_cser_J/mean_density_cser_J
####### Site K, CPIC ########
load("Results/JAGS/cpic_K_mcmc.RData")
# combine chains
df_mcmc_cpic_K <- as.data.frame(cpic_K_mcmc[[1]])
for(i in 2:length(cpic_K_mcmc)) {
df_mcmc_cpic_K <- bind_rows(df_mcmc_cpic_K, as.data.frame(cpic_K_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cpic_K <- df_mcmc_cpic_K %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cpic_K <- centers_cpic_K[1:n_indK, ]
hist(centers[1:n_indK, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cpic_K <- df_mcmc_cpic_K$density[501:1000] #densities per iteration after burnin
mean_density_cpic_K <- mean(densities_cpic_K) # Mean # turtles per 100 meters
estimated_N_cpic_K <- df_mcmc_cpic_K$N[501:1000]
mean_est_N_cpic_K <- mean(estimated_N_cpic_K) # Mean # turtles over trap area (+ boundary)
mean_est_N_cpic_K/mean_density_cpic_K
####### Site L, CPIC ########
load("Results/JAGS/cpic_L_mcmc.RData")
# combine chains
df_mcmc_cpic_L <- as.data.frame(cpic_L_mcmc[[1]])
for(i in 2:length(cpic_L_mcmc)) {
df_mcmc_cpic_L <- bind_rows(df_mcmc_cpic_L, as.data.frame(cpic_L_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cpic_L <- df_mcmc_cpic_L %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cpic_L <- centers_cpic_L[1:n_indL, ]
hist(centers[1:n_indL, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cpic_L <- df_mcmc_cpic_L$density[501:1000] #densities per iteration after burnin
mean_density_cpic_L <- mean(densities_cpic_L) # Mean # turtles per 100 meters
estimated_N_cpic_L <- df_mcmc_cpic_L$N[501:1000]
mean_est_N_cpic_L <- mean(estimated_N_cpic_L) # Mean # turtles over trap area (+ boundary)
mean_est_N_cpic_L/mean_density_cpic_L
####### Site M, CPIC ########
load("Results/JAGS/cpic_M_mcmc.RData")
# combine chains
df_mcmc_cpic_M <- as.data.frame(cpic_M_mcmc[[1]])
for(i in 2:length(cpic_M_mcmc)) {
df_mcmc_cpic_M <- bind_rows(df_mcmc_cpic_M, as.data.frame(cpic_M_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cpic_M <- df_mcmc_cpic_M %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cpic_M <- centers_cpic_M[1:n_indM, ]
hist(centers[1:n_indM, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cpic_M <- df_mcmc_cpic_M$density[501:1000] #densities per iteration after burnin
mean_density_cpic_M <- mean(densities_cpic_M) # Mean # turtles per 100 meters
estimated_N_cpic_M <- df_mcmc_cpic_M$N[501:1000]
mean_est_N_cpic_M <- mean(estimated_N_cpic_M) # Mean # turtles over trap area (+ boundary)
mean_est_N_cpic_M/mean_density_cpic_M
####### Site M, CSER ########
load("Results/JAGS/cser_M_mcmc.RData")
# combine chains
df_mcmc_cser_M <- as.data.frame(cser_M_mcmc[[1]])
for(i in 2:length(cser_M_mcmc)) {
df_mcmc_cser_M <- bind_rows(df_mcmc_cser_M, as.data.frame(cser_M_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cser_M <- df_mcmc_cser_M %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cser_M <- centers_cser_M[1:n_indM, ]
hist(centers[1:n_indM, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cser_M <- df_mcmc_cser_M$density[501:1000] #densities per iteration after burnin
mean_density_cser_M <- mean(densities_cser_M) # Mean # turtles per 100 meters
estimated_N_cser_M <- df_mcmc_cser_M$N[501:1000]
mean_est_N_cser_M <- mean(estimated_N_cser_M) # Mean # turtles over trap area (+ boundary)
mean_est_N_cser_M/mean_density_cser_M
####### Site N, CPIC ########
load("Results/JAGS/cpic_N_mcmc.RData")
# combine chains
df_mcmc_cpic_N <- as.data.frame(cpic_N_mcmc[[1]])
for(i in 2:length(cpic_N_mcmc)) {
df_mcmc_cpic_N <- bind_rows(df_mcmc_cpic_N, as.data.frame(cpic_N_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cpic_N <- df_mcmc_cpic_N %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cpic_N <- centers_cpic_N[1:n_indN, ]
hist(centers[1:n_indN, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cpic_N <- df_mcmc_cpic_N$density[501:1000] #densities per iteration after burnin
mean_density_cpic_N <- mean(densities_cpic_N) # Mean # turtles per 100 meters
estimated_N_cpic_N <- df_mcmc_cpic_N$N[501:1000]
mean_est_N_cpic_N <- mean(estimated_N_cpic_N) # Mean # turtles over trap area (+ boundary)
mean_est_N_cpic_N/mean_density_cpic_N
####### Site N, CSER ########
load("Results/JAGS/cser_N_mcmc.RData")
# combine chains
df_mcmc_cser_N <- as.data.frame(cser_N_mcmc[[1]])
for(i in 2:length(cser_N_mcmc)) {
df_mcmc_cser_N <- bind_rows(df_mcmc_cser_N, as.data.frame(cser_N_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cser_N <- df_mcmc_cser_N %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cser_N <- centers_cser_N[1:n_indN, ]
hist(centers[1:n_indN, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cser_N <- df_mcmc_cser_N$density[501:1000] #densities per iteration after burnin
mean_density_cser_N <- mean(densities_cser_N) # Mean # turtles per 100 meters
estimated_N_cser_N <- df_mcmc_cser_N$N[501:1000]
mean_est_N_cser_N <- mean(estimated_N_cser_N) # Mean # turtles over trap area (+ boundary)
mean_est_N_cser_N/mean_density_cser_N
####### Site O, CPIC ########
load("Results/JAGS/cpic_O_mcmc.RData")
# combine chains
df_mcmc_cpic_O <- as.data.frame(cpic_O_mcmc[[1]])
for(i in 2:length(cpic_O_mcmc)) {
df_mcmc_cpic_O <- bind_rows(df_mcmc_cpic_O, as.data.frame(cpic_O_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cpic_O <- df_mcmc_cpic_O %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cpic_O <- centers_cpic_O[1:n_indO, ]
hist(centers[1:n_indO, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cpic_O <- df_mcmc_cpic_O$density[501:1000] #densities per iteration after burnin
mean_density_cpic_O <- mean(densities_cpic_O) # Mean # turtles per 100 meters
estimated_N_cpic_O <- df_mcmc_cpic_O$N[501:1000]
mean_est_N_cpic_O <- mean(estimated_N_cpic_O) # Mean # turtles over trap area (+ boundary)
mean_est_N_cpic_O/mean_density_cpic_O
####### Site O, CSER ########
load("Results/JAGS/cser_O_mcmc.RData")
# combine chains
df_mcmc_cser_O <- as.data.frame(cser_O_mcmc[[1]])
for(i in 2:length(cser_O_mcmc)) {
df_mcmc_cser_O <- bind_rows(df_mcmc_cser_O, as.data.frame(cser_O_mcmc[[i]]))
}
# Obtain Activity Centers
centers_cser_O <- df_mcmc_cser_O %>%
select(starts_with("s[")) %>%
summarise_all(mean) %>%
t()
str(centers) # activity centers
centers_cser_O <- centers_cser_O[1:n_indO, ]
hist(centers[1:n_indO, ]) # activity centers for individuals caught at least once
# hist(centers)
#### Obtaining Density For Site 1 and CPICS from MCMC Output ####
densities_cser_O <- df_mcmc_cser_O$density[501:1000] #densities per iteration after burnin
mean_density_cser_O <- mean(densities_cser_O) # Mean # turtles per 100 meters
estimated_N_cser_O <- df_mcmc_cser_O$N[501:1000]
mean_est_N_cser_O <- mean(estimated_N_cser_O) # Mean # turtles over trap area (+ boundary)
mean_est_N_cser_O/mean_density_cser_O
######## Checking z and psi
# animals in pop
# z <- df_mcmc %>%
# select(starts_with("z[")) %>%
# summarise_all(mean) %>%
# t()
# str(z)
#
# psi <- df_mcmc %>%
# select(starts_with("psi")) %>%
# summarise_all(mean)