#####Yoshioka et al. Development of a camera trap for perching dragonflies: a new tool for freshwater environmental assessment. #####Supplemental Code S2 #####This code was executed using R version 4.0.0 (https://www.R-project.org/). ####Validation by time-laps camera monitoring ###Fisher's exact test #The one sided test with the alternative hypothesis that the ratio of true posives to false negatives in the field site is higher than that in the pond site. fisher.test(matrix(c(1,0,8,4),ncol=2,byrow=T),alternative="greater") ####Comparison with the dragonfly census ###The first analysis ##camera detection #Field vs Pond pd1<-chisq.test(c(15,50),simulate.p.value = TRUE, B = 1000000,set.seed(0))$p.value #Pond vs Rooftop pd2<-chisq.test(c(50,0),simulate.p.value = TRUE, B = 1000000,set.seed(0))$p.value #Field vs Rooftop pd3<-chisq.test(c(15,0),simulate.p.value = TRUE, B = 1000000,set.seed(0))$p.value #P-value adjustment by Holm's method pd<-c(pd1,pd2,pd3) adjpd<-pd*rank(-1*pd) #adjusted p-values for Field vs Pond, Pond vs Rooftop, and Field vs Rooftop adjpd ##census observation #Field vs Pond po1<-chisq.test(c(35,21),simulate.p.value = TRUE, B = 1000000,set.seed(0))$p.value #Pond vs Rooftop po2<-chisq.test(c(21,8),simulate.p.value = TRUE, B = 1000000,set.seed(0))$p.value #Field vs Rooftop po3<-chisq.test(c(35,8),simulate.p.value = TRUE, B = 1000000,set.seed(0))$p.value #P-value adjustment by Holm's method po<-c(po1,po2,po3) adjpo<-po*rank(-1*po) #adjusted p-values for Field vs Pond, Pond vs Rooftop, and Field vs Rooftop adjpo ###The second analysis ##In advance, the package glmmTMB should be installed from https://cran.r-project.org/ ##Package loading library(glmmTMB) ##Data loading #census observation for 10 min obs<-c(10,10,0,9,6,0,8,10,0,0,3,0,3,4,0,1,0,0) #Camera detection for 3 hours detect<-c(0,0,0,0,15,0,15,35,0,0,0,0,0,0,0,0,0,0) #Site ID "F":field, "P":pond, "R":rooftop site<-c("F","F","F","F","F","F","P","P","P","P","P","P","R","R","R","R","R","R") #date ID "a":21th October, "b":22th October date<-c("a","a","a","b","b","b","a","a","a","b","b","b","a","a","a","b","b","b") #time period ID 1:9:00-12:00,2:12:00-15:00,3:15:00-18:00 time<-c(1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3) ##GLMM #Whether the camera detection reflect census observation summary(glmmTMB(detect~obs+(1|site)+(1|date)+(1|time),family="nbinom1")) #Whether the census observation reflect camera detection summary(glmmTMB(obs~detect+(1|site)+(1|date)+(1|time),family="nbinom1"))