LIEN PUBLICATION : https://rpubs.com/theophile_kabasele/1448376
tibble [2,834 × 7] (S3: tbl_df/tbl/data.frame)
$ Site : chr [1:2834] "T52" "T52" "T52" "T52" ...
$ Esp : chr [1:2834] "BOP" "BOP" "BOP" "BOP" ...
$ Id : chr [1:2834] "APY4" "APY4" "APY5" "APY5" ...
$ Perturbation: chr [1:2834] "feu" "feu" "feu" "feu" ...
$ Position : chr [1:2834] "after" "before" "after" "before" ...
$ mean_bai : num [1:2834] 328 142 794 286 114 ...
$ n_years : int [1:2834] 10 10 10 10 10 10 10 10 1 10 ...
On applique le modèle
lmer_bai_ERR <- 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_ERR)
Type III Analysis of Variance Table with Satterthwaite's method
Sum Sq Mean Sq NumDF
Perturbation 8552893 4276447 2
Position 793914 793914 1
Perturbation:Position 1493828 746914 2
DenDF F value Pr(>F)
Perturbation 350.76 52.3947 < 2.2e-16
Position 399.42 9.7270 0.0019475
Perturbation:Position 413.94 9.1511 0.0001291
Perturbation ***
Position **
Perturbation:Position ***
---
Signif. codes:
0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(lmer_bai_ERR)
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: 8431.1
Scaled residuals:
Min 1Q Median 3Q Max
-1.6780 -0.5245 -0.1428 0.2747 4.4338
Random effects:
Groups Name Variance Std.Dev.
Id (Intercept) 21288 145.90
Site (Intercept) 1140 33.76
Residual 81620 285.69
Number of obs: 592, groups: Id, 267; Site, 8
Fixed effects:
Estimate
(Intercept) 111.46
Perturbationfeu 33.65
Perturbationtbe 408.31
Positionbefore -46.14
Perturbationfeu:Positionbefore -19.15
Perturbationtbe:Positionbefore -230.20
Std. Error df
(Intercept) 36.00 68.21
Perturbationfeu 77.90 371.95
Perturbationtbe 39.08 334.80
Positionbefore 47.12 451.06
Perturbationfeu:Positionbefore 120.59 403.11
Perturbationtbe:Positionbefore 56.37 437.34
t value Pr(>|t|)
(Intercept) 3.096 0.00284
Perturbationfeu 0.432 0.66601
Perturbationtbe 10.447 < 2e-16
Positionbefore -0.979 0.32802
Perturbationfeu:Positionbefore -0.159 0.87391
Perturbationtbe:Positionbefore -4.084 5.26e-05
(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.771 0.349
Positionbfr -0.586 0.319 0.543
Prtrbtnf:Ps 0.227 -0.595 -0.207 -0.394
Prtrbtntb:P 0.499 -0.281 -0.659 -0.837
Prtrbtnf:P
Perturbatnf
Perturbtntb
Positionbfr
Prtrbtnf:Ps
Prtrbtntb:P 0.333
Conclusion : le modèle est significatif. Il y a donc une différence significative de la moyenne du BAI entre type de perturbations.
# Extraire les résidus et valeurs prédites
model_ERR <- lmer_bai_ERR
df_ERR <- bai.final_10ans_2_ERR
df_ERR$residus <- residuals(model_ERR)
df_ERR$fitted <- fitted(model_ERR)
# Graphique de base
library(ggplot2)
ggplot(df_ERR, 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
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!
Interprétation : Des résidus suivant une distribution normale indiquent que le modèle n’est pas biaisé.
CONCLUSION : FAIRE LA 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_ERR <- lmer(mean.bai_log ~ Perturbation*Position + (1 | Id) + (1 | Site), data = bai.final_10ans_2_ERR, REML=T)
summary(lmer_bai_log_ERR)
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: 1745.9
Scaled residuals:
Min 1Q Median 3Q Max
-2.87838 -0.58971 0.05969 0.67027 2.17292
Random effects:
Groups Name Variance Std.Dev.
Id (Intercept) 0.31688 0.5629
Site (Intercept) 0.05961 0.2441
Residual 0.84397 0.9187
Number of obs: 592, groups: Id, 267; Site, 8
Fixed effects:
Estimate
(Intercept) 4.1670
Perturbationfeu -0.1331
Perturbationtbe 1.6839
Positionbefore -0.2943
Perturbationfeu:Positionbefore 0.1358
Perturbationtbe:Positionbefore -0.6262
Std. Error
(Intercept) 0.1430
Perturbationfeu 0.2572
Perturbationtbe 0.1311
Positionbefore 0.1538
Perturbationfeu:Positionbefore 0.3904
Perturbationtbe:Positionbefore 0.1853
df t value
(Intercept) 28.0400 29.142
Perturbationfeu 403.5518 -0.517
Perturbationtbe 447.0988 12.840
Positionbefore 428.9644 -1.913
Perturbationfeu:Positionbefore 379.3226 0.348
Perturbationtbe:Positionbefore 435.4795 -3.380
Pr(>|t|)
(Intercept) < 2e-16 ***
Perturbationfeu 0.60516
Perturbationtbe < 2e-16 ***
Positionbefore 0.05637 .
Perturbationfeu:Positionbefore 0.72804
Perturbationtbe:Positionbefore 0.00079 ***
---
Signif. codes:
0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Correlation of Fixed Effects:
(Intr) Prtrbtnf Prtrbtnt Pstnbf
Perturbatnf -0.301
Perturbtntb -0.644 0.350
Positionbfr -0.483 0.332 0.532
Prtrbtnf:Ps 0.188 -0.587 -0.204 -0.398
Prtrbtntb:P 0.415 -0.299 -0.658 -0.832
Prtrbtnf:P
Perturbatnf
Perturbtntb
Positionbfr
Prtrbtnf:Ps
Prtrbtntb:P 0.335
anova(lmer_bai_log_ERR)
Type III Analysis of Variance Table with Satterthwaite's method
Sum Sq Mean Sq NumDF
Perturbation 175.922 87.961 2
Position 9.799 9.799 1
Perturbation:Position 11.725 5.863 2
DenDF F value Pr(>F)
Perturbation 439.37 104.2228 < 2.2e-16
Position 376.82 11.6107 0.0007265
Perturbation:Position 400.48 6.9464 0.0010823
Perturbation ***
Position ***
Perturbation:Position **
---
Signif. codes:
0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Extraire les résidus et valeurs prédites
model_log_ERR <- lmer_bai_log_ERR
df_log_ERR <- bai.final_10ans_2_ERR
df_log_ERR $residus <- residuals(model_log_ERR )
df_log_ERR $fitted <- fitted(model_log_ERR )
# Graphique de base
ggplot(df_log_ERR , 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