iMPORTATION DES DONNÉES

FONCTION QUI TRANSFORME LES BD DES PERTURBATIONS EN DONNÉES BINAIRES

RAJOUTER LES PERTURBATIONS BINAIRES AUX BASES DE DONNÉES

On tranforme les perturbation de binaire en variable catégorielle.

TRansformation de la BD

tibble [3,197 × 7] (S3: tbl_df/tbl/data.frame)
 $ Site        : chr [1:3197] "T52" "T52" "T52" "T52" ...
 $ Esp         : chr [1:3197] "BOP" "BOP" "BOP" "BOP" ...
 $ Id          : chr [1:3197] "APY4" "APY4" "APY5" "APY5" ...
 $ Perturbation: chr [1:3197] "feu" "feu" "feu" "feu" ...
 $ Position    : chr [1:3197] "after" "before" "after" "before" ...
 $ mean_bai    : num [1:3197] 328 142 794 286 114 ...
 $ n_years     : int [1:3197] 10 10 10 10 10 10 10 10 1 10 ...

MODELE linéaire AVEC BAI

ERR

Plot de début de

Modélisation

On applique le modèle

lmer_bai <- lmer(mean_bai ~ Perturbation*Position + (1 | Id) + (1 | Site) , data = bai.final_10ans_2_ERR, REML=T) # Effet d'croisée entre Id et Site

anova(lmer_bai)
Type III Analysis of Variance Table with Satterthwaite's method
                        Sum Sq Mean Sq NumDF
Perturbation          11793173 5896586     2
Position                285274  285274     1
Perturbation:Position     9378    4689     2
                       DenDF F value  Pr(>F)    
Perturbation          459.29 99.7084 < 2e-16 ***
Position              510.95  4.8238 0.02852 *  
Perturbation:Position 525.32  0.0793 0.92379    
---
Signif. codes:  
0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(lmer_bai)
Linear mixed model fit by REML. t-tests use
  Satterthwaite's method [lmerModLmerTest]
Formula: 
mean_bai ~ Perturbation * Position + (1 | Id) + (1 | Site)
   Data: bai.final_10ans_2_ERR

REML criterion at convergence: 10231

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-2.7041 -0.5696 -0.1291  0.4212  4.8383 

Random effects:
 Groups   Name        Variance Std.Dev.
 Id       (Intercept) 31454.2  177.35  
 Site     (Intercept)   396.9   19.92  
 Residual             59138.3  243.18  
Number of obs: 728, groups:  Id, 278; Site, 8

Fixed effects:
                               Estimate
(Intercept)                      92.426
Perturbationfeu                 -38.392
Perturbationtbe                 326.188
Positionbefore                  -85.279
Perturbationfeu:Positionbefore   31.098
Perturbationtbe:Positionbefore   -6.364
                               Std. Error      df
(Intercept)                        31.067 104.378
Perturbationfeu                    66.053 458.414
Perturbationtbe                    31.904 542.502
Positionbefore                     40.413 547.393
Perturbationfeu:Positionbefore    103.182 511.904
Perturbationtbe:Positionbefore     46.000 547.265
                               t value Pr(>|t|)
(Intercept)                      2.975  0.00364
Perturbationfeu                 -0.581  0.56137
Perturbationtbe                 10.224  < 2e-16
Positionbefore                  -2.110  0.03530
Perturbationfeu:Positionbefore   0.301  0.76324
Perturbationtbe:Positionbefore  -0.138  0.89002
                                  
(Intercept)                    ** 
Perturbationfeu                   
Perturbationtbe                ***
Positionbefore                 *  
Perturbationfeu:Positionbefore    
Perturbationtbe:Positionbefore    
---
Signif. codes:  
0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation of Fixed Effects:
            (Intr) Prtrbtnf Prtrbtnt Pstnbf
Perturbatnf -0.363                         
Perturbtntb -0.802  0.363                  
Positionbfr -0.581  0.318    0.572         
Prtrbtnf:Ps  0.226 -0.596   -0.222   -0.396
Prtrbtntb:P  0.512 -0.281   -0.656   -0.878
            Prtrbtnf:P
Perturbatnf           
Perturbtntb           
Positionbfr           
Prtrbtnf:Ps           
Prtrbtntb:P  0.350    

Conclusion : le modèle est significatif. Il y a donc une différence significative de la moyenne du BAI entre type de perturbations.

VALIDATION DU MODÈLE

3.1 Vérifier l’homogénéité de la variance : Résidus vs Prédits (détection globale)

# Extraire les résidus et valeurs prédites
model <- lmer_bai
df <- bai.final_10ans_2_ERR
df$residus <- residuals(model)
df$fitted <- fitted(model)

# Graphique de base
library(ggplot2)
ggplot(df, aes(x = fitted, y = residus)) +
  geom_point(alpha = 0.5, color = "blue") +
  geom_hline(yintercept = 0, color = "red", linetype = "dashed") +
  geom_smooth(method = "loess", color = "red", se = FALSE) +
  labs(title = "Résidus vs Prédits",
       x = "Valeurs prédites (bai)",
       y = "Résidus") +
  theme_minimal() +
  theme(plot.title = element_text(hjust = 0.5))

Interprétation : Étendue non-homogène des résidus -> la supposition non- respectée!

Q-Q PLOT

####3.2 Vérifier l’indépendance des résidus avec chaque covariable

EFFETS FIXES
Pour Pert_type (facteur)

Pour Year (facteur)

Pour l’interaction Pert_type:Year

EFFETS ALÉATOIRES

Interprétation : Étendue homogène des résidus autour de 0 -> pas de patron des résidus en fonction de la variable, la supposition n’est pas respectée!

3.3 Vérifier la normalité des résidus

Interprétation : Des résidus suivant une distribution normale indiquent que le modèle n’est pas biaisé.

CONCLUSION : FAIRE LA TRANSFORMATION LOGARITHMIQUE

Transformation logarithmique

bai.final_10ans_2_ERR$mean.bai_log <- log(bai.final_10ans_2_ERR$mean_bai)  # Ajoute une colonne transformée

lmer_bai_log <- lmer(mean.bai_log ~ Perturbation*Position + (1 | Id) + (1 | Site), data = bai.final_10ans_2_ERR, REML=T)

summary(lmer_bai_log)
Linear mixed model fit by REML. t-tests use
  Satterthwaite's method [lmerModLmerTest]
Formula: 
mean.bai_log ~ Perturbation * Position + (1 | Id) + (1 | Site)
   Data: bai.final_10ans_2_ERR

REML criterion at convergence: 2064

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-3.2630 -0.5694  0.0750  0.6232  2.3908 

Random effects:
 Groups   Name        Variance Std.Dev.
 Id       (Intercept) 0.47609  0.6900  
 Site     (Intercept) 0.04888  0.2211  
 Residual             0.67252  0.8201  
Number of obs: 728, groups:  Id, 278; Site, 8

Fixed effects:
                                Estimate
(Intercept)                      4.11822
Perturbationfeu                 -0.32197
Perturbationtbe                  1.52693
Positionbefore                  -0.33777
Perturbationfeu:Positionbefore   0.21239
Perturbationtbe:Positionbefore   0.02722
                               Std. Error
(Intercept)                       0.13224
Perturbationfeu                   0.22837
Perturbationtbe                   0.11003
Positionbefore                    0.13787
Perturbationfeu:Positionbefore    0.34945
Perturbationtbe:Positionbefore    0.15687
                                      df t value
(Intercept)                     31.74612  31.141
Perturbationfeu                488.32331  -1.410
Perturbationtbe                542.28221  13.878
Positionbefore                 507.79349  -2.450
Perturbationfeu:Positionbefore 474.59228   0.608
Perturbationtbe:Positionbefore 507.35664   0.174
                               Pr(>|t|)    
(Intercept)                      <2e-16 ***
Perturbationfeu                  0.1592    
Perturbationtbe                  <2e-16 ***
Positionbefore                   0.0146 *  
Perturbationfeu:Positionbefore   0.5436    
Perturbationtbe:Positionbefore   0.8623    
---
Signif. codes:  
0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation of Fixed Effects:
            (Intr) Prtrbtnf Prtrbtnt Pstnbf
Perturbatnf -0.298                         
Perturbtntb -0.654  0.365                  
Positionbfr -0.471  0.331    0.571         
Prtrbtnf:Ps  0.185 -0.585   -0.224   -0.398
Prtrbtntb:P  0.416 -0.294   -0.655   -0.878
            Prtrbtnf:P
Perturbatnf           
Perturbtntb           
Positionbfr           
Prtrbtnf:Ps           
Prtrbtntb:P  0.352    
anova(lmer_bai_log)
Type III Analysis of Variance Table with Satterthwaite's method
                       Sum Sq Mean Sq NumDF
Perturbation          258.365 129.182     2
Position                3.162   3.162     1
Perturbation:Position   0.250   0.125     2
                       DenDF  F value  Pr(>F)    
Perturbation          527.54 192.0880 < 2e-16 ***
Position              474.46   4.7024 0.03062 *  
Perturbation:Position 486.96   0.1856 0.83064    
---
Signif. codes:  
0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Vérification dU MODÈLE

# Extraire les résidus et valeurs prédites
model <- lmer_bai_log
df <- bai.final_10ans_2_ERR
df$residus <- residuals(model)
df$fitted <- fitted(model)

# Graphique de base
ggplot(df, aes(x = fitted, y = residus)) +
  geom_point(alpha = 0.5, color = "blue") +
  geom_hline(yintercept = 0, color = "red", linetype = "dashed") +
  geom_smooth(method = "loess", color = "red", se = FALSE) +
  labs(title = "Résidus vs Prédits",
       x = "Valeurs prédites (bai)",
       y = "Résidus") +
  theme_minimal() +
  theme(plot.title = element_text(hjust = 0.5))

Q-Q PLOT

Graphique du modèle

GRAPHIQUE

GRAPHIQUE GLOBAL