-
Notifications
You must be signed in to change notification settings - Fork 3
/
Github_EHI_script.Rmd
188 lines (145 loc) · 9.29 KB
/
Github_EHI_script.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
---
title: "Ecosystem Health Index"
author: "Jessica A. Rowland"
output: html_document
---
## Index overview
The Ecosystem Health Index (EHI) measures temporal changes in environmental conditions and biotic processes/interactions (hereafter collectively, ecological processes). The EHI uses relative severity of change in ecosystem-specific ecological variables and extent of the ecosystem affected to quantify transitions towards or away from ecosystem collapse. The index represents the geometric mean of the relative severity of decline. It uses data defined in IUCN Red List of Ecosystems risk assessments.
This information sheet provides the code used to calculate the the index and an example of each step.
**Reference:**
Rowland, J. A., Bland, L. M., Keith, D. A., Bignoli, D. J., Burgman, M., Etter, A., Ferrer-Paris, J. R., Miller, R. M. and Nicholson, E. (2020) Ecosystem indices to support global biodiversity conservation. Conservation Letters. e12680
## Set up functions
### Calculate the index
The function *calcEHI* selects the column in a dataframe listing the relative severity of degradation and the proportion of the ecosystem area affected by degradation for criteria C (environmental degradation) and criterion D (biotic disruption). Next, it combines the relative severity and extent values into a single value, selects the ecological variable between criteria C and D with the highest decline. The value of decline for the selected ecological variable is used to calculate the index, along with percentiles capturing the middle 95% of the data.
Parameters are:
- eco_data = dataframe.
- RLE_criteria = name of the column with the Red List of Ecosystems criterion of interest.
- severity = relative severity of degradation of an ecological variable towards collapse over a given timeframe towards.
- extent = proportion of the ecosystem area affected by degradation.
- group_1 = the factor (optional) you want to group the index by. Where not specified, an EAI will be calculated based on all ecosystems (output = single score).
- group_2 = the second factor (optional) you want to group the index by.
```{r calcEHI}
calcEHI <- function(eco_data, severity_C, extent_C, severity_D, extent_D, severity, extent, group_1, group_2, one_criteria){
# Calculate the proportion remaining where only one criteria was assessed
if (one_criteria == TRUE) {
funcPct <- mutate(eco_data,
est_intact = 1 - (eco_data[[severity]] * eco_data[[extent]]))
# Drop NA values
no_na_values <- drop_na(funcPct, est_intact)
# Calculate overall index score if missing group, or scores based on a classification if specified
if (missing(group_1)) {
values <- group_by(no_na_values)
} else if (missing(group_2)) {
values <- group_by(no_na_values, group_1 = no_na_values[[group_1]])
} else {
values <- group_by(no_na_values, group_1 = no_na_values[[group_1]],
group_2 = no_na_values[[group_2]])
}
# Calculate the proportion remaining where both criterion C and D were available
} else if(one_criteria == FALSE) {
# Calculate proportion remaining for criteria C and D
funcPct <- mutate(eco_data,
est_intact_C = 1 - (eco_data[[severity_C]] * eco_data[[extent_C]]),
est_intact_D = 1 - (eco_data[[severity_D]] * eco_data[[extent_D]]))
# Select lowest value for criteria C or D
final <- mutate(funcPct, est_intact = ifelse(is.na(est_intact_C), est_intact_D,
ifelse(is.na(est_intact_D), est_intact_C,
ifelse(est_intact_C <= est_intact_D, est_intact_C, est_intact_D))))
# Drop NA values
no_na_values <- drop_na(final, est_intact)
# Calculate overall index score if missing group, or scores based on a classification if specified
if (missing(group_1)) {
values <- group_by(no_na_values)
} else if (missing(group_2)) {
values <- group_by(no_na_values, group_1 = no_na_values[[group_1]])
} else {
values <- group_by(no_na_values, group_1 = no_na_values[[group_1]],
group_2 = no_na_values[[group_2]])
}
}
# Calculate index scores (accounting for zeros) and quantiles
index_scores <- summarise(values, total_count = n(),
count_non_zeros = length(est_intact > 0),
EHI = ((exp(mean(log(est_intact[est_intact > 0])))) * (count_non_zeros/total_count)),
lower = quantile(est_intact, probs = 0.025),
upper = quantile(est_intact, probs = 0.975))
}
```
#### Forests of the Americas example
An example dataset of the Red list of Ecosystem assessments of the forests across the Americas is available from github.The assessments are from the continental-scale RLE assessments of 136 temperate and tropical forests across 51 countries/territories in the Caribbean and Americas (Ferrer-Paris et al., 2018).
**Reference:**
Ferrer-Paris, J. R., Zager, I., Keith, D. A., Oliveira-Miranda, M. A., Rodríguez, J. P., Josse, C., … Barrow, E. (2018). An ecosystem risk assessment of temperate and tropical forests of the Americas with an outlook on future conservation strategies. Conservation Letters, 12. https://doi.org/10.1111/conl.12623
The columns in the dataframe are:
- ecosystem = type of ecosystem.
- country = country containing part of the ecosystem distribution.
- mean_severity_C2a = average relative severity of abiotic change across the ecosystem (as a proportion) predicted over the next 50 years.
- extent_C2a = extent of abiotic change across the ecosystem (as a proportion) predicted over the next 50 years. Because the relative severity is calculated as the mean, the extent is 1 (100% of the ecosystem area).
- mean_severity_D1 = average relative severity of biotic change across the ecosystem (as a proportion) over the past 50 years.
- extent_D1 = extent of biotic change across the ecosystem (as a proportion) over the past 50 years. Because the relative severity is calculated as the mean, the extent is 1 (100% of the ecosystem area).
- mean_severity_D2b = average relative severity of biotic change across the ecosystem (as a proportion) predicted over a 50-year period containing the past, present and future.
- extent_D2b = extent of biotic change across the ecosystem (as a proportion) predicted over a 50-year period containing the past, present and future. Because the relative severity is calculated as the mean, the extent is 1 (100% of the ecosystem area).
- mean_severity_D3 = average relative severity of biotic change across the ecosystem (as a proportion) since ~ 1750.
- extent_D3 = extent of biotic change across the ecosystem (as a proportion) since ~ 1750. Because the relative severity is calculated as the mean, the extent is 1 (100% of the ecosystem area).
```{r example, message = FALSE}
# Load packages
library(dplyr)
library(tidyr)
# Load data
data <- read.csv("~/Desktop/Github_example_AmericanForests_EHI.csv") #fill in path to file
# View data
head(data)
```
To calculate the index using no groupings where only one criteria (either criteria C or D) is available, include the parameter:
- one_criteria = TRUE
The output above shows:
- total_count = the total number of ecosystems included in the index.
- count_non_zeros = the total number of ecosystems where the relative severity is greater than zero.
- EHI = the Ecosystem Health Index.
- lower and upper = the intervals are based on the quantiles aiming to capture the middle 95% of the data calcualted using the 2.5th and 97.5th percentiles.
```{r EHI one criteria}
# Calculate the index values
output_one <- calcEHI(data,
one_criteria = TRUE,
extent = "extent_C2a",
severity = "mean_severity_C2a")
# View output
head(output_one)
```
To calculate the index using no groupings where both criteria C and D are available, use the following code:
```{r EHI two criteria}
# Calculate the index values
output_two <- calcEHI(data,
one_criteria = FALSE,
severity_C = "mean_severity_C2b",
extent_C = "extent_C2b",
severity_D = "mean_severity_D2b",
extent_D = "extent_D2b")
# View output
head(output_two)
```
Calculate the index using one grouping:
```{r EHI one group}
# Calculate the index values
output_one_grouping <- calcEHI(data,
one_criteria = TRUE,
severity = "mean_severity_D1",
extent = "extent_D1",
group_1 = "ecosystem")
# View output
head(output_one_grouping)
```
Calculate the index using one grouping:
```{r EHI two groups}
# Calculate the index values
output_two_groupings <- calcEHI(data,
one_criteria = TRUE,
severity = "mean_severity_D1",
extent = "extent_D1",
group_1 = "ecosystem",
group_2 = "country")
# View output
head(output_two_groupings)
```
## Author information
jessica.rowland674@gmail.com
http://jessrowlandresearch.wordpress.com