##### Each Bystander Related Behaviour (BRB) ##### data <- read.table("Data_R2.txt",header=T,sep="\t") str(data) data$Hypothesis <- as.factor(data$Hypothesis) ### Eavesdropping eavesHyp <- table(data$Eavesdropping, data$Hypothesis) dimnames(eavesHyp)<-list(Eavesdropping=c("no-evidence","evidence"), Hypothesis=c("competition","other")) eavesChiSqResult <- chisq.test(eavesHyp, simulate.p.value=TRUE) eavesChiSqResult$expected # Hypothesis # Eavesdropping competition other # no-evidence 15.774648 40.22535 # evidence 4.225352 10.77465 ## the assumption that the expected frequencies are at least 5 ## in no less than 80% of the cells in the contingency table is not fulfilled # Therefore, we ran Fisher's exact test (eavesFisherResult <- fisher.test(eavesHyp)) # p-value = 0.00383 # alternative hypothesis: true odds ratio is not equal to 1 # 95 percent confidence interval: # 0.0396541 0.6549499 # sample estimates: # odds ratio # 0.1683376 eavesHyp # Hypothesis # Eavesdropping competition other # no-evidence 11 45 # evidence 9 6 ## Odds ratio (9/20)/(6/51) # 3.825 # it was 3.8 times more likely to find evidence of eavesdropping # for species related to the intrasexual competition hypothesis # than for those linked to other hypotheses ### Exploitation expHyp <- table(data$Exploitation, data$Hypothesis) dimnames(expHyp)<-list(Exploitation=c("no-evidence","evidence"), Hypothesis=c("competition","other")) expChiSqResult <- chisq.test(expHyp, simulate.p.value=TRUE) expChiSqResult$expected # Hypothesis # Exploitation competition other # no-evidence 17.464789 44.535211 # evidence 2.535211 6.464789 (expFisherResult <- fisher.test(expHyp)) # p-value = 0.1051 # alternative hypothesis: true odds ratio is not equal to 1 # 95 percent confidence interval: # 0.04548752 1.38497379 # sample estimates: # odds ratio # 0.2613004 ### Audience effect ('audience effect' test) audHyp <- table(data$Audience, data$Hypothesis) dimnames(audHyp)<-list(Audience=c("no-evidence","evidence"), Hypothesis=c("competition","other")) audChiSqResult <- chisq.test(audHyp, simulate.p.value=TRUE) audChiSqResult$expected # Hypothesis # Audience competition other # no-evidence 17.183099 43.816901 # evidence 2.816901 7.183099 (audFisherResult <- fisher.test(audHyp)) # p-value = 0.1314 # alternative hypothesis: true odds ratio is not equal to 1 # 95 percent confidence interval: # 0.06609034 1.65608514 # sample estimates: # odds ratio # 0.3321457 ### Removing 10 species for which at least another hypothesis was also suggested ### row_names_df_to_remove<-c("Oreochromis mossambicus","Cygnus atratus","Ptilonorhynchus violaceus","Aphidius ervi","Byrsotria fumigata","Cotesia rubecula","Euphydryas editha","Eupoecilia ambiguella","Capra hircus","Thamnophis sirtalis") data2 <- data[!(data$Species %in% row_names_df_to_remove),] ### Eavesdropping eavesHyp2 <- table(data2$Eavesdropping, data2$Hypothesis) dimnames(eavesHyp2)<-list(Eavesdropping=c("no evidence","evidence"), Hypothesis=c("competition","other")) eavesChiSqResult2 <- chisq.test(eavesHyp2, simulate.p.value=TRUE) eavesChiSqResult2$expected (eavesFisherResult2 <- fisher.test(eavesHyp2)) # p-value = 0.01211 # alternative hypothesis: true odds ratio is not equal to 1 # 95 percent confidence interval: # 0.02330775 0.79568593 # sample estimates: # odds ratio # 0.1400554 ### Exploitation expHyp2 <- table(data2$Exploitation, data2$Hypothesis) dimnames(expHyp2)<-list(Exploitation=c("no evidence","evidence"),Hypothesis=c("competition","other")) expChiSqResult2 <- chisq.test(expHyp2, simulate.p.value=TRUE) expChiSqResult2$expected (expFisherResult2 <- fisher.test(expHyp2)) # p-value = 0.2526 # alternative hypothesis: true odds ratio is not equal to 1 # 95 percent confidence interval: # 0.04111985 4.44921221 # sample estimates: # odds ratio # 0.3483708 ### Audience effect audHyp2 <- table(data2$Audience, data2$Hypothesis) dimnames(audHyp2)<-list(Audience=c("no evidence","evidence"),Hypothesis=c("competition","other")) audChiSqResult2 <- chisq.test(audHyp2, simulate.p.value=TRUE) audChiSqResult2$expected (audFisherResult2 <- fisher.test(audHyp2, simulate.p.value=TRUE)) # p-value = 0.1154 # alternative hypothesis: true odds ratio is not equal to 1 # 95 percent confidence interval: # 0.03917116 2.05207579 # sample estimates: # odds ratio # 0.2615068 ##### Combined BRB ##### data$BRBcombined <- data$Eavesdropping + data$Exploitation + data$Audience BRBHyp <- table(data$BRBcombined, data$Hypothesis) dimnames(BRBHyp)<-list(BRBcombined=c("none","one","two","three"), Hypothesis=c("competition","other")) BRBHyp # Hypothesis # BRBcombined competition other # none 11 41 # one 1 6 # two 6 3 # three 2 1 BRBChiSqResult <- chisq.test(BRBHyp, simulate.p.value=TRUE) BRBChiSqResult$expected # Hypothesis # BRBcombined competition other # none 14.6478873 37.352113 # one 1.9718310 5.028169 # two 2.5352113 6.464789 # three 0.8450704 2.154930 ## the assumption that the expected frequencies are at least 5 ## in no less than 80% of the cells in the contingency table is not fulfilled # Therefore, we ran Fisher's exact test (BRBFisherResult<- fisher.test(BRBHyp)) # p-value = 0.01035 # alternative hypothesis: two.sided3. ### Odds ratio (2/11)/(1/41) # 7.454545 # it was 7.5 times more likely to find all 3 bystander-related behaviours combined than no BRB # for species related to the intrasexual competition hypothesis than the other hypotheses ### Removing 10 species for which at least another hypothesis was also suggested ### data2$BRBcombined <- data2$Eavesdropping + data2$Exploitation + data2$Audience BRBHyp2 <- table(data2$BRBcombined, data2$Hypothesis) dimnames(BRBHyp2)<-list(BRBcombined=c("none","one","two","three"), Hypothesis=c("competition","other")) BRBHyp2 # Hypothesis # BRBcombined competition other # none 5 41 # one 1 6 # two 3 3 # three 1 1 BRBChiSqResult2 <- chisq.test(BRBHyp2, simulate.p.value=TRUE) BRBChiSqResult2$expected # Hypothesis # BRBcombined competition other # none 7.5409836 38.459016 # one 1.1475410 5.852459 # two 0.9836066 5.016393 # three 0.3278689 1.672131 (BRBFisherResult2<- fisher.test(BRBHyp2)) # p-value = 0.04924 # alternative hypothesis: two.sided3.