From b81867ad93c11fd5c428ac72be785fe74f9c852a Mon Sep 17 00:00:00 2001 From: Jette Reeg Date: Thu, 17 Feb 2022 16:16:05 +0100 Subject: [PATCH] Updated R scripts --- .../Scripts/(2) Final_figures_without_Fig3.R | 45 +++++++++++++++++++ .../(8) Figures_local_sensitivity_analysis.R | 33 ++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/Reeg_et_al_2021/Scripts/(2) Final_figures_without_Fig3.R b/Reeg_et_al_2021/Scripts/(2) Final_figures_without_Fig3.R index 48fdc11..aca29bb 100644 --- a/Reeg_et_al_2021/Scripts/(2) Final_figures_without_Fig3.R +++ b/Reeg_et_al_2021/Scripts/(2) Final_figures_without_Fig3.R @@ -403,3 +403,48 @@ dev.off() # This figure was generated within the BiTZ SA R-project (file "(2) Figures") # ##### + +##### +# +# Statistical analyses of quasi extinction risk +# using an ANOVA +# +##### + +extinction_risk$TZ<-factor(extinction_risk$TZ) +extinction_risk$Cluster<-factor(extinction_risk$Cluster) + +# summary(extinction_risk) + +two.way <- aov(ext.prob ~ TZ + Cluster, data = extinction_risk) +kruskal1 <- kruskal.test(ext.prob ~ TZ, data = extinction_risk[Cluster==1]) +kruskal2 <- kruskal.test(ext.prob ~ TZ, data = extinction_risk[Cluster==2]) +kruskal3 <- kruskal.test(ext.prob ~ TZ, data = extinction_risk[Cluster==3]) +kruskal4 <- kruskal.test(ext.prob ~ TZ, data = extinction_risk[Cluster==4]) + +Cl1 <- extinction_risk[Cluster==1] +pairwise.wilcox.test(Cl1$ext.prob, Cl1$TZ, + p.adjust.method = "BH") + +one.way <- aov(ext.prob ~ TZ, data = extinction_risk[Cluster==1]) + +# multiple linear regression +model <- lm(ext.prob~TZ+Cluster,data=extinction_risk) +summary(model) + +hist(rstandard(model)) +hist(residuals(model)) +qqnorm(rstandard(model)) +qqline(rstandard(model)) +shapiro.test(rstandard(model)) + + +#1 +plot(model, 1) + +#2 +plot(fitted.values(model), rstandard(model)) + +par(mfrow=c(2,2)) +plot(two.way) +par(mfrow=c(1,1)) diff --git a/Reeg_et_al_2021/Scripts/(8) Figures_local_sensitivity_analysis.R b/Reeg_et_al_2021/Scripts/(8) Figures_local_sensitivity_analysis.R index 465239c..ffad04b 100644 --- a/Reeg_et_al_2021/Scripts/(8) Figures_local_sensitivity_analysis.R +++ b/Reeg_et_al_2021/Scripts/(8) Figures_local_sensitivity_analysis.R @@ -106,6 +106,39 @@ Landscape_mean$Parameter <- factor(Landscape_mean$Parameter, 'disturbance_eff', 'trans_effect_nest', 'trans_effect_res', 'trans_effect_nest_res')) +# Rename +Landscape_mean[Parameter=="weather_std"]$Parameter <- "standard deviation \n weather" +Landscape_mean[Parameter=="disturbance_prob"]$Parameter <- "disturbance \n probability" +Landscape_mean[Parameter=="dispersal_tries"]$Parameter <- "dispersal \n tries" +Landscape_mean[Parameter=="competition_strength"]$Parameter <- "competition \n strength" +Landscape_mean[Parameter=="growth_rate"]$Parameter <- "growth rate" +Landscape_mean[Parameter=="nest_suitability"]$Parameter <- "nesting site \n suitability" +Landscape_mean[Parameter=="res_suitability"]$Parameter <- "resource \n suitability" +Landscape_mean[Parameter=="dispersal_mean"]$Parameter <- "mean dispersal" +Landscape_mean[Parameter=="dispersal_sd"]$Parameter <- "standard deviation \n dispersal" +Landscape_mean[Parameter=="emigration_mu"]$Parameter <- "emigration \n parameter mu" +Landscape_mean[Parameter=="emigration_omega"]$Parameter <- "emigration \n parameter omega" +Landscape_mean[Parameter=="disturbance_eff"]$Parameter <- "disturbance \n effect" +Landscape_mean[Parameter=="trans_effect_nest"]$Parameter <- "effect of ABZs \n on nesting site" +Landscape_mean[Parameter=="trans_effect_res"]$Parameter <- "effect of ABZs \n on resources" +Landscape_mean[Parameter=="trans_effect_nest_res"]$Parameter <- "effect of ABZs \n on nesting site \n and resources" + +Landscape_Shannon_all[Parameter=="weather_std"]$Parameter <- "standard deviation \n weather" +Landscape_Shannon_all[Parameter=="disturbance_prob"]$Parameter <- "disturbance \n probability" +Landscape_Shannon_all[Parameter=="dispersal_tries"]$Parameter <- "dispersal \n tries" +Landscape_Shannon_all[Parameter=="competition_strength"]$Parameter <- "competition \n strength" +Landscape_Shannon_all[Parameter=="growth_rate"]$Parameter <- "growth rate" +Landscape_Shannon_all[Parameter=="nest_suitability"]$Parameter <- "nesting site \n suitability" +Landscape_Shannon_all[Parameter=="res_suitability"]$Parameter <- "resource \n suitability" +Landscape_Shannon_all[Parameter=="dispersal_Shannon_all"]$Parameter <- "mean dispersal" +Landscape_Shannon_all[Parameter=="dispersal_sd"]$Parameter <- "standard deviation \n dispersal" +Landscape_Shannon_all[Parameter=="emigration_mu"]$Parameter <- "emigration \n parameter mu" +Landscape_Shannon_all[Parameter=="emigration_omega"]$Parameter <- "emigration \n parameter omega" +Landscape_Shannon_all[Parameter=="disturbance_eff"]$Parameter <- "disturbance \n effect" +Landscape_Shannon_all[Parameter=="trans_effect_nest"]$Parameter <- "effect of ABZs \n on nesting site" +Landscape_Shannon_all[Parameter=="trans_effect_res"]$Parameter <- "effect of ABZs \n on resources" +Landscape_Shannon_all[Parameter=="trans_effect_nest_res"]$Parameter <- "effect of ABZs \n on nesting site \n and resources" + ##### # Figure F.3