data & packages

df = readRDS("ecd_obs_agathe.RDS") 
df <- df[!is.na(df$obs_ts),] 
df[is.na(df)] <- 0
library('rsq')
library(ggfortify)
## Loading required package: ggplot2
library('AER')
## Loading required package: car
## Loading required package: carData
## Registered S3 methods overwritten by 'car':
##   method                          from
##   influence.merMod                lme4
##   cooks.distance.influence.merMod lme4
##   dfbeta.influence.merMod         lme4
##   dfbetas.influence.merMod        lme4
## Loading required package: lmtest
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: sandwich
## Loading required package: survival

Species to consider + Stratification+ Legende+ Distribution

espece<-c("num_Other_bony_fishes","num_Silky_shark","num_Common_dolphinfish")


df$num_Other_bony_fishes=df$`num_Other bony fishes`
df$num_Common_dolphinfish=df$`num_Common dolphinfish`
df$num_Silky_shark=df$`num_Silky shark`


df$group = paste0("O",df$ocean,"G",df$code_assoc_groupe) 
# Création d'une variable groupe 
# O1G1, O1G2, O2G1, O2G2
# O1: Atlantique 02: Indien
# G1: Floating object G2: Free swiming school 
## Par océan et banc 
df1<-df[df$group =="O1G1",] 
# df1 contient tous les calais qui sont sont O1G1
df2<-df[df$group =="O1G2",]
# df2 contient tous les calais qui sont O1G2
df3<-df[df$group =="O2G1",]
# df3 contient tous les calais qui sont O2G1
df4<-df[df$group =="O2G2",]
# df4 contient tous les calais qui sont O2G2

# légende -----------------------------------------------

strat<-c("O1G1","O1G2","O2G1","O2G2")
data_list<-list(O1G1=df1,O1G2=df2,O2G1=df3,O2G2=df4)

# Distribution----------------------------------------
famille<-"poisson"

Results regression

res_regression<-list()
for (i in 1:length(espece)){
for (j in 1:length(data_list)){
data <- data_list[[j]]
form <- formula(paste(espece[i],"capture_total_target_tunas_corrigee", sep="~"))
reg <- glm(form, data=data,family=famille)
gr=strat[j]
sp=gsub("^num_","",espece[i])
fn=paste(gr,sp,sep=".")
res_regression[[paste(gr,sp,sep=".")]] = list(sp=sp,gr=gr,fn=fn,reg=reg)
}
}

Pvalues & overdispersion

pvalues<-list()
for (v in res_regression){
    overdisp<-summary(v$reg)$deviance/summary(v$reg)$df.residual
    test<-dispersiontest(v$reg)$p.value[[1]] 
    disp<-dispersiontest(v$reg)$estimate[[1]] 
    pvalue<-summary(v$reg)$coefficients["capture_total_target_tunas_corrigee","Pr(>|z|)"]
    b<-c(pvalue,rsq(v$reg),overdisp,test,disp)
    pvalues[[v$fn]]<-b
}
## Warning in cbind(y, yfit): number of rows of result is not a multiple of vector
## length (arg 2)

## Warning in cbind(y, yfit): number of rows of result is not a multiple of vector
## length (arg 2)

## Warning in cbind(y, yfit): number of rows of result is not a multiple of vector
## length (arg 2)

## Warning in cbind(y, yfit): number of rows of result is not a multiple of vector
## length (arg 2)

## Warning in cbind(y, yfit): number of rows of result is not a multiple of vector
## length (arg 2)

## Warning in cbind(y, yfit): number of rows of result is not a multiple of vector
## length (arg 2)

## Warning in cbind(y, yfit): number of rows of result is not a multiple of vector
## length (arg 2)

## Warning in cbind(y, yfit): number of rows of result is not a multiple of vector
## length (arg 2)

## Warning in cbind(y, yfit): number of rows of result is not a multiple of vector
## length (arg 2)
colnames<-c("Pvalue capture","R-square","Overdispersion","Overdispersion test","Dispersion ")
pvalues.table<-t(as.data.frame(pvalues))
colnames(pvalues.table)<-colnames
pvalues.table
##                         Pvalue capture      R-square Overdispersion
## O1G1.Other_bony_fishes    0.000000e+00  2.363634e-01    758.7641105
## O1G2.Other_bony_fishes    2.498381e-05  7.569965e-02      5.5751838
## O2G1.Other_bony_fishes    0.000000e+00  1.841816e-01    295.5319400
## O2G2.Other_bony_fishes    3.523655e-01  1.008813e-06     28.2283986
## O1G1.Silky_shark          0.000000e+00  3.380116e-02      3.2184410
## O1G2.Silky_shark          0.000000e+00  2.344117e-02      3.4743134
## O2G1.Silky_shark          0.000000e+00  2.377944e-01      7.2022793
## O2G2.Silky_shark          5.765928e-01  1.197639e-05      0.7512533
## O1G1.Common_dolphinfish  6.045728e-169  8.379433e-02     20.8424912
## O1G2.Common_dolphinfish   2.416903e-02  9.055430e-03      0.8027919
## O2G1.Common_dolphinfish  8.595653e-251  1.820994e-01     33.5334666
## O2G2.Common_dolphinfish   2.475783e-77 -9.734212e-04      2.9332413
##                         Overdispersion test Dispersion 
## O1G1.Other_bony_fishes         2.041407e-22 1341.299137
## O1G2.Other_bony_fishes         3.396797e-03   87.236100
## O2G1.Other_bony_fishes         1.472409e-06  652.135720
## O2G2.Other_bony_fishes         1.846581e-02  615.483922
## O1G1.Silky_shark               1.598562e-07    8.304379
## O1G2.Silky_shark               1.075953e-02   45.378869
## O2G1.Silky_shark               1.363179e-21   11.343276
## O2G2.Silky_shark               8.993384e-03    8.498579
## O1G1.Common_dolphinfish        5.504921e-04   74.049824
## O1G2.Common_dolphinfish        1.342407e-01   67.390908
## O2G1.Common_dolphinfish        4.660110e-15   65.996285
## O2G2.Common_dolphinfish        1.042627e-01   82.282848

regression by fishing mode

ocean 1 = Atlantic

reg_byocean_O1G1<-list(res_regression$O1G1.Other_bony_fishes, res_regression$O1G1.Silky_shark,res_regression$O1G1.Common_dolphinfish)

reg_byocean_O1G2<-list(res_regression$O1G2.Other_bony_fishes, res_regression$O1G2.Silky_shark,res_regression$O1G2.Common_dolphinfish)

  for (i in 1:3){
  v=reg_byocean_O1G1[[i]]
  b1<-summary(v$reg)$coefficients[1]
  a1<-summary(v$reg)$coefficients[2]
  p=reg_byocean_O1G2[[i]]
  b2<-summary(p$reg)$coefficients[1]
  a2<-summary(p$reg)$coefficients[2]
  
  #diagnostique
  par(mfrow = c(2, 2))
  plot(v$reg) 
  #diagnostique
  par(mfrow = c(2, 2))
  plot(p$reg)
  
  
  data1et2<-rbind(df1,df2)
  data1et2$group <- as.factor(data1et2$group)
  
  plot<-ggplot(data1et2, aes(x=capture_total_target_tunas_corrigee,y=get(paste("num_",v$sp,sep = ""),data1et2)))+
    geom_abline(slope = a1,intercept = b1,color="#20B2AA")+
    geom_abline(slope = a2,intercept = b2,color="#FF7F50")+
    ggtitle("Regression by fishing mode, Atlantic ocean" )+
    geom_point(aes(colour=group))+
    ylab(v$sp)
  
  print(plot)
 
}

Ocean 2 = Indien

reg_byocean_O2G1<-list(res_regression$O2G1.Other_bony_fishes, res_regression$O2G1.Silky_shark,res_regression$O2G1.Common_dolphinfish)

reg_byocean_O2G2<-list(res_regression$O2G2.Other_bony_fishes, res_regression$O2G2.Silky_shark,res_regression$O2G2.Common_dolphinfish)

  for (i in 1:3){
  v=reg_byocean_O2G1[[i]]
  b1<-summary(v$reg)$coefficients[1]
  a1<-summary(v$reg)$coefficients[2]
  p=reg_byocean_O2G2[[i]]
  b2<-summary(p$reg)$coefficients[1]
  a2<-summary(p$reg)$coefficients[2]
  
  #diagnostique
  par(mfrow = c(2, 2))
  plot(v$reg) 
  
   #diagnostique
  par(mfrow = c(2, 2))
  plot(p$reg)
  
  data1et2<-rbind(df3,df4)
  data1et2$group <- as.factor(data1et2$group)
  
  plot<-ggplot(data1et2, aes(x=capture_total_target_tunas_corrigee,y=get(paste("num_",v$sp,sep = ""),data1et2)))+
    geom_abline(slope = a1,intercept = b1,color="#20B2AA")+
    geom_abline(slope = a2,intercept = b2,color="#FF7F50")+
    ggtitle("Regression by fishing mode, Indian ocean" )+
    geom_point(aes(colour=group))+
    ylab(v$sp)
  
  print(plot)
 
}

Regression by ocean

Fishing mode 1 : Floating object

reg_fishingmode_O1G1<-list(res_regression$O1G1.Other_bony_fishes, res_regression$O1G1.Silky_shark,res_regression$O1G1.Common_dolphinfish)

reg_fishingmode_O2G1<-list(res_regression$O2G1.Other_bony_fishes, res_regression$O2G1.Silky_shark,res_regression$O2G1.Common_dolphinfish)

  for (i in 1:3){
  v=reg_byocean_O1G1[[i]]
  b1<-summary(v$reg)$coefficients[1]
  a1<-summary(v$reg)$coefficients[2]
  p=reg_byocean_O2G1[[i]]
  b2<-summary(p$reg)$coefficients[1]
  a2<-summary(p$reg)$coefficients[2]
  
  #diagnostique
  par(mfrow = c(2, 2))
  plot(v$reg) 
  #diagnostique
  par(mfrow = c(2, 2))
  plot(p$reg)
  
  
  data1et2<-rbind(df1,df3)
  data1et2$group <- as.factor(data1et2$group)
  
  plot<-ggplot(data1et2, aes(x=capture_total_target_tunas_corrigee,y=get(paste("num_",v$sp,sep = ""),data1et2)))+
    geom_abline(slope = a1,intercept = b1,color="#20B2AA")+
    geom_abline(slope = a2,intercept = b2,color="#FF7F50")+
    ggtitle("Regression by ocean, Floating object fishing")+
    geom_point(aes(colour=group))+
    ylab(v$sp)
  
  print(plot)
 
}

fishing mode 2 : free school

reg_fishingmode_O1G2<-list(res_regression$O1G2.Other_bony_fishes, res_regression$O1G2.Silky_shark,res_regression$O1G2.Common_dolphinfish)

reg_fishingmode_O2G2<-list(res_regression$O2G2.Other_bony_fishes, res_regression$O2G2.Silky_shark,res_regression$O2G2.Common_dolphinfish)

  for (i in 1:3){
  v=reg_byocean_O1G2[[i]]
  b1<-summary(v$reg)$coefficients[1]
  a1<-summary(v$reg)$coefficients[2]
  p=reg_byocean_O2G2[[i]]
  b2<-summary(p$reg)$coefficients[1]
  a2<-summary(p$reg)$coefficients[2]
  
  #diagnostique
  par(mfrow = c(2, 2))
  plot(v$reg) 
  #diagnostique
  par(mfrow = c(2, 2))
  plot(p$reg)
  
  
  data1et2<-rbind(df2,df4)
  data1et2$group <- as.factor(data1et2$group)
  
  plot<-ggplot(data1et2, aes(x=capture_total_target_tunas_corrigee,y=get(paste("num_",v$sp,sep = ""),data1et2)))+
    geom_abline(slope = a1,intercept = b1,color="#20B2AA")+
    geom_abline(slope = a2,intercept = b2,color="#FF7F50")+
    ggtitle("Regression by ocean, free school fishing")+
    geom_point(aes(colour=group))+
    ylab(v$sp)
  
  print(plot)
 
}

# Regression by Ocean and fishing mode

reg_O1G1<-list(res_regression$O1G1.Other_bony_fishes, res_regression$O1G1.Silky_shark,res_regression$O1G1.Common_dolphinfish)
reg_O1G2<-list(res_regression$O1G2.Other_bony_fishes, res_regression$O1G2.Silky_shark,res_regression$O1G2.Common_dolphinfish)
reg_O2G1<-list(res_regression$O2G1.Other_bony_fishes, res_regression$O2G1.Silky_shark,res_regression$O2G1.Common_dolphinfish)
reg_O2G2<-list(res_regression$O2G2.Other_bony_fishes, res_regression$O2G2.Silky_shark,res_regression$O2G2.Common_dolphinfish)

  for (i in 1:3){
    v<-reg_O1G1[[i]]
  b1<-summary(v$reg)$coefficients[1]
  a1<-summary(v$reg)$coefficients[2] 
    p<-reg_O1G2[[i]]
  b2<-summary(p$reg)$coefficients[1]
  a2<-summary(p$reg)$coefficients[2] 
    x<-reg_O2G1[[i]]
  b3<-summary(x$reg)$coefficients[1]
  a3<-summary(x$reg)$coefficients[2] 
    z<-reg_O2G2[[i]]
  b4<-summary(z$reg)$coefficients[1]
  a4<-summary(z$reg)$coefficients[2] 
  
  #diagnostique
  par(mfrow = c(2,2))
  plot(v$reg) 
  par(mfrow = c(2,2))
  plot(p$reg) 
  par(mfrow = c(2,2))
  plot(x$reg) 
  par(mfrow = c(2,2))
  plot(z$reg) 
    
df$group <- as.factor(df$group)

print<-ggplot(df, aes(x=capture_total_target_tunas_corrigee, y=get(paste("num_",v$sp,sep = ""),df)))+
  geom_abline(slope = a1,intercept = b1,color="#20B2AA")+
  geom_abline(slope = a2,intercept = b2,color="#008000")+
  geom_abline(slope = a3,intercept = b3,color="#FF7F50")+
  geom_abline(slope = a4,intercept = b4,color="#c541c5")+
  ggtitle("Regression by ocean and fishing mode")+
  geom_point(aes(colour=group))+
  ylab(v$sp)

print(plot)
}