-
Notifications
You must be signed in to change notification settings - Fork 3
/
Github_EAI_script.Rmd
137 lines (104 loc) · 6.02 KB
/
Github_EAI_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
---
title: "Ecosystem Area Index"
author: "Jessica A. Rowland"
output:
html_document: default
pdf_document: default
---
## Index overview
The Ecosystem Area Index (EAI) measures trends in changes in ecosystem area towards ecosystem collapse. The EAI is the geometric mean of the proportion of ecosystem area remaining over a given timeframe relative to the initial area and an ecosystem-specific collapse threshold. It uses data on ecosystem area and an area-based collapse threshold as defined based on IUCN Red List of Ecosystems risk assessments.
This information sheet provides the code used to calculate 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. 116, e12680
## Set up functions
### Calculate the index
The function *calcEAI* selects the column in a dataframe listing the proportion of the ecosystem area lost over a given timeframe towards or away from the point where the ecosystem collapses, and 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.
- pct_change = proportion of the ecosystem area lost over a given timeframe towards ecosystem collapse.
- group1 = 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).
- group2 = the second factor (optional) you want to group the index by.
```{r calcEAI}
calcEAI <- function(eco_data, RLE_criteria, pct_change, group1, group2){
filter_data <- filter(eco_data, RLE_criteria != "NE" & RLE_criteria != "DD")
# Calculate percentage remaining
area_Pct <- mutate(filter_data, est_remain = (1 - filter_data[[pct_change]]))
# Calculate overall index score if missing group, or scores based on a classification if specified
if (missing(group1)) {
values <- group_by(area_Pct)
} else {
if (missing(group2)) {
values <- group_by(area_Pct, group1 = area_Pct[[group1]])
} else {
values <- group_by(area_Pct, group1 = area_Pct[[group1]],
group2 = area_Pct[[group2]])
}
}
# Calculate EAI scores (accounting for zeros) & quantiles
index_scores <- summarise(values, total_count = n(),
count_non_zeros = length(est_remain > 0), # sample size excluding zeros
EAI = ((exp(mean(log(est_remain[est_remain > 0])))) * (count_non_zeros/total_count)), # natural log, accounting for zeros
lower = quantile(est_remain, probs = 0.025),
upper = quantile(est_remain, probs = 0.975))
return(index_scores)
}
```
#### 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.
- recent_area_lost = proportion of the ecosystem area lost over the past 50 years.
- future_area_lost = proportion of the ecosystem area lost over the next 50 years (or any 50-year timeframe across the past, present and future).
- historical_area_lost = proportion of the ecosystem area lost since ~1750.
- criterion_A1 = risk category assigned based on the recent_area_lost.
- criterion_A2b = risk category assigned based on the future_area_lost.
- criterion_A3 = risk category assigned based on the historical_area_lost.
```{r example, message = FALSE}
# Load packages
library(dplyr)
# Load data
data <- read.csv("~/Desktop/Github_example_AmericanForests_EAI.csv") #fill in path to file
# View data
head(data)
```
Calculate the index for sub-criteria A1 (recent change over the past 50 years) using no groupings. 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 area remaining is greater than 0 km2.
- EAI = the Ecosystem Area 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 EAI overall}
# Calculate the index values
output <- calcEAI(data,
pct_change = "recent_area_lost",
RLE_criteria = "criterion_A1")
# View output
head(output)
```
Calculate the index using one grouping, in this case, by ecosystem type:
```{r EAI one group}
# Calculate the index values
output_one_grouping <- calcEAI(data,
pct_change = "recent_area_lost",
RLE_criteria = "criterion_A1",
group1 = "ecosystem")
# View output
head(output_one_grouping)
```
Calculate the index using two groupings where ecosystems are grouped by ecosystem type and country.
```{r EAI two groups}
# Calculate the index values
output_two_groupings <- calcEAI(data,
pct_change = "recent_area_lost",
RLE_criteria = "criterion_A1",
group1 = "ecosystem",
group2 = "country")
# View output
head(output_two_groupings)
```
## Author information
jessica.rowland674@gmail.com
http://jessrowlandresearch.wordpress.com