-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSupportingInformation.Rmd
5161 lines (4396 loc) · 268 KB
/
SupportingInformation.Rmd
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
---
title: "Copulas and their potential for ecology: Appendices"
author: "Shyamolina Ghosh, Lawrence W. Sheppard, Mark T. Holder, Terrance D. Loecke, Philip C. Reid, James D. Bever, Daniel C. Reuman"
geometry: "left=1cm,right=1cm,top=2.2cm,bottom=2.2cm"
output:
pdf_document:
number_sections: yes
keep_tex: yes
fig_caption: yes
includes:
in_header: head_supp.sty
tables: True
link-citations: True
urlcolor : blue
indent : True
csl: ecology-letters.csl
bibliography: REF_ALL.bib
---
\pagenumbering{roman}
\tableofcontents
\listoffigures
\listoftables
\pagebreak
\pagenumbering{arabic}
<!--Basic setup-->
```{r setup, echo=F}
knitr::opts_chunk$set(echo = TRUE, fig.pos = "H")
seed<-101
source("mtime.R") #A function needed for caching
library(captioner)
library(parallel)
freecores<-2
busycores<-detectCores()-freecores # for parallell computing with mclapply your computer will use all cores except the number of freecores.
```
<!--generating plots for pedagog figures-->
```{r cop_pedagog_fig,echo=F,results="hide"}
set.seed(seed)
source("./FirstPedagogFig.R")
source("./SecondPedagogFig.R")
source("./ThirdPedagogFig.R")
source("./MakeCopulaPedagogFigs.R")
source("./PedagogFigCopThry.R")
```
<!--reading data and generaing plot for soilCN-->
```{r load_and_plot_data_soilCN, echo=F, results='hide'}
#d_old<-readRDS("Data/dataForShymolinaCoord.rds")
#write.csv(d_old,"./Data/SoilCN/SoilCNdata.csv")
d<-read.csv("./Data/SoilCN/SoilCNdata.csv")
rownames(d)<-d$X
d<-d[,-1]
#sapply(dCN,class)
d<-d[,c("SOCstock100","TSNstock100","lat","long")]
#identical(d_old[,c("SOCstock100","TSNstock100","lat","long")],d) # checked : they are identical :)
d<-na.omit(d)
pdf("./Results/SoilCNraw.pdf")
op<-par(mar=c(6, 6, 0.2, 2.1))
d_log<-log10(d[,c(1:2)])
plot(d_log[,1],d_log[,2],type="p",col="black",xlab="log(Soil C)",ylab="log(Soil N)",cex.lab=2.5,cex.axis=2.5)
par(op)
dev.off()
```
<!--generating copula plot with soilCN data-->
```{r copula_plot_soilCN, echo=F, results='hide'}
source("getcopula.R")
#convert to a copula and plot
pdf("./Results/SoilCNcop.pdf")
v_CN<-getcopula(d=d_log,rankon=T,ploton=T)
dev.off()
```
<!--generating plots with sampling locations for soilCN data-->
```{r plot_SoilCNmapUSA, echo=F, results='hide'}
#---------map of soilCN location on USA------------
library(maps)
pdf("./Results/SoilCNmapUSA.pdf",height=4,width=8)
map("usa")
points(x = d$long, y = d$lat, col=rgb(0,0,0,0.2),pch=16,cex=0.5)
dev.off()
```
<!--reading Birds' BMR data and generating raw, copula plots with it-->
```{r read_BMR_birds_and_copulaplot, echo=F, results='hide'}
library(readxl)
set.seed(seed)
raw_b<-readxl::read_xls("./Data/BMR/BirdBodyMassesMetabolicRates/BirdMassesAndMetabolicRatesMcNab2008.xls")
raw_b<-raw_b[,1:3]
raw_b<-na.omit(raw_b)
raw_b<-raw_b[,2:3]
raw_b<-as.data.frame(raw_b)
saveRDS(raw_b,"./Data/BMR/BirdBodyMassesMetabolicRates/my_birdsBMR_data.RDS")
b<-log10(raw_b)
colnames(b)<-c("log10M(g)","log10BMR(KJ/h)")
pdf("./Results/BMR_results/birds/raw_birds_BMR.pdf")
op<-par(mar=c(6, 6, 0.2, 2.1))
plot(b[,1],b[,2],type="p",col="black",xlab="log(Mass)",ylab="log(BMR)",cex.lab=2.5,cex.axis=2.5)
par(op)
dev.off()
source("getcopula.R")
pdf("./Results/BMR_results/birds/copula_birds_BMR.pdf")
cop_b<-getcopula(d=b,rankon=T,ploton=T) #convert to a copula and plot
dev.off()
```
<!--reading Mammals' BMR data and generating raw, copula plots with it-->
```{r read_BMR_mammals_and_copulaplot, echo=F, results='hide'}
set.seed(seed)
raw_m<-readxl::read_xls("./Data/BMR/MammalianBodyMassesMetabolicRates/MammalianMassesAndMetabolicRatesMcNab2008.xls")
raw_m<-raw_m[,1:3]
raw_m<-na.omit(raw_m)
raw_m<-raw_m[,2:3]
saveRDS(raw_m,"./Data/BMR/MammalianBodyMassesMetabolicRates/my_mammalsBMR_data.RDS")
m<-log10(raw_m)
colnames(m)<-c("log10M(g)","log10BMR(KJ/h)")
m<-as.data.frame(m)
pdf("./Results/BMR_results/mammals/raw_mammals_BMR.pdf")
op<-par(mar=c(6, 6, 0.2, 2.1))
plot(m[,1],m[,2],type="p",col="black",xlab="log(Mass)",ylab="log(BMR)",cex.lab=2.5,cex.axis=2.5)
par(op)
dev.off()
source("getcopula.R")
pdf("./Results/BMR_results/mammals/copula_mammals_BMR.pdf")
cop_m<-getcopula(d=m,rankon=T,ploton=T) #convert to a copula and plot
dev.off()
```
<!--reading ceder creek data and generating raw and copula plots with it-->
```{r read_ceder_creek_data, echo=F, results="hide"}
set.seed(seed)
#-------------------------------------------------
# This function takes
# Input :
# db : a dataframe : smaller subset of ple_120 data to calculate avg. biomass for each plot
# dp : a dataframe : smaller subset of pce_120 data to calculate avg. shannon's H for those plots
# plots : a vector of given 168 plot ids as used in reference papers by Tilman
# year : the year for which you want to calculate biomass and shannon's index data
# rawplot : logical : T for rawdata plot, F for copula plot
# ploton : logical for optional plotting
# Output :
# a list of two data-frame:
# tab_dbp : a data-frame with 3 column : (plot no , avg.H, avg.Biomass(g/m2))
# cop_tab_dbp : a data-frame with 3 column : (plot no, pobs(avg.H), pobs(avg.Biomass(g/m2)))
cop_HB<-function(db,dp,plots,year,rawplot,ploton){
# db : biomass dataset for a specific year
# dp : percent cover dataset for a specific year
db<-subset(db,Plot%in%plots)
dp<-subset(dp,Plot%in%plots)
tab_dbp<-data.frame(Plot=plots,avg.H=NA,avg.Biomass=NA)
for(i in 1:length(plots)){
# calculate biomass for each plot (averaged over all strips for that plot)
x<-subset(db,Plot==plots[i])
tab_dbp$avg.Biomass[i]<-mean(x$Biomass)
# calculate shannon's index H for each plot (averaged over all Quadrates for that plot)
x<-subset(dp,Plot==plots[i])
x$Species<-trimws(x$Species) # to remove duplicated names of sp. (cutting white spaces) : e.g. 1999 : plot no 339
uniq_sp<-sort(as.character(unique(x$Species))) # These are the species in a particular plot
Q<-as.character(unique(x$Quadrat))
#cat("----------total unique quadrats = ",length(Q),"--------------------\n")
tab_each_sp<-data.frame(sp=uniq_sp,avg_cov=0,rel_avg_cov=0)
#cat("=====================================plot : ",plots[i],"===========================\n")
for(sp in 1:length(uniq_sp)){
my_sp<-uniq_sp[sp]
#cat("---------- sp = ",my_sp,"--------------------\n")
tab_temp<-data.frame(Q=Q,abs_cov=0)
ind<-which(x$Species==my_sp)
li<-length(ind)
#print(li)
tab_temp$abs_cov[1:li]<-x$Abscover[ind]
tab_each_sp$avg_cov[[sp]]<-mean(tab_temp$abs_cov) # avg. over Quadrats for a sp.
}
tab_each_sp$rel_avg_cov<-tab_each_sp$avg_cov/sum(tab_each_sp$avg_cov)
tab_dbp$avg.H[i]<- -sum((tab_each_sp$rel_avg_cov)*log(tab_each_sp$rel_avg_cov))
}
tab_dbp<-na.omit(tab_dbp)
cop_tab_dbp<-data.frame(Plot=tab_dbp$Plot,avg.H=NA,avg.Biomass=NA)
cop_tab_dbp$avg.H<-VineCopula::pobs(tab_dbp$avg.H)
cop_tab_dbp$avg.Biomass<-VineCopula::pobs(tab_dbp$avg.Biomass)
if(ploton==T){
if(rawplot==T){
op<-par(mar=c(6, 6, 0.2, 2.1))
plot(tab_dbp$avg.H,tab_dbp$avg.Biomass,xlab="avg. H",ylab="avg. Biomass",pch=1,cex.lab=2.5,cex.axis=2)
mtext(paste0("Year=",year),cex=1)
par(op)
}else{
op<-par(mar=c(6, 6, 0.2, 2.1))
plot(cop_tab_dbp$avg.H,cop_tab_dbp$avg.Biomass,xlab="u",ylab="v",pch=1,cex.lab=3,cex.axis=2,
xlim=c(0,1),ylim=c(0,1),asp=1)
rect(0,0,1,1)
lines(c(0,1),c(0,1),type='l',col="grey")
#mtext(paste0("Year=",year),cex=1)
par(op)
}
}
return(list(tab_dbp=tab_dbp,
cop_tab_dbp=cop_tab_dbp))
}
#-----------------------------
r_ple<-read.delim("./Data/Ceder_creek_e120/edited_ple120.txt")
names(r_ple)[36]<-"Biomass"
r_pce<-read.delim("./Data/Ceder_creek_e120/edited_pce120.txt")
y1<-unique(r_ple$Year)
y2<-unique(r_pce$Year)
yr<-sort(intersect(y1,y2))
a<-as.data.frame(table(sort(r_pce$Species)))
b<-as.character(a$Var1)
bad_sp<-c(b[51:53],b[156:158],"Disturbance")
# bad sp : "Bare ground","Bare ground","BARE GROUND","Miscellaneous litter","Miscellaneous litter","MISCELLANEOUS LITTER"
ind<-which(r_pce$Species%in%bad_sp)
r_pce_clean<-r_pce[-ind,]
#----------------------------------------------------------------------------------------------
#=======================================================
# This sections selects 168 plots considered for both biomass and percent cover datasets in Tilman's papers 2001, 2006
plot_info<-read.delim("./Data/Ceder_creek_e120/edited_plots.txt")
id_excluded_plots<-which(plot_info$Species=="Bargr") # there were 4 plots with no sp. seeded
plots_168<-plot_info$Plot[-id_excluded_plots]
#------------------------------------------------------
# You can check that here too
s<-subset(r_ple,NumSp==0)
sb<-sort(unique(s$Plot))
s<-subset(r_pce_clean,NumSp==0)
spc<-sort(unique(s$Plot))
sb==spc # This should be all TRUE for 4 not seeded plots with id : 126, 166, 244, 248
#=======================================================
#--------------------------------------------------------------------------------------------
pdf("./Results/Ceder_creek_results/raw_HB_all_yr.pdf",height = 6,width = 10)
op<-par(mfrow=c(2,3),mar=c(3,3,3,3), mgp=c(1.5,0.5,0))
for(i in 1:length(yr)){
db<-subset(r_ple,Year==yr[i])
dp<-subset(r_pce_clean,Year==yr[i])
sr<-cop_HB(db=db,dp=dp,year=yr[i],plots=plots_168,rawplot=T,ploton = T)
}
par(op)
dev.off()
#-----------------------
#raw data plot for year2000
pdf("./Results/Ceder_creek_results/raw_HB_2000.pdf",height = 6,width = 6)
i<-5
db<-subset(r_ple,Year==yr[i])
dp<-subset(r_pce_clean,Year==yr[i])
sr<-cop_HB(db=db,dp=dp,year=yr[i],plots=plots_168,rawplot=T,ploton = T)
saveRDS(sr,"./Results/Ceder_creek_results/raw_cop_cc_2000.RDS")
dev.off()
#----------------------------------------------------------------------------------------
cop_HB_all_yr<-vector("list",length(yr))
names(cop_HB_all_yr)<-yr
pdf("./Results/Ceder_creek_results/cop_HB_all_yr.pdf",height = 6,width = 10)
op<-par(mfrow=c(2,3),mar=c(3,3,3,3), mgp=c(1.5,0.5,0))
for(i in 1:length(yr)){
db<-subset(r_ple,Year==yr[i])
dp<-subset(r_pce_clean,Year==yr[i])
s<-cop_HB(db=db,dp=dp,year=yr[i],plots=plots_168,rawplot=F,ploton = T)
cop_HB_all_yr[[i]]<-s$cop_tab_dbp[,2:3]
}
par(op)
dev.off()
#-------------------------
#cop data plot for year2000
pdf("./Results/Ceder_creek_results/cop_HB_2000.pdf",height = 6,width = 6)
i<-5
db<-subset(r_ple,Year==yr[i])
dp<-subset(r_pce_clean,Year==yr[i])
s<-cop_HB(db=db,dp=dp,year=yr[i],plots=plots_168,rawplot=F,ploton = T)
cc_cop_2000<-s$cop_tab_dbp[,2:3]
dev.off()
#------------------
saveRDS(cop_HB_all_yr,"./Results/Ceder_creek_results/cop_HB_all_yr.RDS")
#---------------------------------------------------------------------------------------
cop_HB_all_yr<-readRDS("./Results/Ceder_creek_results/cop_HB_all_yr.RDS")
```
<!--reading aphid and plankton data, then generating plots showing sampling locations-->
```{r map_plot_aphid_plankton,results="hide",echo=F}
source("aphid_data_calling.R")
source("good_loclist.R")
library(maps)
#----------------- Aphid map--------------------------------------------
d0_count<-as.matrix(read.csv("./Data/Aphid_data/APHID_DATA_RAW/aphidtscount141117.csv",header=F))
data_aphid_count<-d_allsp_data(d0_count)
d0_firstflight<-as.matrix(read.csv("./Data/Aphid_data/APHID_DATA_RAW/aphidtsfirstflight141117.csv",header=F))
data_aphid_ff<-d_allsp_data(d0_firstflight)
selective_loc1<-good_loclist(d_allsp=data_aphid_count,sp=10,data_pt_thrs=30)
selective_loc2<-good_loclist(d_allsp=data_aphid_ff,sp=11,data_pt_thrs=30)
all(selective_loc1==selective_loc2)==T
longs<-c(-4.567,0.57,-3.069,-3.312,-2.637,-1.682,-2.763,-0.356,-3.454,0.427,0.939)
lats<-c(55.477,52.26,56.457,55.949,52.125,55.213,53.854,51.807,50.628,51.733,51.185)
locno<-length(longs)
df_loc_info_org<-data.frame(loc_no=c(1:length(lats)),longs=longs,lats=lats)
df_loc_info<-df_loc_info_org[selective_loc1,]
xlim=c(-10,2)
ylim=c(50, 60)
pdf("./Results/aphid_map_plot.pdf")
map("world", fill=TRUE, col="grey84", bg="white",border=0, xlim=xlim, ylim=ylim)
map.axes(cex.axis=2.5)
points(x = df_loc_info_org$longs, y = df_loc_info_org$lats, col="black",pch=16)
points(x = df_loc_info$longs, y = df_loc_info$lats, col="black", pch=0, cex=1.5)
text(df_loc_info_org$loc_no, x = df_loc_info_org$longs, y = df_loc_info_org$lats, col="black", pos=1)
dev.off()
#--------------Plankton map----------------------------
source("plankton_north_sea_data_calling.R")
d0_plankton_north_sea<-as.matrix(read.csv("./Data/Plankton_North_Sea_data/planktontimeseries201117_4.csv",header=F))
data_plankton_north_sea<-d_allsp_data_plankton_north_sea(d0_plankton_north_sea)
longs<-read.csv("./Data/Plankton_North_Sea_data/boxcornerlongs201117.csv",header=F)
lats<-read.csv("./Data/Plankton_North_Sea_data/boxcornerlats201117.csv",header=F)
longs_pns<-longs[[1]]
lats_pns<-lats[[1]]
df_loc_info_org<-data.frame(loc_no=c(1:length(lats_pns)),longs=longs_pns,lats=lats_pns)
selective_loc<-good_loclist(d_allsp=data_plankton_north_sea,sp=16,data_pt_thrs=45)
df_loc_info<-df_loc_info_org[selective_loc,]
xlim=c(-12,10)
ylim=c(48, 60)
pdf("./Results/plankton_map_plot.pdf")
map("world", fill=TRUE, col="grey84", bg="white",border=0, xlim=xlim, ylim=ylim)
map.axes(cex.axis=2.5)
abline(h=seq(from=ylim[1],to=ylim[2],by=2), v=seq(from=xlim[1],to=xlim[2],by=2), col="black", lty=2)
points(x = df_loc_info_org$longs+1, y = df_loc_info_org$lats+1, col="black",pch=16)
points(x = df_loc_info$longs+1, y = df_loc_info$lats+1, col="black", pch=0, cex=1.5)
text(df_loc_info_org$loc_no, x = df_loc_info_org$longs+1, y = df_loc_info_org$lats+1, col="black", pos=1)
dev.off()
```
<!--Generating a single plot containing raw and copula plots for all bivariate data-->
```{r make_data_plot_fig,echo=FALSE,results="hide"}
source("./MakeBivarDataPlot.R")
```
# Transformation alters Pearson but not Spearman correlation \label{pedagog1_details}
The data of Fig. \ref{MT-fig_cop_pedag1}A-B were generated to have standard normal marginals.
Fig. \ref{fig_transf_pearson_spearman}A can be obtained from Fig. \ref{MT-fig_cop_pedag1}A via transformation
of both variables by the cumulative distribution function (cdf) of the standard normal distribution, and then by the inverse of
the cdf of the gamma distribution with shape and scale parameters 2.
The functions `pnorm` and `qgamma` in R were used.
Fig. \ref{fig_transf_pearson_spearman}B can be obtained from Fig. \ref{MT-fig_cop_pedag1}B in the same way.
The Pearson correlations differ substantially after transformation,
but the Spearman correlations are unchanged (Figs \ref{MT-fig_cop_pedag1}A-B, \ref{fig_transf_pearson_spearman}).
A scatterplot very similar to Fig. \ref{MT-fig_cop_pedag1}C can be obtained from Fig. \ref{MT-fig_cop_pedag1}A via transformation
of both variables by the cdf of the standard normal distribution.
Likewise a scatterplot similar to Fig. \ref{MT-fig_cop_pedag1}D can be obtained from Fig. \ref{MT-fig_cop_pedag1}B in the same way.
\begin{figure}[!h]
\begin{center}
\includegraphics[width=10 cm]{./Results/PedagogFig_SMExport.pdf}
\caption[Transformation alters Pearson but not Spearman correlation]{Transformation alters Pearson but not Spearman correlation.
Displayed data are transformed from the data pictured on
Fig. \ref{MT-fig_cop_pedag1}A-B. See Appendix \ref{pedagog1_details} for
details. P=Pearson, S=Spearman
correlation.\label{fig_transf_pearson_spearman}}
\end{center}
\end{figure}
\begin{figure}[!h]
\begin{center}
\includegraphics[width=16 cm,height=8 cm]{./Results/copula_pedagog_fig_BB1.pdf}
\caption[Lower- and upper-tail dependence can vary independently of correlation]{Lower- and
upper-tail dependence can vary independently of correlation. (A-C) Data generated using the BB1
copula (see section \ref{MT-Background} in the main text)
with three different
sets of parameters chosen to produce a variety of
lower-tail (LT) and upper-tail (UT) dependence strengths, but with the same
Kendall correlation (K) (to two digits) in all cases. (D-F) Similar to A-C, but
with stronger correlation. Asymmetry of tail dependence (LT-UT) is the same
within each column. See section \ref{MT-Background} in the main text for a formal description of
tail dependence and other measures of association in the tails.\label{fig_cop_pedag}}
\end{center}
\end{figure}
# Proofs of statements related to Sklar's theorem in the case of continuous, strictly monotonic margins \label{ContStrictMonoton}
Let $F$ be the cdf
of a random vector $(X,Y)$, with margins $F_X$ and $F_Y$ assumed to be
continuous and strictly monotonic. We show the copula associated with
$(X,Y)$, which exists and is unique by Sklar's theorem, is, in fact,
the bivariate cdf
of the random variable $(U,V)=(F_X(X),F_Y(Y))$. Let $C$ denote the distribution
function of $(U,V)$, which has uniform margins. By the uniqueness
statement of Sklar's theorem, it suffices to show that $F(x,y)=C(F_X(x),F_Y(y))$
for all $(x,y)$ in the Euclidean plane. But
$C(F_X(x),F_Y(y)) = P[U \leq F_X(x), V \leq F_Y(y)]
= P[F_X(X) \leq F_X(x), F_Y(Y) \leq F_Y(y)]
= P[X \leq x, Y \leq y]
= F(x,y),$
where the third equality follows from the strict monotonicity assumption. In fact,
that equality should hold even with non-strict monotonicity, so a stronger
statement is possible (see below for more on this topic). The continuity assumption
for $F_X$ and $F_Y$ is necessary, however: without it the random variables
$U$ and $V$ are not uniformly distributed, so their joint cdf
is not even a copula.
Now let $D$ be any bivariate copula and let
$G_A$ and $G_B$ be univariate cdfs, so that
$D(G_A(x),G_B(y))$ is guaranteed by Sklar's theorem to be a cdf.
We here show that if $G_A$ and $G_B$ are continuous and strictly monotonic, then
$D(G_A(x),G_B(y))$ is the cdf of the random variable
$(G_A^{-1}(U),G_B^{-1}(V))$, where $(U,V)$ now denotes the random
vector with uniform marginals associated with $D$ and
$G_A^{-1}$ and $G_B^{-1}$ are the inverses of $G_A$ and $G_B$.
The inverses exist because of the strict monotonicity assumption.
To get to the desired result, note that the cdf of
$(G_A^{-1}(U),G_B^{-1}(V))$ is $P[G_A^{-1}(U) \leq x, G_B^{-1}(V) \leq y]$,
which equals $P[U \leq G_A(x), V \leq G_B(y)]$, by strict monotonicity.
But this is $D(G_A(x),G_B(y))$ because $D$ is the cdf of
$(U,V)$. In fact, a stronger statement assuming
neither continuity nor strict monotonicity is possible, if one uses generalized
inverses for $G_A^{-1}$ and $G_B^{-1}$ [@MaiScherer2017]. We adopt the weaker
statements for simplicity and because our applications are solely under the case
of continuous, strictly monotonic margins. But see @Anderson2018 and
@Popovic2019 for applications of copulas outside this case.
# Details of the data \label{Data_details}
\textbf{Environmental data, soil C and N.} Measurements were from the central pedon of a soil
core, to 1m depth.
\textbf{Phenological and population data on aphids.}
Data pre-processing for the aphid data was the same as that of @Sheppard2016,
except that years for which data was unavailable were excluded rather than being
replaced by median values. We also excluded one of the 11 sites they used in
order to only use sites with at least 30 years data.
\textbf{Population data, plankton abundances.}
These data
were obtained from the Continuous Plankton Recorder (CPR) dataset, now operated and maintained by
the Marine Biological Association of the United Kingdom. Data pre-processing was similar but not identical to that
of @Sheppard2017.
The CPR plankton data presented in @Sheppard2017 was aggregated in the following way. Fifty
$2^\circ$ by $2^\circ$ location boxes were examined between $-10^\circ$ and $10^\circ$ longitude
and between $50^\circ$ and $60^\circ$ latitude (Fig. \ref{fig_plankton_map}). For each species, for each box,
for each year, for each month, the average of any available CPR samples was taken to give monthly
time series of population densities with some missing values. Missing monthly values were then
replaced with the median value for that species for that location for that month. The data for each
species for each box for each year was then averaged over all twelve months, and 26 usable annual
time series were identified for wavelet analysis. The CPR plankton data used here is aggregated in
the same way, except that for any species, box and year for which more than 4 months data were missing,
missing values were not replaced with medians and those species, box, year combinations were not used.
We used only data from the 14 locations which had at least 45 years of annual data subject to this
restriction, shown by blue markers in Fig. \ref{fig_plankton_map}. The CPR data are described in
great detail elsewhere, e.g., by @Batten2003 and @Raitsos2014.
\textbf{Community-level data, Cedar Creek.} Above-ground biomass [@ccdataple120] and percent cover data [@ccdatapce120] were
obtained from biodiversity experiment E120 conducted at the Cedar Creek Ecosystem Science Reserve
by Tilman *et al*. In 1994, 168 plots [@ccdataplotse120] (each 9 m $\times$ 9 m) of 39, 35, 29, 30 and 35 replicates,
were seeded with 1, 2, 4, 8, or 16 perennials, respectively, chosen randomly from a pool of
18 species (4 species, each, of C4 grasses, C3 grasses, legumes, non-legume forbs; and 2 species of woody
plants). All plots received, in total, 10 gm$^{-2}$ of pure live seed in May 1994 and 5 gm$^{-2}$ in May, 1995
with seed mass divided equally among species. Treatments were maintained by weeding manually 3-4 times a year
and sometimes selective herbicides were used. We downloaded the data on July, 2018 from the Cedar Creek website \url{http://www.cedarcreek.umn.edu/research/experiments/e120} and
analyzed those data for 6 years
(1996-2000, 2007) for which both biomass and percent cover data were available. Plots were annually
sampled by clipping
different locations each year. For each available year, we analyzed above-ground biomass (gm$^{-2}$)
and Shannon's biodiversity index (computed using percent cover data) averaged over the
sampled strips/quadrats taken from each
of 168 plots.
\textbf{Ecosystem functioning data on methane-flux.} The Great Miami Wetland Mitigation Bank was at
$36^{\circ}46^{'}51^{''}$ N, $84^{\circ}20^{'}26^{''}$ W, in Trotwood, Montgomery County, Ohio. Additional information
on the history of the site and soil types is detailed in @Jarecke2016. Briefly, the closed static flux chamber method
was used [@Holland1999] to measure $\text{CH}_{4}$ fluxes at 28 locations across a hydrologic gradient (upland to
seasonal wetland) at daily to weekly interval from September 2015 to September 2016. See @smyth2019using for
additional details on greenhouse gas flux methods for this site. We considered 13 locations for which data were
gathered for at least 50 dates.
<!--table with summarized notation used in maintext-->
```{r tab_summary_notation, echo=F, results='markup',message=F}
library(tibble)
library(kableExtra)
library(dplyr)
tab_summary_notation<- tibble(Notation=c("$x_{i}$,$y_{i}$", "$u_{i}$,$v_{i}$",
"$(X,Y)$", "F",
"$F_{X}$, $F_{Y}$","$C$",
"$D$", "$G_{A}$,$G_{B}$",
"$\\lambda_{L}$, $\\lambda_{U}$",
"$l_{b}$, $u_{b}$",
"cor$_{lb,ub}$",
"cor$_{l}$","cor$_{u}$",
"P$_{lb,ub}$, P$_{l}$,P$_{u}$, D$_{lb,ub}^2$, D$_{l}^2$, D$_{u}^2$",
"$b$", "$g,g_{1},g_{2}$",
"$E$","$P$"),
Meaning=c("Variables representing raw bivariate data",
"Normalized ranks of ($x_{i}$,$y_{i}$)",
"A bivariate random vector",
"The bivariate cdf of $(X,Y)$",
"The cdfs of the marginals, $X$ and $Y$, respectively",
"The copula for $(X,Y)$",
"A bivariate copula",
"Two univariate cdfs",
"Lower and upper tail dependence of a copula",
"A lower and upper bound satisfying $0 \\leq l_{b} \\leq u_{b} \\leq 1$",
"partial Spearman correlation",
"cor$_{lb,ub}$ when $l_{b}$ = 0, $u_{b}$ = 0.5",
"cor$_{lb,ub}$ when $l_{b}$ = 0.5, $u_{b}$ = 1",
"Related nonparametric statistics",
"AR$(1)$ coefficient in the model related to Leibig's law",
"Function describing environmental influence in the model related to Leibigs law",
"An ecological variable",
"A population variable"),
"Section in maintext"=c(1,1,
2,2,2,2,2,2,2,
4,4,4,4,4,
6,6,6,6))
knitr::kable(tab_summary_notation, "latex", booktabs = T, linesep = "", escape=F,
caption.short = "Summary of principal notation",
caption = "Summary of principal notation. Many notations are defined and used only within a small part of the paper. This table summarizes notation that is used across larger portions of the paper. Third column refers to the section in which the notation was originally defined. cdf = cumulative distribution function. \\label{tab_summary_notation}")%>%
column_spec(column = 2,width="4.5 cm")
```
<!--generating table with information about 20 aphid species-->
```{r tab_aphid_info, echo=F, results='asis',message=F}
library(tinytex)
library(tibble)
library(kableExtra)
library(dplyr)
aphid_info <- tibble(c1=c("Apple grass aphid","Bird cherry oat aphid","Black bean aphid","Blackberry cereal aphid","Blackcurrant sowthistle aphid",
"Corn leaf aphid","Currant lettuce aphid","Damson hop aphid","Grain aphid","Green spruce aphid",
"Leaf-curling plum aphid","Mealy cabbage aphid","Mealy plum aphid","Pea aphid","Peach potato aphid",
"Potato aphid","Rose grain aphid","Shallot aphid","Sycamore aphid","Willow carrot aphid"),
c2=c("Rhopalosiphum insertum", "Rhopalosiphum padi", "Aphis fabae", "Sitobion fragariae", "Hyperomyzus lactucae",
"Rhopalosiphum maidis", "Nasonovia ribisnigri","Phorodon humuli","Sitobion avenae","Elatobium abietinum",
"Brachycaudus helichrysi","Brevicoryne brassicae","Hyalopterus pruni","Acyrthosiphon pisum","Myzus persicae",
"Macrosiphum euphorbiae","Metopolophium dirhodum","Myzus ascalonicus","Drepanosiphum platanoidis","Cavariella aegopodii")
)
saveRDS(aphid_info,"./Results/aphid_info.RDS")
knitr::kable(aphid_info, "latex", booktabs = T, linesep = "",
caption = "Species names of 20 aphids for which data were available \\label{tab_aphid_info}",
col.names = NULL)%>%
column_spec(column = 2,italic=T)%>%add_header_above(header=c("Common name" = 1, "Latin binomial" = 1))
```
<!--generating table with information about 22 plankton species-->
```{r tab_plankton_info, echo=F, results='asis',message=F}
library(tibble)
plankton_info <- tibble(c1=c('Calanus stages I-IV','Para-pseudocalanus spp.','Temora longicornis','Acartia sp.',
'Centropages typicus',
'Oithona sp.','Echinoderm larvae','Calanus finmarchicus',
'Calanus helgolandicus','Metridia lucens','Decapoda larvae',
'Euphausiids','Thalassiosira sp.','Rhizosolenia styliformis',
'Ceratium fusus','Ceratium furca','Ceratium tripos','Ceratium macroceros',
'Proboscia alata','Pseudocalanus sp.',
'Pseudo-nitzschia delicatissima','Pseudo-nitzschia seriata')
)
cns<-c('Echinoderm larvae','Euphausiids','Decapoda larvae')
'%ni%' <- Negate('%in%')
idn<-which(plankton_info$c1%ni%cns)
knitr::kable(plankton_info, "latex", booktabs = T, linesep = "",
caption = "Species names of 22 plankton taxa for which data were available \\label{tab_plankton_info}",
col.names = c("Plankton taxon name"))%>%row_spec(row=idn,italic=T)
```
<!--survival clayton copula-->
\begin{figure}[!h]
\begin{center}
\includegraphics[width=7.5in]{./Results/PedagogSuppMat_SurvClayton.pdf}
\caption[Example survival Clayton copulas]{Log-transformed pdfs (A-E) and samples (F-J)
from example survival Clayton
copulas. K is Kendall correlation; p is the value of the parameter for the survival Clayton
family (it is a one-parameter family); and LT and UT are the measures of lower- and
upper-tail dependence, respectively. The parameter range for the family is $p \in (0,\infty)$, upper-tail dependence is $2^{-1/p}$ and lower-tail
dependence is $0$.\label{figped_SC}}
\end{center}
\end{figure}
<!--embedding plot with sampling locations : soilCN, aphids, planktons-->
\begin{figure}[!h]
\begin{center}
\includegraphics[width=16 cm,height=16 cm]{./Results/SoilCNmapUSA.pdf}
\caption[Sampling locations for C and N data]{Locations of central pedons sampled
for soil organic carbon and total soil nitrogen (megagrams C or N per hectare of soil
surface) at 5907 sites across the coterminous United States. \label{fig_SoilCNmapUSA}}
\end{center}
\end{figure}
\begin{figure}[!h]
\begin{center}
\includegraphics[width=16 cm,height=16 cm]{./Results/aphid_map_plot.pdf}
\caption[Sampling locations for aphid data]{Locations of the
Rothamsted Insect Survey
suction traps from which data were available are indicated by the circles,
out of which only squares had at least 30 years of data and were
used for our study. \label{fig_aphid_map}}
\end{center}
\end{figure}
\begin{figure}[!h]
\begin{center}
\includegraphics[width=16 cm,height=16 cm]{./Results/plankton_map_plot.pdf}
\caption[Sampling regions for CPR plankton data]{CPR data were available from
26 locations ($2^{\circ}$ $\times$ $2^{\circ}$ regions on the map) around UK
seas (circles), out of which only squares had at least 45 years of data and
were used for our study. \label{fig_plankton_map}}
\end{center}
\end{figure}
<!--Now the copula figures that were not presented in the main text-->
\begin{figure}[!h]
\begin{center}
\includegraphics[width=7.5in]{./Results/PedagogSuppMat_Gumbel.pdf}
\caption[Example Gumbel copulas]{Log-transformed pdfs (A-E) and samples (F-J) from example Gumbel copulas. K is Kendall
correlation; $p$ is the value of the parameter for the Gumbel family (it is a
one-parameter family); and LT and UT are the measures of lower- and upper-tail dependence,
respectively. The parameter range for the family is $p \in [1,\infty)$, lower-tail dependence is $0$ and upper-tail
dependence is $2-2^{1/p}$.\label{figped_G}}
\end{center}
\end{figure}
\begin{figure}[!h]
\begin{center}
\includegraphics[width=7.5in]{./Results/PedagogSuppMat_SurvGumbel.pdf}
\caption[Example survival Gumbel copulas]{Log-transformed pdfs (A-E) and samples (F-J) from example survival Gumbel
copulas. K is Kendall correlation; $p$ is the value of the parameter for the survival Gumbel
family (it is a one-parameter family); and LT and UT are the measures of lower- and
upper-tail dependence, respectively. The parameter range for the family is $p \in [1,\infty)$, upper-tail dependence is $0$ and lower-tail
dependence is $2-2^{1/p}$.\label{figped_SG}}
\end{center}
\end{figure}
\begin{figure}[!h]
\begin{center}
\includegraphics[width=7.5in]{./Results/PedagogSuppMat_Joe.pdf}
\caption[Example Joe copulas]{Log-transformed pdfs (A-E) and samples (F-J) from example Joe copulas. K is Kendall correlation; $p$ is the value of the parameter for the Joe family (it is a
one-parameter family); and LT and UT are the measures of lower- and upper-tail dependence,
respectively. The parameter range for the family is $p \in [1,\infty)$, lower-tail dependence is $0$ and upper-tail
dependence is $2-2^{1/p}$.\label{figped_J}}
\end{center}
\end{figure}
\begin{figure}[!h]
\begin{center}
\includegraphics[width=7.5in]{./Results/PedagogSuppMat_SurvJoe.pdf}
\caption[Example survival Joe copulas]{Log-transformed pdfs (A-E) and samples (F-J) from example survival Joe
copulas. K is Kendall correlation; $p$ is the value of the parameter for the survival Joe
family (it is a one-parameter family); and LT and UT are the measures of lower- and
upper-tail dependence, respectively. The parameter range for the family is $p \in [1,\infty)$, upper-tail dependence is $0$ and lower-tail
dependence is $2-2^{1/p}$.\label{figped_SJ}}
\end{center}
\end{figure}
\begin{figure}[!h]
\begin{center}
\includegraphics[width=7.5in]{./Results/PedagogSuppMat_Frank.pdf}
\caption[Example Frank copulas]{Log-transformed pdfs (A-E) and samples (F-J) from example Frank copulas. K is Kendall correlation; $p$ is the value of the parameter for the Frank family (it is a
one-parameter family); and LT and UT are the measures of lower- and upper-tail dependence,
respectively. The parameter range for the family is $p \in (0,\infty)$, lower-tail dependence is $0$ and upper-tail
dependence is $0$.\label{figped_F}}
\end{center}
\end{figure}
\begin{figure}[!h]
\begin{center}
\includegraphics[width=7.5in]{./Results/PedagogSuppMat_SBB1.pdf}
\caption[Example survival BB1 copulas]{Log-transformed pdfs for example survival BB1 copulas. K is Kendall correlation; $p_1$ and $p_2$
denote the two parameters of the family (it is a
two-parameter family); and LT and UT are the measures of lower- and upper-tail dependence,
respectively. The parameter ranges for the family are $p_1 \in (0,\infty)$
and $p_2 \in [1,\infty)$, lower-tail dependence is $2-2^{1/p_2}$ and upper-tail
dependence is $2^{-1/(p_1 p_2)}$.\label{figped_SBB1}}
\end{center}
\end{figure}
\begin{figure}[!h]
\begin{center}
\includegraphics[width=7.5in]{./Results/PedagogSuppMat_BB6.pdf}
\caption[Example BB6 copulas]{Log-transformed pdfs for example BB6 copulas. K is Kendall correlation; $p_1$ and $p_2$
denote the two parameters of the family (it is a
two-parameter family); and LT and UT are the measures of lower- and upper-tail dependence,
respectively. The parameter ranges for the family are $p_1 \in [1,\infty)$
and $p_2 \in [1,\infty)$, lower-tail dependence is $0$ and upper-tail
dependence is $2-2^{1/(p_1 p_2)}$. \label{figped_BB6}}
\end{center}
\end{figure}
\begin{figure}[!h]
\begin{center}
\includegraphics[width=7.5in]{./Results/PedagogSuppMat_SBB6.pdf}
\caption[Example survival BB6 copulas]{Log-transformed pdfs for example survival BB6 copulas. K is Kendall correlation; $p_1$ and $p_2$
denote the two parameters of the family (it is a
two-parameter family); and LT and UT are the measures of lower- and upper-tail dependence,
respectively. The parameter ranges for the family are $p_1 \in [1,\infty)$
and $p_2 \in [1,\infty)$, upper-tail dependence is $0$ and lower-tail
dependence is $2-2^{1/(p_1 p_2)}$.\label{figped_SBB6}}
\end{center}
\end{figure}
\begin{figure}[!h]
\begin{center}
\includegraphics[width=7.5in]{./Results/PedagogSuppMat_BB7.pdf}
\caption[Example BB7 copulas]{Log-transformed pdfs for example BB7 copulas. K is Kendall correlation; $p_1$ and $p_2$
denote the two parameters of the family (it is a
two-parameter family); and LT and UT are the measures of lower- and upper-tail dependence,
respectively. The parameter ranges for the family are $p_1 \in [1,\infty)$
and $p_2 \in (0,\infty)$, lower-tail dependence is $2^{-1/p_2}$ and upper-tail
dependence is $2-2^{1/p_1}$.\label{figped_BB7}}
\end{center}
\end{figure}
\begin{figure}[!h]
\begin{center}
\includegraphics[width=7.5in]{./Results/PedagogSuppMat_SBB7.pdf}
\caption[Example survival BB7 copulas]{Log-transformed pdfs for example survival BB7 copulas. K is Kendall correlation; $p_1$ and $p_2$
denote the two parameters of the family (it is a
two-parameter family); and LT and UT are the measures of lower- and upper-tail dependence,
respectively. The parameter ranges for the family are $p_1 \in [1,\infty)$
and $p_2 \in (0,\infty)$, upper-tail dependence is $2^{-1/p_2}$ and lower-tail
dependence is $2-2^{1/p_1}$.\label{figped_SBB7}}
\end{center}
\end{figure}
\begin{figure}[!h]
\begin{center}
\includegraphics[width=7.5in]{./Results/PedagogSuppMat_BB8.pdf}
\caption[Example BB8 copulas]{Log-transformed pdfs for example BB8 copulas. K is Kendall correlation; $p_1$ and $p_2$
denote the two parameters of the family (it is a
two-parameter family); and LT and UT are the measures of lower- and upper-tail dependence,
respectively. The parameter ranges for the family are $p_1 \in [1,\infty)$
and $p_2 \in (0,1]$, lower-tail dependence is $0$ and upper-tail
dependence is $2-2^{1/p_1}$ if $p_2=1$ and $0$ otherwise.\label{figped_BB8}}
\end{center}
\end{figure}
\begin{figure}[!h]
\begin{center}
\includegraphics[width=7.5in]{./Results/PedagogSuppMat_SBB8.pdf}
\caption[Example survival BB8 copulas]{Log-transformed pdfs for example survival BB8 copulas. K is Kendall correlation; $p_1$ and $p_2$
denote the two parameters of the family (it is a
two-parameter family); and LT and UT are the measures of lower- and upper-tail dependence,
respectively. The parameter ranges for the family are $p_1 \in [1,\infty)$
and $p_2 \in (0,1]$, upper-tail dependence is $0$ and lower-tail
dependence is $2-2^{1/p_1}$ if $p_2=1$ and $0$ otherwise.\label{figped_SBB8}}
\end{center}
\end{figure}
# Nonparametric statistics \label{nonparam_stats}
\noindent We define $\Ps_{l_b,u_b}$, using the bounds
$u+v=2l_b$ and $u+v=2u_b$ defined in the main text, as follows. For a distance $h$, we define
$S(h)$ to be the number of points $(u_i,v_i)$ within the bounds
and a distance less than $h$ from the line $v=u$, divided by the
total number of points within the bounds. This function is
defined for $h$ going from $0$ to a distance $h_{\text{max}}$ which
is half the longer of the two segments obtained by intersecting the
bounds with the unit square. It is easy to see $S(0)=0$ and
$S(h_{\text{max}})=1$. We define $S_i(h)$, also for $h$ going from $0$
to $h_{\text{max}}$, to be the area within the bounds and the unit square
and within distance $h$ of the line $v=u$, divided by the area
within the bounds and the unit square. This is the expected value of
$S(h)$ for independent data. We then define
\begin{equation}\label{eq.P}
P_{l_b,u_b} = \int_0^{h_{\text{max}}} ( S(h) - S_i(h) ) dh.
\end{equation}
\noindent As for $\cor_{l_b,u_b}$, larger values of $\Ps_{l_b,u_b}$
indicate stronger positive association
between $u$ and $v$ in the region given by the bounds.
We use both statistics
because $\cor_{l_{b},u_{b}}(u,v)$ is more familiar, but
in some instances $\Ps_{l_b,u_b}$ appears to have more power to
reveal tail dependence.
<!--Decided we do not need this fig.
\begin{figure}[!h]
\begin{center}
\includegraphics[width=6 cm,height=6 cm]{./stat_image.jpg} \hspace{0.6 cm}
\caption[For definitions of nonparametric statistics]{Schematic diagram supporting definitions of nonparametric tail dependence statistics. The blue and red lines are, respectively, $u+v=2l_b$ and $u+v=2u_b$.\label{fig_stat_image}}
\end{center}
\end{figure}-->
# Testing the nonparametric statistics \label{Test_npa_stat}
Normal and Frank copula families
are known to have symmetric tail dependence,
i.e., strengths of dependence in the lower and upper tails are the same, for all copulas
in these families [@nelsen2006_copula]. Clayton copulas are known to have stronger lower- than
upper-tail dependence, and survival Clayton copulas, being rotations of Clayton copulas by
$180^\circ$, have stronger upper- than lower tail dependence [@nelsen2006_copula].
Using the `iRho` function from the `copula` package, for each of the four families normal,
Frank, Clayton, and survival Clayton, we obtained parameters for which the expected value of
Spearman's $\rho$ was, separately, $0,0.1,0.2,...,0.9$. For each copula family and for each
of the selected parameter values we generated $n$ points, 100 times, and thereby
computed 100 values of the
statistics $\cor_l-\cor_u$, $\Ps_l-\Ps_u$, and $\Dsq_u-\Dsq_l$. This exercise
was repeated, separately,
for $n=1000$ and for $n=35$, these cases being chosen, respectively, to reflect
asymptotic behavior of the
statistics and their behavior on the small datasets which are common in some fields
of ecology. The mean and standard error of the three difference statistics were computed for
each copula family, parameter value, and value of $n$, and results were plotted against
Spearman's rho (Figs \ref{fig_stat_testing35} and \ref{fig_stat_testing1000}),
the expectation being that the difference statistics would be positive for
Clayton copulas, negative for survival Clayton copulas (except for the case of $\rho=0$, a
boundary case of these families corresponding to independence), and not significantly different
from $0$ for Frank and normal
copulas.
We used a $t$-test with a significance threshold of $0.05$ to judge significance here.
These expectations were fulfilled (Figs \ref{fig_stat_testing35} and
\ref{fig_stat_testing1000}).
<!--Simulation for testing non-parametric statistics with different copulas :
The message=F is to suppress warnings that come when you pass a parameter
of 0 to the Frank or Clayton copulas. These are technicallly boundary cases for these families.
They correspond to the independent copula. The packages we use provide the indepdent copula, but
issue a message.-->
```{r stat_testing_save_result, message=F, results="hide", echo=F, cache=T, cache.extra=list(seed,busycores,mtime("TestStats_multivar_dataset.R"),mtime("CopulaFunctions.R"),mtime("CopulaFunctions_flexible.R"))}
source("TestStats_multivar_dataset.R")
set.seed(seed)
resultsloc<-"./Results/stat_results/stat_testing/"
spearvals<-seq(from=0,to=0.9,by=0.1)
callfn<-coplist_with_params(spearvals=spearvals)
coplist<-callfn$coplist
res_pt35_rankF<-mclapply(X=coplist,FUN=worker,numpts=35,numsims=100,rank=F,mc.cores=busycores)
res_pt35_rankT<-mclapply(X=coplist,FUN=worker,numpts=35,numsims=100,rank=T,mc.cores=busycores)
res_pt1000_rankF<-mclapply(X=coplist,FUN=worker,numpts=1000,numsims=100,rank=F,mc.cores=busycores)
res_pt1000_rankT<-mclapply(X=coplist,FUN=worker,numpts=1000,numsims=100,rank=T,mc.cores=busycores)
save(res_pt35_rankF,res_pt35_rankT,res_pt1000_rankF,res_pt1000_rankT,file=paste(resultsloc,"StatTestNumericResults.RData",sep=''))
b<-callfn$paramlist
plotter_stat_testing(reslist=res_pt35_rankF,filename="res_pt35_rankF",xaxparams=b,resultsloc,spearvals)
plotter_stat_testing(reslist=res_pt35_rankT,filename="res_pt35_rankT",xaxparams=b,resultsloc,spearvals)
plotter_stat_testing(reslist=res_pt1000_rankF,filename="res_pt1000_rankF",xaxparams=b,resultsloc,spearvals)
plotter_stat_testing(reslist=res_pt1000_rankT,filename="res_pt1000_rankT",xaxparams=b,resultsloc,spearvals)
```
\begin{figure}[!h]
\begin{center}
\includegraphics[width=16 cm]{./Results/stat_results/stat_testing/res_pt35_rankT.pdf}
\caption[Testing nonparametric statistics with 35 data points]{Results of tests of whether $\cor_l-\cor_u$, $\Ps_l-\Ps_u$, and $\Dsq_u-\Dsq_l$ reveal the known asymmetry of tail dependence of the Clayton and survival Clayton copulas, and the known symmetry of tail dependence of the normal and Frank copulas. p-values (indicated by the triangles), when less than $0.05$ (below the dashed line), mean there is significant tail asymmetry. See Appendix \ref{Test_npa_stat} for details. $n=35$. \label{fig_stat_testing35}}
\end{center}
\end{figure}
\begin{figure}[!h]
\begin{center}
\includegraphics[width=16 cm]{./Results/stat_results/stat_testing/res_pt1000_rankT.pdf}
\caption[Testing nonparametric statistics with 1000 data points]{Results of tests of whether $\cor_l-\cor_u$, $\Ps_l-\Ps_u$, and $\Dsq_u-\Dsq_l$ reveal the known asymmetry of tail dependence of the Clayton and survival Clayton copulas, and the known symmetry of tail dependence of the normal and Frank copulas. p-values (indicated by the triangles), when less than $0.05$ (below the dashed line), mean there is significant tail asymmetry. See Appendix \ref{Test_npa_stat} for details. $n=1000$.\label{fig_stat_testing1000}}
\end{center}
\end{figure}
<!--This chunk is for model selection results of soilCN dataset-->
```{r bivmodselect_Loecke, echo=F, cache=T, cache.extra=list(seed,v_CN,mtime("OurBiCopSelect.R"),mtime("MyBiCopGofTest.R"),mtime("preprocessors.R"))}
source("OurBiCopSelect.R")
set.seed(seed)
families_Loecke<-c(1,3:10,13:14,16:20)
BivMS_res_Loecke<-OurBiCopSelect(u1=v_CN[,1],u2=v_CN[,2],families=families_Loecke,level=0.05,AICBIC="AIC",numBSsmall=100,pthresh=0.2,numBSlarge=1000,gofnormal=F,status=F)
saveRDS(BivMS_res_Loecke,file="./Results/fitting_results/BivMS_soilCN.RDS")
```
<!--This chunk is for npa testing results of soilCN dataset-->
```{r stat_soilCN_graphic_approach, echo=F, results="hide", cache=T, cache.extra=list(seed,v_CN,mtime("bivfunctionplot.R"),mtime("CopulaFunctions_flexible.R"),mtime("copsurrog2d.R"))}
source("bivfunctionplot.R")
set.seed(seed)
stat_soilCN_ga<-bivfunctionplot(v=v_CN,resloc="./Results/stat_results/stat_soilCN/",nametag="soilCN",numbin=10)
```
<!--Simulations for model selection results with Birds' BMR data-->
```{r bivmodselect_birds_BMR, echo=F, cache=T, cache.extra=list(seed,cop_b,mtime("OurBiCopSelect.R"),mtime("MyBiCopGofTest.R"),mtime("preprocessors.R"))}
source("OurBiCopSelect.R")
set.seed(seed)
BivMS_birds<-OurBiCopSelect(u1=cop_b[,1],u2=cop_b[,2],families=c(1,3:10,13:14,16:20),
level=0.05,AICBIC="AIC",numBSsmall=100,pthresh=0.2,numBSlarge=1000,
gofnormal=F,status=F)
saveRDS(BivMS_birds,file="./Results/BMR_results/birds/BivMS_birds.RDS")
```
<!--Display model selection results for BMR:birds data in a table-->
```{r tab_bmr_birds_fit, echo=F, results='markup'}
h<-BivMS_birds$InfCritRes[,c("copname","AIC","AICw","BIC","BICw","LTdep","UTdep")]
colnames(h)<-c("Copula","AIC","AICw","BIC","BICw","LT","UT")
h_ord <- h[order(h$AIC),] #sorting data: min AIC to max AIC
#---- This line forces the formating which is not always true by using digits arg in kable function ----
h_ord$AIC<-formatC(h_ord$AIC,2,format="f")
h_ord$AICw<-formatC(h_ord$AICw,2,format="f")
h_ord$BIC<-formatC(h_ord$BIC,2,format="f")
h_ord$BICw<-formatC(h_ord$BICw,2,format="f")
h_ord$LT<-formatC(h_ord$LT,4,format="f")
h_ord$UT<-formatC(h_ord$UT,4,format="f")
#-------------------------------------------------
knitr::kable(h_ord,
format='latex',linesep = "",row.names = F, #digits = c(4,2,2,2,2,4,4),
caption.short = "Model fitting results for the bird body mass and BMR dataset",
caption = "Results of fitting our 16 copula families to the bird body mass and BMR dataset. Analogous to Fig. \\ref{MT-tab_soilCNfit}, see caption of that figure for details. \\label{tab_bmr_birds_fit}",
booktabs=T)
```
<!--This chunk is for npa testing results for Birds' BMR dataset-->
```{r stat_bmr_birds_graphic_approach, echo=F, results="hide", cache=T, cache.extra=list(seed,cop_b,mtime("bivfunctionplot.R"),mtime("CopulaFunctions_flexible.R"),mtime("copsurrog2d.R"))}
source("bivfunctionplot.R")
set.seed(seed)
stat_birds_ga<-bivfunctionplot(v=cop_b,resloc="./Results/BMR_results/birds/",nametag="birds_numbin_10",numbin = 10)
```
\begin{figure}[!h]
\begin{center}
\includegraphics[width=16 cm]{./Results/BMR_results/birds/birds_numbin_10_bivfunctionplot.pdf}
\caption[Nonparametric tests against a normal-copula null, bird body mass and BMR data]{Nonparametric tests for tail dependence and other deviations from normal copula structure, for bird body mass and BMR data. Same format as Fig. \ref{MT-fig_soilCN_nonparam}, see caption of that figure. \label{fig_bmr_birds_nonparam}}
\end{center}
\end{figure}
<!--Simulations for model selection results with Mammals' BMR data-->
```{r bivmodselect_mammals_BMR, echo=F, cache=T, cache.extra=list(seed,cop_m,mtime("OurBiCopSelect.R"),mtime("MyBiCopGofTest.R"),mtime("preprocessors.R"))}
source("OurBiCopSelect.R")
set.seed(seed)
BivMS_mammals<-OurBiCopSelect(u1=cop_m[,1],u2=cop_m[,2],families=c(1,3:10,13:14,16:20),
level=0.05,AICBIC="AIC",numBSsmall=100,pthresh=0.2,numBSlarge=1000,
gofnormal=F,status=F)
saveRDS(BivMS_mammals,file="./Results/BMR_results/mammals/BivMS_mammals.RDS")
```
<!--Display model selection results for BMR:mammals data in a table-->
```{r tab_bmr_mammals_fit, echo=F, results='markup'}
h<-BivMS_mammals$InfCritRes[,c("copname","AIC","AICw","BIC","BICw","LTdep","UTdep")]
colnames(h)<-c("Copula","AIC","AICw","BIC","BICw","LT","UT")
h_ord <- h[order(h$AIC),] #sorting data: min AIC to max AIC
#---- This line forces the formating which is not always true by using digits arg in kable function ----
h_ord$AIC<-formatC(h_ord$AIC,2,format="f")
h_ord$AICw<-formatC(h_ord$AICw,2,format="f")
h_ord$BIC<-formatC(h_ord$BIC,2,format="f")
h_ord$BICw<-formatC(h_ord$BICw,2,format="f")
h_ord$LT<-formatC(h_ord$LT,4,format="f")
h_ord$UT<-formatC(h_ord$UT,4,format="f")
#-------------------------------------------------
knitr::kable(h_ord,
format='latex',linesep = "",row.names = F, #digits = c(4,2,2,2,2,4,4),
caption.short = "Model fitting results for the mammal body mass and BMR dataset",
caption = "Results of fitting our 16 copula families to the mammal body mass and BMR dataset. Analogous to Fig. \\ref{MT-tab_soilCNfit}, see caption of that figure for details. \\label{tab_bmr_mammals_fit}",
booktabs=T)
```
<!--This chunk is for npa testing results for Mammals' BMR dataset-->
```{r stat_bmr_mammals_graphic_approach, echo=F, results="hide", cache=T, cache.extra=list(seed,cop_m,mtime("bivfunctionplot.R"),mtime("CopulaFunctions_flexible.R"),mtime("copsurrog2d.R"))}
source("bivfunctionplot.R")
set.seed(seed)
stat_mammals_ga<-bivfunctionplot(v=cop_m,resloc="./Results/BMR_results/mammals/",nametag="mammals_numbin_10",numbin = 10)
```
\begin{figure}[!h]
\begin{center}
\includegraphics[width=16 cm]{./Results/BMR_results/mammals/mammals_numbin_10_bivfunctionplot.pdf}
\caption[Nonparametric tests against a normal-copula null, mammal body mass and BMR data]{Nonparametric tests for tail dependence and other deviations from normal copula structure, for mammal body mass and BMR data. Same format as Fig. \ref{MT-fig_soilCN_nonparam}, see caption of that figure. \label{fig_bmr_mammals_nonparam}}