Skip to content

Commit

Permalink
Updated R scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
JetteReeg committed Feb 17, 2022
1 parent 0695cdf commit b81867a
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
45 changes: 45 additions & 0 deletions Reeg_et_al_2021/Scripts/(2) Final_figures_without_Fig3.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
33 changes: 33 additions & 0 deletions Reeg_et_al_2021/Scripts/(8) Figures_local_sensitivity_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b81867a

Please sign in to comment.