Analysis of population and range change in European mammals from Article 17 data

Explore population trends and distribution changes of the Wildlife Comeback in Europe Report species that have records within the Article 17 data.

mammals_list = c(
"Megaptera_novaeangliae",
#"Caretta_caretta", ##Loggerheads
"Pusa_hispida",
"Lutra_lutra",
"Meles_meles",
"Martes_martes",
"Myotis_daubentonii",
"Myotis_nattereri",
"Myotis_emarginatus",
"Alces_alces",
"Bison_bonasus",
"Canis_aureus",
"Canis_lupus",
"Capra_ibex",
"Capra_pyrenaica",
"Capreolus_capreolus",
"Castor_fiber",
"Cervus_elaphus",
"Gulo_gulo",
"Halichoerus_grypus",
"Lynx_lynx",
"Lynx_pardinus",
"Phoca_vitulina",
"Rupicapra_pyrenaica",
"Rupicapra_rupicapra",
"Sus_scrofa",
"Ursus_arctos")

mammals_list = gsub("_", " ", mammals_list)

List of mammals for analysis

mammals_list
##  [1] "Megaptera novaeangliae" "Pusa hispida"           "Lutra lutra"           
##  [4] "Meles meles"            "Martes martes"          "Myotis daubentonii"    
##  [7] "Myotis nattereri"       "Myotis emarginatus"     "Alces alces"           
## [10] "Bison bonasus"          "Canis aureus"           "Canis lupus"           
## [13] "Capra ibex"             "Capra pyrenaica"        "Capreolus capreolus"   
## [16] "Castor fiber"           "Cervus elaphus"         "Gulo gulo"             
## [19] "Halichoerus grypus"     "Lynx lynx"              "Lynx pardinus"         
## [22] "Phoca vitulina"         "Rupicapra pyrenaica"    "Rupicapra rupicapra"   
## [25] "Sus scrofa"             "Ursus arctos"

How many do we match in article 17 data?

#### *** 2020 species data
#mammal_species <- fread("Article17_2020_dataset/Article17_2020_speciesEUassessment.csv", na.strings = 'NULL')
mammal_species <- fread("Article17_2020_dataset/Article17_2020_data_species_regions.csv", na.strings = 'NULL')
#write.csv(bird_species,"bird_species_check.csv")

#intersect(mammal_species$assessment_speciesname, mammals_list)
intersect(mammal_species$speciesname, mammals_list)
##  [1] "Myotis daubentonii"     "Myotis emarginatus"     "Myotis nattereri"      
##  [4] "Castor fiber"           "Canis lupus"            "Canis aureus"          
##  [7] "Ursus arctos"           "Lutra lutra"            "Martes martes"         
## [10] "Lynx lynx"              "Rupicapra rupicapra"    "Capra ibex"            
## [13] "Halichoerus grypus"     "Phoca vitulina"         "Bison bonasus"         
## [16] "Megaptera novaeangliae" "Lynx pardinus"          "Capra pyrenaica"       
## [19] "Rupicapra pyrenaica"    "Gulo gulo"              "Pusa hispida"
setdiff(mammals_list, mammal_species$speciesname)
## [1] "Meles meles"         "Alces alces"         "Capreolus capreolus"
## [4] "Cervus elaphus"      "Sus scrofa"
## 21 of 26 match****
#Meles meles
#Sus scrofa
#Alces alces
#Capreolus capreolus
#Cervus elaphus

## I think these are missing as they're not Article 17 species (check?)

# Restrict to those in list
# **
# ** Need to check matches as losing some
# **
mammal_species_short <- mammal_species[mammal_species$speciesname %in% mammals_list, ]

#names(bird_species_short)[names(bird_species_short) == "ï..specieshash"] <- "specieshash"

# Get the species codes (unique for each species)
speciescode <- unique(mammal_species$speciescode)

Which species have population trend data available?

# Population trend vs species 
table(mammal_species_short$speciesname, mammal_species_short$population_trend)
##                         
##                              D  I  S  U Unk
##   Bison bonasus           2  0  3  0  0   1
##   Canis aureus            0  0 11  4  0   5
##   Canis lupus             5  1 23 13  2   1
##   Capra ibex              2  1  3  1  0   0
##   Capra pyrenaica         0  0  6  0  0   0
##   Castor fiber            0  1 31  4  0   0
##   Gulo gulo               0  0  3  1  0   0
##   Halichoerus grypus      1  0 13  2  1   2
##   Lutra lutra             1  0 25 21  1   6
##   Lynx lynx               2  4  5 13  1   8
##   Lynx pardinus           0  0  2  0  0   0
##   Martes martes           0  0  8 22  3  20
##   Megaptera novaeangliae  2  0  0  0  1  10
##   Myotis daubentonii      0  4  4 24  7  11
##   Myotis emarginatus      1  5 12 16  1   7
##   Myotis nattereri        0  0  9 18  9  14
##   Phoca vitulina          1  0  9  1  1   3
##   Pusa hispida            1  0  0  0  0   1
##   Rupicapra pyrenaica     0  0  3  3  0   0
##   Rupicapra rupicapra     3  0  1 10  0   3
##   Ursus arctos            0  3 12 10  1   0

Which species have long-term population trend data available?

# Population trend vs species 
table(mammal_species_short$speciesname, mammal_species_short$population_trend_long)
##                         
##                              D  I  S  U Unk
##   Bison bonasus           4  0  2  0  0   0
##   Canis aureus           16  0  3  1  0   0
##   Canis lupus            32  1  9  2  1   0
##   Capra ibex              4  0  3  0  0   0
##   Capra pyrenaica         4  0  2  0  0   0
##   Castor fiber           21  0 15  0  0   0
##   Gulo gulo               4  0  0  0  0   0
##   Halichoerus grypus     12  0  7  0  0   0
##   Lutra lutra            36  1 16  1  0   0
##   Lynx lynx              29  1  1  2  0   0
##   Lynx pardinus           1  0  1  0  0   0
##   Martes martes          40  0  6  6  0   1
##   Megaptera novaeangliae  9  0  0  0  0   4
##   Myotis daubentonii     32  1  0  7  2   8
##   Myotis emarginatus     30  2  6  1  0   3
##   Myotis nattereri       35  1  4  5  0   5
##   Phoca vitulina          8  0  6  0  1   0
##   Pusa hispida            2  0  0  0  0   0
##   Rupicapra pyrenaica     2  0  2  2  0   0
##   Rupicapra rupicapra    13  0  3  1  0   0
##   Ursus arctos           19  0  6  1  0   0

Which species have regional range change data available?

# Population trend vs species 
table(mammal_species_short$speciesname, mammal_species_short$range_trend)
##                         
##                              D  I  S  U Unk
##   Bison bonasus           0  0  3  0  0   3
##   Canis aureus            0  0 14  4  0   2
##   Canis lupus             4  0 23 15  2   1
##   Capra ibex              2  0  1  4  0   0
##   Capra pyrenaica         0  0  2  4  0   0
##   Castor fiber            0  0 32  4  0   0
##   Gulo gulo               0  0  2  2  0   0
##   Halichoerus grypus      3  0  1 15  0   0
##   Lutra lutra             1  0 25 25  0   3
##   Lynx lynx               2  3  6 15  2   5
##   Lynx pardinus           0  0  2  0  0   0
##   Martes martes           0  0  8 37  0   8
##   Megaptera novaeangliae  4  0  0  2  0   7
##   Myotis daubentonii      0  0  3 42  0   5
##   Myotis emarginatus      1  1  2 32  0   6
##   Myotis nattereri        0  1  4 36  3   6
##   Phoca vitulina          2  0  3  9  0   1
##   Pusa hispida            2  0  0  0  0   0
##   Rupicapra pyrenaica     0  0  2  4  0   0
##   Rupicapra rupicapra     3  0  1 12  0   1
##   Ursus arctos            0  2 10 14  0   0

Which species have regional long-term range change data available?

# Population trend vs species 
table(mammal_species_short$speciesname, mammal_species_short$range_trend_long)
##                         
##                              D  I  S  U Unk
##   Bison bonasus           4  0  2  0  0   0
##   Canis aureus           16  0  4  0  0   0
##   Canis lupus            30  0 11  3  0   1
##   Capra ibex              4  0  1  2  0   0
##   Capra pyrenaica         3  0  2  1  0   0
##   Castor fiber           21  0 15  0  0   0
##   Gulo gulo               3  0  1  0  0   0
##   Halichoerus grypus     14  0  3  1  1   0
##   Lutra lutra            35  1 16  2  0   0
##   Lynx lynx              28  1  2  2  0   0
##   Lynx pardinus           1  0  1  0  0   0
##   Martes martes          40  0  4  9  0   0
##   Megaptera novaeangliae  7  0  0  0  1   5
##   Myotis daubentonii     34  0  0 12  0   4
##   Myotis emarginatus     29  1  4  3  0   5
##   Myotis nattereri       37  0  2  7  0   4
##   Phoca vitulina         10  0  1  3  1   0
##   Pusa hispida            2  0  0  0  0   0
##   Rupicapra pyrenaica     3  0  1  2  0   0
##   Rupicapra rupicapra    12  0  2  3  0   0
##   Ursus arctos           19  1  5  1  0   0

Which species have regional habitat change data available?

# Population trend vs species 
table(mammal_species_short$speciesname, mammal_species_short$habitat_trend)
##                         
##                              D  I  S  U Unk
##   Bison bonasus           0  0  1  4  0   1
##   Canis aureus            2  0  6 12  0   0
##   Canis lupus             8  1 10 26  0   0
##   Capra ibex              2  0  0  5  0   0
##   Capra pyrenaica         0  0  0  6  0   0
##   Castor fiber            0  0 14 20  1   1
##   Gulo gulo               0  0  0  4  0   0
##   Halichoerus grypus      2  0  0 13  1   3
##   Lutra lutra             1  1  4 41  1   6
##   Lynx lynx               2  1  1 19  1   9
##   Lynx pardinus           0  0  0  1  1   0
##   Martes martes           0  1  2 29  5  16
##   Megaptera novaeangliae  4  0  0  1  0   8
##   Myotis daubentonii      0  5  0 29  0  16
##   Myotis emarginatus      1 12  0 20  1   8
##   Myotis nattereri        0  2  2 29  3  14
##   Phoca vitulina          2  0  1  8  0   4
##   Pusa hispida            1  0  0  0  0   1
##   Rupicapra pyrenaica     0  0  0  3  0   3
##   Rupicapra rupicapra     3  0  0  8  0   6
##   Ursus arctos            1  0  2 22  0   1

Which species have regional long-term habitat change data available?

# Population trend vs species 
table(mammal_species_short$speciesname, mammal_species_short$habitat_trend_long)
##                         
##                              D  I  S  U Unk
##   Bison bonasus           4  0  1  1  0   0
##   Canis aureus           18  0  0  2  0   0
##   Canis lupus            35  0  4  6  0   0
##   Capra ibex              5  0  0  1  1   0
##   Capra pyrenaica         3  1  2  0  0   0
##   Castor fiber           26  0  2  4  0   4
##   Gulo gulo               4  0  0  0  0   0
##   Halichoerus grypus     15  0  0  3  1   0
##   Lutra lutra            39  1  6  6  1   1
##   Lynx lynx              30  0  1  2  0   0
##   Lynx pardinus           2  0  0  0  0   0
##   Martes martes          41  0  3  9  0   0
##   Megaptera novaeangliae  9  0  0  0  1   3
##   Myotis daubentonii     34  1  0  8  1   6
##   Myotis emarginatus     32  3  0  4  0   3
##   Myotis nattereri       38  1  0  5  0   6
##   Phoca vitulina          8  0  1  5  1   0
##   Pusa hispida            2  0  0  0  0   0
##   Rupicapra pyrenaica     3  0  0  2  0   1
##   Rupicapra rupicapra    13  0  1  0  0   3
##   Ursus arctos           19  0  0  6  0   1

##Threat information

Extract and count the number of threats for each species in each country

# Threats info

#### Threats
mammal_threats <- fread("Article17_2020_dataset/Article17_2020_data_pressures_threats.csv")
mammal_threats = subset(mammal_threats, featuretype == "species")
mammal_threats$featurecode = as.numeric(mammal_threats$featurecode) # Some habitat codes become NA if we do this first

# Subset threats for species we care about
mammal_threats = mammal_threats[mammal_threats$featurecode %in% speciescode, ]


# Filter out 'no-pressure' codes 
mammal_threats = subset(mammal_threats, pressurecode != "Xxt") # Get rid of Xxt

# Get rid of all of those starting with 'X'??
mammal_threats = subset(mammal_threats, !startsWith(mammal_threats$pressurecode, "X"))
mammal_threats = subset(mammal_threats, !is.na(mammal_threats$pressurecode))

mammal_threats_both = mammal_threats %>% 
  group_by(country, region, featurename, featurecode, type) %>% 
  summarise(
    n = n_distinct(pressurecode),
    n_hl = n_distinct(substring(pressurecode, 1, 1)) #n unique codes using only first character
  )
## `summarise()` has grouped output by 'country', 'region', 'featurename', 'featurecode'. You can override using the `.groups` argument.
# Convert this new data to four columns (n_t, n_p, n_hl_t, n_hl_p)
mammal_threats_n = tidyr::pivot_wider(mammal_threats_both, 
                                      id_cols = country:featurecode, 
                                      names_from="type", 
                                      values_from = c("n", "n_hl"),
                                      values_fill = 0) # Fill missing counts with 0

# Give them better names
mammal_threats_n = rename(mammal_threats_n, 
                        n_threat = n_t, 
                        n_pressure = n_p,
                        n_hl_threat = n_hl_t,
                        n_hl_pressure = n_hl_p)


mammal_threats_n
## # A tibble: 7,311 x 8
## # Groups:   country, region, featurename, featurecode [7,311]
##    country region featurename      featurecode n_pressure n_threat n_hl_pressure
##    <chr>   <chr>  <chr>                  <dbl>      <int>    <int>         <int>
##  1 AT      ALP    Acipenser ruthe…        2487          2        2             2
##  2 AT      ALP    Adenophora lili…        4068          6        6             5
##  3 AT      ALP    Alburnus mento          5289          4        4             3
##  4 AT      ALP    Anisus vorticul…        4056          3        4             3
##  5 AT      ALP    Apium repens            1614          2        2             1
##  6 AT      ALP    Aquilegia alpina        1480          2        2             2
##  7 AT      ALP    Arnica montana          1762          6        6             4
##  8 AT      ALP    Artemisia genipi        1764          2        2             2
##  9 AT      ALP    Aspius aspius           1130          2        2             2
## 10 AT      ALP    Asplenium adult…        4066          3        3             3
## # … with 7,301 more rows, and 1 more variable: n_hl_threat <int>
# Couple of quick plots to look at relationship between n_threat and n_hl_threat 
ggplot(mammal_threats_n, aes(x = n_threat, y = n_hl_threat)) + 
  geom_point(alpha = 0.05, size = 5) + 
  ggtitle("Number of unique threats vs. number of unique 'high-level' threats") + 
  xlab("Number of unique threats") + 
  ylab("Number of unique high-level threats") + 
  ggpubr::theme_classic2()
## Registered S3 methods overwritten by 'car':
##   method                          from
##   influence.merMod                lme4
##   cooks.distance.influence.merMod lme4
##   dfbeta.influence.merMod         lme4
##   dfbetas.influence.merMod        lme4

ggplot(mammal_threats_n, aes(x = n_pressure, y = n_hl_pressure)) + 
  geom_point(alpha = 0.05, size = 5) + 
  ggtitle("Number of unique pressures vs. number of unique 'high-level' pressures") + 
  xlab("Number of unique pressures") + 
  ylab("Number of unique high-level pressures") + 
  ggpubr::theme_classic2()

# Measures
mammal_measures <- fread("Article17_2020_dataset/Article17_2020_data_measures.csv", na.strings = 'NULL')
mammal_measures$featurecode = as.numeric(mammal_measures$featurecode) # Some habitat codes become NA
## Warning: NAs introduced by coercion
# Subset measures for species we care about
mammal_measures <- mammal_measures[mammal_measures$featurecode %in% speciescode, ]
mammal_measures = subset(mammal_measures, featuretype == "species")


# ** Do we need to filter out 'no-measure' codes? 
#mammal_threats = subset(mammal_threats, measurecode != "Xxt") ?

mammal_measures_n = mammal_measures %>% 
  group_by(country, region, featurename, featurecode) %>% 
  summarise(
    n_measure = n_distinct(measurecode),
    n_hl_measure = n_distinct(substring(measurecode, 1, 2)) #n unique codes using only first character
  ) 
## `summarise()` has grouped output by 'country', 'region', 'featurename'. You can override using the `.groups` argument.
mammal_measures_n
## # A tibble: 4,671 x 6
## # Groups:   country, region, featurename [4,671]
##    country region featurename                 featurecode n_measure n_hl_measure
##    <chr>   <chr>  <chr>                             <dbl>     <int>        <int>
##  1 AT      ALP    Adenophora lilifolia               4068         1            1
##  2 AT      ALP    Alburnus mento                     5289         2            2
##  3 AT      ALP    Anisus vorticulus                  4056         1            1
##  4 AT      ALP    Apium repens                       1614         1            1
##  5 AT      ALP    Aspius aspius                      1130         2            2
##  6 AT      ALP    Astacus astacus                    1091         7            5
##  7 AT      ALP    Austropotamobius pallipes          1092         1            1
##  8 AT      ALP    Austropotamobius torrentium        1093         6            4
##  9 AT      ALP    Barbastella barbastellus           1308         2            1
## 10 AT      ALP    Barbus barbus                      5085         3            3
## # … with 4,661 more rows
# Couple of quick plots to look at relationship between n_threat and n_hl_threat 
ggplot(mammal_measures_n, aes(x = n_measure, y = n_hl_measure)) + 
  geom_point(alpha = 0.05, size = 5) + 
  ggtitle("Number of unique measures vs. number of unique 'high-level' measures (mammals)") + 
  xlab("Number of unique threats") + 
  ylab("Number of unique high-level threats") + 
  ggpubr::theme_classic2()

##Combine data

# Trend data - get columns from bird species table that we want to use
mammal_trend_data = mammal_species_short %>% select(country, region, speciescode, speciesname,
                                                  population_trend,
                                                  population_trend_long,
                                                  range_trend,
                                                  range_trend_long,
                                                  habitat_trend,
                                                  habitat_trend_long)

mammal_trend_data = rename(mammal_trend_data, 
                        featurecode = speciescode, 
                        featurename = speciesname)

# All together now!
# Combined measure data with threat data
full_dataB = merge(mammal_trend_data, mammal_threats_n, by = c('region', 'country', 'featurename', 'featurecode'), all.x =TRUE)
# Combine those with trend data
full_data = merge(full_dataB, mammal_measures_n, by=c('region', 'country', 'featurename', 'featurecode'), all.x =TRUE)

How many species do we end up with?

length(unique(full_data$featurename))
## [1] 21

How many country records (threats/measures) do we have for each species?

table(full_data$featurename)
## 
##          Bison bonasus           Canis aureus            Canis lupus 
##                      6                     20                     45 
##             Capra ibex        Capra pyrenaica           Castor fiber 
##                      7                      6                     36 
##              Gulo gulo     Halichoerus grypus            Lutra lutra 
##                      4                     19                     54 
##              Lynx lynx          Lynx pardinus          Martes martes 
##                     33                      2                     53 
## Megaptera novaeangliae     Myotis daubentonii     Myotis emarginatus 
##                     13                     50                     42 
##       Myotis nattereri         Phoca vitulina           Pusa hispida 
##                     50                     15                      2 
##    Rupicapra pyrenaica    Rupicapra rupicapra           Ursus arctos 
##                      6                     17                     26

Combine countries to regions

Population/habitat change data is given per regions, so aggregate n_threat/n_measure to region

# Average threats over countries to regions as that's where we have response data
# model_data = full_data %>%
#   group_by(region, featurename, featurecode, population_trend, habitat_trend) %>% 
#   summarise(
#     mean_n_pressure = mean(n_pressure),
#     mean_n_threat = mean(n_threat),
#     mean_n_hl_pressure = mean(n_hl_pressure),
#     mean_n_hl_threat = mean(n_hl_threat),
#     mean_n_measure = mean(n_measure),
#     mean_n_hl_measure = mean(n_hl_measure),
#   )
model_data = full_data

How many species are there per region?

# How many do we have
addmargins(table(model_data$featurename, model_data$region))
##                         
##                          ALP ATL BLS BOR CON MATL MBAL MED MMAC MMED PAN STE
##   Bison bonasus            3   0   0   0   3    0    0   0    0    0   0   0
##   Canis aureus             5   0   2   0   7    0    0   2    0    0   3   1
##   Canis lupus             12   6   1   5  13    0    0   6    0    0   2   0
##   Capra ibex               5   0   0   0   1    0    0   1    0    0   0   0
##   Capra pyrenaica          2   2   0   0   0    0    0   2    0    0   0   0
##   Castor fiber             7   6   0   5  11    0    0   2    0    0   4   1
##   Gulo gulo                2   0   0   2   0    0    0   0    0    0   0   0
##   Halichoerus grypus       0   0   0   0   0   10    8   0    1    0   0   0
##   Lutra lutra             13   9   2   5  14    0    0   6    0    0   4   1
##   Lynx lynx               11   1   1   5  10    0    0   3    0    0   2   0
##   Lynx pardinus            0   0   0   0   0    0    0   2    0    0   0   0
##   Martes martes           13   9   1   5  14    0    0   6    0    0   4   1
##   Megaptera novaeangliae   0   0   0   0   0    6    0   0    2    5   0   0
##   Myotis daubentonii      11   9   1   5  14    0    0   6    0    0   3   1
##   Myotis emarginatus      11   7   1   0  12    0    0   7    0    0   3   1
##   Myotis nattereri        11   9   1   5  14    0    0   7    0    0   3   0
##   Phoca vitulina           0   0   0   0   0   10    4   0    1    0   0   0
##   Pusa hispida             0   0   0   0   0    2    0   0    0    0   0   0
##   Rupicapra pyrenaica      2   2   0   0   0    0    0   2    0    0   0   0
##   Rupicapra rupicapra      7   0   0   0   7    0    0   3    0    0   0   0
##   Ursus arctos            12   1   0   4   5    0    0   4    0    0   0   0
##   Sum                    127  61  10  41 125   28   12  59    4    5  28   6
##                         
##                          Sum
##   Bison bonasus            6
##   Canis aureus            20
##   Canis lupus             45
##   Capra ibex               7
##   Capra pyrenaica          6
##   Castor fiber            36
##   Gulo gulo                4
##   Halichoerus grypus      19
##   Lutra lutra             54
##   Lynx lynx               33
##   Lynx pardinus            2
##   Martes martes           53
##   Megaptera novaeangliae  13
##   Myotis daubentonii      50
##   Myotis emarginatus      42
##   Myotis nattereri        50
##   Phoca vitulina          15
##   Pusa hispida             2
##   Rupicapra pyrenaica      6
##   Rupicapra rupicapra     17
##   Ursus arctos            26
##   Sum                    506

First simple model.. do species appear to have more conservation measures in place when there are more threats reported?

model_data_measure = model_data %>%
  mutate(population_trend = factor(population_trend)) %>%
  filter(population_trend != "") %>%  # Subset to only increases or declines
  select(region, n_threat, n_measure, population_trend_long, featurename) %>% # Columns for modelling
  drop_na() %>% # Get rid of NAs in any of these columns
  droplevels()


#*** Including species ('featurename') as a random effect is tricky (throw singularities) as there's only a couple
# of records for some species. 
m1_measures_NULL = lmer(n_measure ~ (1|region), 
                        data = model_data_measure) 
m1_measuresA = lmer(n_measure ~ population_trend_long + n_threat + (1|region), 
                    data = model_data_measure) 
m1_measuresB = lmer(n_measure ~ population_trend_long * n_threat + (1|region), 
                    data = model_data_measure) 

# Adding 'country' throws singularities due to sparse data
#summary(m1_measures)
tab_model(m1_measures_NULL, m1_measuresA, m1_measuresB, show.aicc = TRUE)
  n_measure n_measure n_measure
Predictors Estimates CI p Estimates CI p Estimates CI p
(Intercept) 4.75 3.85 – 5.66 <0.001 1.93 1.01 – 2.85 <0.001 2.15 1.12 – 3.18 <0.001
population_trend_long [D] -0.36 -2.76 – 2.04 0.771 -3.81 -8.65 – 1.04 0.123
population_trend_long [I] -0.33 -1.05 – 0.38 0.361 -1.18 -2.80 – 0.44 0.154
population_trend_long [S] -0.41 -2.45 – 1.63 0.693 -1.93 -7.27 – 3.41 0.479
population_trend_long [U] -2.19 -5.58 – 1.19 0.204 2.39 -3.98 – 8.76 0.463
population_trend_long
[Unk]
-1.06 -2.46 – 0.33 0.136 -0.55 -3.36 – 2.27 0.705
n_threat 0.51 0.41 – 0.61 <0.001 0.47 0.35 – 0.60 <0.001
population_trend_long [D]
* n_threat
0.72 -0.17 – 1.60 0.112
population_trend_long [I]
* n_threat
0.14 -0.09 – 0.37 0.242
population_trend_long [S]
* n_threat
0.19 -0.40 – 0.78 0.524
population_trend_long [U]
* n_threat
-0.84 -1.81 – 0.13 0.089
population_trend_long
[Unk] * n_threat
-0.15 -0.74 – 0.44 0.616
Random Effects
σ2 7.83 5.76 5.69
τ00 1.74 region 0.74 region 0.73 region
ICC 0.18 0.11 0.11
N 12 region 12 region 12 region
Observations 265 265 265
Marginal R2 / Conditional R2 0.000 / 0.182 0.281 / 0.363 0.298 / 0.378
AIC 1319.712 1237.220 1243.374
compare_performance(m1_measures_NULL, m1_measuresA, m1_measuresB)
## # Comparison of Model Performance Indices
## 
## Name             |   Model |      AIC |      BIC | R2 (cond.) | R2 (marg.) |   ICC |  RMSE | Sigma
## --------------------------------------------------------------------------------------------------
## m1_measures_NULL | lmerMod | 1319.620 | 1330.359 |      0.182 |      0.000 | 0.182 | 2.755 | 2.799
## m1_measuresA     | lmerMod | 1236.514 | 1268.731 |      0.363 |      0.281 | 0.113 | 2.338 | 2.399
## m1_measuresB     | lmerMod | 1241.694 | 1291.811 |      0.378 |      0.298 | 0.113 | 2.303 | 2.386
# 
# library(rstanarm)
# sm1_measures_NULL = stan_glmer(n_hl_measure ~ (1|featurename), 
#                         data = model_data_measure, diagnostic_file = file.path(tempdir(), "df0.csv"))
# sm1_measuresA = stan_glmer(n_hl_measure ~ population_trend + n_threat + (1|featurename), 
#                     data = model_data_measure, diagnostic_file = file.path(tempdir(), "df1.csv"))
# sm1_measuresB = stan_glmer(n_hl_measure ~ population_trend * n_threat + (1|featurename), 
#                     data = model_data_measure, diagnostic_file = file.path(tempdir(), "df2.csv"))
# 
# 
# library(bridgesampling)
# bridge_0 <- bridge_sampler(sm1_measures_NULL)
# bridge_1 <- bridge_sampler(sm1_measuresA)
# bridge_2 <- bridge_sampler(sm1_measuresB)
# 
# bf(bridge_1, bridge_0)
# bf(bridge_2, bridge_1)
# 
# plot(sm1_measuresA)

In general, popualtions with more threats have significantly more measures, but this doesn’t appear to vary with the type of population trend (e.g. declines, increases, etc)

plot_model(m1_measuresA, show.intercept = TRUE)

tab_model(m1_measuresA) 
  n_measure
Predictors Estimates CI p
(Intercept) 1.93 1.01 – 2.85 <0.001
population_trend_long [D] -0.36 -2.76 – 2.04 0.771
population_trend_long [I] -0.33 -1.05 – 0.38 0.361
population_trend_long [S] -0.41 -2.45 – 1.63 0.693
population_trend_long [U] -2.19 -5.58 – 1.19 0.204
population_trend_long
[Unk]
-1.06 -2.46 – 0.33 0.136
n_threat 0.51 0.41 – 0.61 <0.001
Random Effects
σ2 5.76
τ00 region 0.74
ICC 0.11
N region 12
Observations 265
Marginal R2 / Conditional R2 0.281 / 0.363
plot_model(m1_measuresA, type = "pred")
## $population_trend_long

## 
## $n_threat

#plot_model(m1_measuresB, type = "pred", terms = c("mean_n_hl_threat", "population_trend")) # Hard to see significant effects on orediction plot because of broad CIs of D pops

Declines vs Threats/Measures

Are species more likely to be declining where there are more threats/measures?

# Model data is only declines or increases (remapped to 'increasing' as 0/1)
model_data_binom = model_data %>%
  ungroup() %>%
  mutate(population_trend = factor(population_trend)) %>%
  filter(population_trend == "D" | population_trend == "I" | population_trend == "S") %>%  # Subset to only increases or declines
  mutate(increasing = ifelse(population_trend == "I", 1, 0)) %>% # Response variable with be 'increasing' or otherwise 'decreasing'
  select(increasing, n_threat, n_pressure, n_measure, featurename) %>% # Columns for modelling
  drop_na() # Get rid of NAs in any of these columns


# Are populations more likely to be declining where there are more threats/measures
m1_NULL = glmer(increasing ~ (1|featurename), 
            data = model_data_binom, family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
# Are populations more likely to be declining where there are more threats/measures
m1_threat = glmer(increasing ~  scale(n_threat) + (1|featurename), 
            data = model_data_binom, family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m1_measure = glmer(increasing ~  scale(n_measure) + (1|featurename), 
            data = model_data_binom, family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m1_pressuee = glmer(increasing ~  scale(n_pressure) + (1|featurename), 
            data = model_data_binom, family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m1A = glmer(increasing ~  scale(n_threat) + scale(n_measure) + (1|featurename), 
            data = model_data_binom, family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m1B = glmer(increasing ~  scale(n_threat) * scale(n_measure) + (1|featurename), 
            data = model_data_binom, family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m1C = glmer(increasing ~  scale(n_pressure) + scale(n_measure) + (1|featurename), 
            data = model_data_binom, family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m1D = glmer(increasing ~  scale(n_pressure) * scale(n_measure) + (1|featurename), 
            data = model_data_binom, family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
# Adding 'country' throws singularities due to sparse data
#summary(m1)

tab_model(m1_NULL, m1_threat, m1_measure, m1A, m1B, m1C, m1D, show.aicc = TRUE)
  increasing increasing increasing increasing increasing increasing increasing
Predictors Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p
(Intercept) 1.49 0.63 – 3.53 0.368 1.48 0.62 – 3.52 0.372 1.45 0.61 – 3.48 0.401 1.51 0.62 – 3.69 0.367 1.44 0.58 – 3.58 0.437 1.50 0.62 – 3.67 0.370 1.47 0.59 – 3.65 0.412
n_threat 0.98 0.72 – 1.35 0.924 1.27 0.86 – 1.88 0.224 1.33 0.87 – 2.02 0.187
n_measure 0.74 0.54 – 1.01 0.058 0.65 0.44 – 0.95 0.026 0.62 0.41 – 0.94 0.024 0.65 0.44 – 0.95 0.028 0.63 0.41 – 0.97 0.037
n_threat * n_measure 1.10 0.77 – 1.56 0.609
n_pressure 1.27 0.85 – 1.89 0.242 1.30 0.84 – 2.02 0.243
n_pressure * n_measure 1.05 0.72 – 1.52 0.798
Random Effects
σ2 3.29 3.29 3.29 3.29 3.29 3.29 3.29
τ00 2.35 featurename 2.35 featurename 2.42 featurename 2.53 featurename 2.53 featurename 2.53 featurename 2.53 featurename
ICC 0.42 0.42 0.42 0.43 0.44 0.43 0.43
N 18 featurename 18 featurename 18 featurename 18 featurename 18 featurename 18 featurename 18 featurename
Observations 229 229 229 229 229 229 229
Marginal R2 / Conditional R2 0.000 / 0.417 0.000 / 0.417 0.016 / 0.432 0.022 / 0.447 0.023 / 0.448 0.021 / 0.447 0.021 / 0.447
AIC 286.813 288.858 285.269 285.878 287.712 285.980 288.006
compare_performance(m1_NULL, m1_threat, m1_measure, m1A, m1B, m1C, m1D)
## # Comparison of Model Performance Indices
## 
## Name       |    Model |     AIC |     BIC | R2 (cond.) | R2 (marg.) |   ICC |  RMSE | Sigma | Log_loss | Score_log | Score_spherical
## ------------------------------------------------------------------------------------------------------------------------------------
## m1_NULL    | glmerMod | 286.760 | 293.627 |      0.417 |      0.000 | 0.417 | 0.421 | 1.000 |    0.533 |  -112.100 |           0.007
## m1_threat  | glmerMod | 288.751 | 299.052 |      0.417 |  4.121e-05 | 0.417 | 0.421 | 1.000 |    0.533 |  -112.094 |           0.007
## m1_measure | glmerMod | 285.162 | 295.463 |      0.432 |      0.016 | 0.423 | 0.417 | 1.000 |    0.525 |  -114.024 |           0.005
## m1A        | glmerMod | 285.700 | 299.434 |      0.447 |      0.022 | 0.435 | 0.416 | 1.000 |    0.521 |  -115.115 |           0.009
## m1B        | glmerMod | 287.443 | 304.611 |      0.448 |      0.023 | 0.435 | 0.416 | 1.000 |    0.520 |  -115.248 |           0.008
## m1C        | glmerMod | 285.801 | 299.536 |      0.447 |      0.021 | 0.435 | 0.416 | 1.000 |    0.521 |  -114.987 |           0.009
## m1D        | glmerMod | 287.737 | 304.905 |      0.447 |      0.021 | 0.435 | 0.416 | 1.000 |    0.521 |  -114.986 |           0.009

No clear support for threats/measures helping predict increases - null model preferred

plot_model(m1_NULL, show.intercept = TRUE)

tab_model(m1_NULL) 
  increasing
Predictors Odds Ratios CI p
(Intercept) 1.49 0.63 – 3.53 0.368
Random Effects
σ2 3.29
τ00 featurename 2.35
ICC 0.42
N featurename 18
Observations 229
Marginal R2 / Conditional R2 0.000 / 0.417
plot_model(m1_NULL, type = "pred")
## list()

Long-term change

Are species more likely to be declining where there are more threats/measures?

# Model data is only declines or increases (remapped to 'increasing' as 0/1)
model_data_binom_long = model_data %>%
  ungroup() %>%
  mutate(population_trend_long = factor(population_trend_long)) %>%
  filter(population_trend_long == "D" | population_trend_long == "I") %>%  # Subset to only increases or declines
  mutate(increasing = ifelse(population_trend_long == "I", 1, 0)) %>% # Response variable with be 'increasing' or otherwise 'decreasing'
  select(increasing, n_threat, n_measure, n_pressure, featurename) %>% # Columns for modelling
  drop_na() # Get rid of NAs in any of these columns


# Are populations more likely to be declining where there are more threats/measures
m2_NULL = glmer(increasing ~ (1|featurename), 
            data = model_data_binom_long, family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
# Are populations more likely to be declining where there are more threats/measures
m2_threat = glmer(increasing ~  scale(n_threat) + (1|featurename), 
            data = model_data_binom_long, family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m2_measure = glmer(increasing ~  scale(n_measure) + (1|featurename), 
            data = model_data_binom_long, family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m2_pressure = glmer(increasing ~  scale(n_pressure) + (1|featurename), 
            data = model_data_binom_long, family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m2A = glmer(increasing ~  scale(n_threat) + scale(n_measure) + (1|featurename), 
            data = model_data_binom_long, family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m2B = glmer(increasing ~  scale(n_threat) * scale(n_measure) + (1|featurename), 
            data = model_data_binom_long, family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m2C = glmer(increasing ~  scale(n_pressure) + scale(n_measure) + (1|featurename), 
            data = model_data_binom_long, family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m2D = glmer(increasing ~  scale(n_pressure) * scale(n_measure) + (1|featurename), 
            data = model_data_binom_long, family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
# Adding 'country' throws singularities due to sparse data
#summary(m1)

tab_model(m2_NULL, m2_threat, m2_measure, m2A, m2B, m2C, m2D, show.aicc = TRUE)
  increasing increasing increasing increasing increasing increasing increasing
Predictors Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p
(Intercept) 21.10 3.21 – 138.50 0.001 22.38 3.49 – 143.50 0.001 20.89 3.28 – 132.99 0.001 24.14 3.25 – 179.63 0.002 36.44 2.98 – 445.10 0.005 22.72 3.24 – 159.31 0.002 26.54 2.34 – 300.99 0.008
n_threat 1.59 0.52 – 4.87 0.420 1.98 0.38 – 10.34 0.420 1.76 0.25 – 12.44 0.570
n_measure 1.15 0.38 – 3.47 0.803 0.73 0.15 – 3.56 0.701 0.80 0.12 – 5.26 0.819 0.92 0.22 – 3.90 0.909 1.00 0.19 – 5.12 0.996
n_threat * n_measure 0.60 0.15 – 2.38 0.466
n_pressure 1.45 0.33 – 6.43 0.621 1.33 0.24 – 7.36 0.742
n_pressure * n_measure 0.83 0.18 – 3.83 0.815
Random Effects
σ2 3.29 3.29 3.29 3.29 3.29 3.29 3.29
τ00 0.75 featurename 0.65 featurename 0.69 featurename 0.79 featurename 0.90 featurename 0.82 featurename 0.97 featurename
ICC 0.19 0.16 0.17 0.19 0.22 0.20 0.23
N 12 featurename 12 featurename 12 featurename 12 featurename 12 featurename 12 featurename 12 featurename
Observations 68 68 68 68 68 68 68
Marginal R2 / Conditional R2 0.000 / 0.186 0.051 / 0.207 0.005 / 0.177 0.068 / 0.250 0.112 / 0.303 0.026 / 0.221 0.028 / 0.249
AIC 34.449 35.969 36.576 38.078 39.842 38.575 40.851
compare_performance(m2_NULL, m2_threat, m2_measure, m2A, m2B, m2C, m2D)
## # Comparison of Model Performance Indices
## 
## Name       |    Model |    AIC |    BIC | R2 (cond.) | R2 (marg.) |   ICC |  RMSE | Sigma | Log_loss | Score_log | Score_spherical
## ----------------------------------------------------------------------------------------------------------------------------------
## m2_NULL    | glmerMod | 34.265 | 38.704 |      0.186 |      0.000 | 0.186 | 0.228 | 1.000 |    0.193 |  -189.585 |           0.036
## m2_threat  | glmerMod | 35.594 | 42.253 |      0.207 |      0.051 | 0.165 | 0.226 | 1.000 |    0.192 |  -193.490 |           0.015
## m2_measure | glmerMod | 36.201 | 42.860 |      0.177 |      0.005 | 0.173 | 0.227 | 1.000 |    0.195 |  -189.147 |           0.015
## m2A        | glmerMod | 37.443 | 46.321 |      0.250 |      0.068 | 0.194 | 0.225 | 1.000 |    0.186 |  -197.527 |           0.015
## m2B        | glmerMod | 38.875 | 49.972 |      0.303 |      0.112 | 0.215 | 0.223 | 1.000 |    0.180 |  -204.418 |           0.015
## m2C        | glmerMod | 37.940 | 46.818 |      0.221 |      0.026 | 0.200 | 0.226 | 1.000 |    0.189 |  -193.209 |           0.022
## m2D        | glmerMod | 39.884 | 50.981 |      0.249 |      0.028 | 0.227 | 0.225 | 1.000 |    0.185 |  -195.512 |           0.025

No clear support for threats/measures helping predict long-term increases - null model preferred

plot_model(m2_NULL, show.intercept = TRUE)

tab_model(m2_NULL) 
  increasing
Predictors Odds Ratios CI p
(Intercept) 21.10 3.21 – 138.50 0.001
Random Effects
σ2 3.29
τ00 featurename 0.75
ICC 0.19
N featurename 12
Observations 68
Marginal R2 / Conditional R2 0.000 / 0.186
plot_model(m2_NULL, type = "pred")
## list()

Range-change vs Threats/Measures

Are species ranges more likely to be shrinking where there are more threats/measures?

model_data_binom_range = model_data %>%
  ungroup() %>%
  mutate(range_trend = factor(range_trend)) %>%
  filter(range_trend == "D" | range_trend == "I" | range_trend == "S") %>%  # Subset to only increases or declines
  mutate(increasing = ifelse(range_trend == "I", 1, 0)) %>% # Response variable with be 'increasing' or otherwise 'decreasing'
  select(region,increasing, n_measure, n_threat, n_pressure, featurename) %>% # Columns for modelling
  drop_na() # Get rid of NAs in any of these columns


# Are species ranges more likely to be shrinking where there are more threats/measures
m1r_NULL = glmer(increasing ~ (1|featurename), 
            data = model_data_binom_range, 
            family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m1r_threat = glmer(increasing ~ scale(n_threat) + (1|featurename), 
            data = model_data_binom_range, 
            family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m1r_measure = glmer(increasing ~ scale(n_measure) + (1|featurename), 
            data = model_data_binom_range, 
            family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m1r_pressure = glmer(increasing ~ scale(n_pressure) + (1|featurename), 
            data = model_data_binom_range, 
            family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m1rA = glmer(increasing ~ scale(n_measure) + scale(n_threat) + (1|featurename), 
           data = model_data_binom_range, 
           family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m1rB = glmer(increasing ~ scale(n_measure) * scale(n_threat) + (1|featurename), 
          data = model_data_binom_range, 
          family = "binomial", control = glmerControl(optimizer = "bobyqa"))  
m1rC = glmer(increasing ~ scale(n_measure) + scale(n_pressure) + (1|featurename), 
           data = model_data_binom_range, 
           family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m1rD = glmer(increasing ~ scale(n_measure) * scale(n_pressure) + (1|featurename), 
          data = model_data_binom_range, 
          family = "binomial", control = glmerControl(optimizer = "bobyqa"))  

tab_model(m1r_NULL, m1r_threat, m1r_measure, m1rA, m1rB, m1rC, m1rD, show.aicc = TRUE)
  increasing increasing increasing increasing increasing increasing increasing
Predictors Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p
(Intercept) 0.39 0.17 – 0.91 0.029 0.40 0.17 – 0.92 0.031 0.39 0.17 – 0.91 0.029 0.39 0.17 – 0.92 0.032 0.36 0.15 – 0.85 0.020 0.39 0.17 – 0.91 0.030 0.35 0.15 – 0.84 0.018
n_threat 1.07 0.78 – 1.49 0.662 1.19 0.81 – 1.76 0.374 1.28 0.85 – 1.93 0.245
n_measure 0.92 0.67 – 1.26 0.589 0.83 0.57 – 1.22 0.346 0.77 0.51 – 1.16 0.214 0.86 0.59 – 1.26 0.444 0.78 0.51 – 1.20 0.258
n_measure * n_threat 1.20 0.84 – 1.72 0.321
n_pressure 1.12 0.75 – 1.67 0.569 1.23 0.80 – 1.91 0.348
n_measure * n_pressure 1.21 0.84 – 1.77 0.307
Random Effects
σ2 3.29 3.29 3.29 3.29 3.29 3.29 3.29
τ00 2.35 featurename 2.32 featurename 2.41 featurename 2.39 featurename 2.38 featurename 2.37 featurename 2.32 featurename
ICC 0.42 0.41 0.42 0.42 0.42 0.42 0.41
N 19 featurename 19 featurename 19 featurename 19 featurename 19 featurename 19 featurename 19 featurename
Observations 253 253 253 253 253 253 253
Marginal R2 / Conditional R2 0.000 / 0.417 0.001 / 0.414 0.001 / 0.424 0.005 / 0.424 0.009 / 0.425 0.003 / 0.420 0.007 / 0.418
AIC 280.443 282.305 282.206 283.503 284.624 283.958 285.019
compare_performance(m1r_NULL, m1r_threat, m1r_measure, m1rA, m1rB, m1rC, m1rD)
## # Comparison of Model Performance Indices
## 
## Name        |    Model |     AIC |     BIC | R2 (cond.) | R2 (marg.) |   ICC |  RMSE | Sigma | Log_loss | Score_log | Score_spherical
## -------------------------------------------------------------------------------------------------------------------------------------
## m1r_NULL    | glmerMod | 280.395 | 287.462 |      0.417 |      0.000 | 0.417 | 0.393 | 1.000 |    0.468 |   -48.904 |           0.023
## m1r_threat  | glmerMod | 282.209 | 292.809 |      0.414 |  9.305e-04 | 0.413 | 0.393 | 1.000 |    0.468 |   -48.926 |           0.023
## m1r_measure | glmerMod | 282.110 | 292.710 |      0.424 |      0.001 | 0.423 | 0.392 | 1.000 |    0.467 |   -49.021 |           0.022
## m1rA        | glmerMod | 283.342 | 297.476 |      0.424 |      0.005 | 0.421 | 0.392 | 1.000 |    0.466 |   -49.218 |           0.022
## m1rB        | glmerMod | 284.381 | 302.048 |      0.425 |      0.009 | 0.420 | 0.391 | 1.000 |    0.464 |   -49.445 |           0.018
## m1rC        | glmerMod | 283.796 | 297.930 |      0.420 |      0.003 | 0.419 | 0.393 | 1.000 |    0.467 |   -49.071 |           0.023
## m1rD        | glmerMod | 284.776 | 302.443 |      0.418 |      0.007 | 0.413 | 0.392 | 1.000 |    0.466 |   -49.222 |           0.019

No clear support for threats/measures helping predict range increases - null model preferred

plot_model(m1r_NULL, show.intercept = TRUE)

tab_model(m1r_NULL) 
  increasing
Predictors Odds Ratios CI p
(Intercept) 0.39 0.17 – 0.91 0.029
Random Effects
σ2 3.29
τ00 featurename 2.35
ICC 0.42
N featurename 19
Observations 253
Marginal R2 / Conditional R2 0.000 / 0.417
plot_model(m1r_NULL, type = "pred")
## list()

Are species long-term ranges more likely to be shrinking where there are more threats/measures?

model_data_binom_range_long = model_data %>%
  ungroup() %>%
  mutate(range_trend_long = factor(range_trend_long)) %>%
  filter(range_trend_long == "D" | range_trend_long == "I" | range_trend_long == "S") %>%  # Subset to only increases or declines
  mutate(increasing = ifelse(range_trend_long == "I", 1, 0)) %>% # Response variable with be 'increasing' or otherwise 'decreasing'
  select(region, increasing, n_measure, n_threat, n_pressure, featurename) %>% # Columns for modelling
  drop_na() # Get rid of NAs in any of these columns


# Are species ranges more likely to be shrinking where there are more threats/measures
m2r_NULL = glmer(increasing ~ (1|featurename), 
            data = model_data_binom_range_long, 
            family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m2r_threat = glmer(increasing ~ scale(n_threat) + (1|featurename), 
            data = model_data_binom_range_long, 
            family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m2r_measure = glmer(increasing ~ scale(n_measure) + (1|featurename), 
            data = model_data_binom_range_long, 
            family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m2r_pressure = glmer(increasing ~ scale(n_pressure) + (1|featurename), 
            data = model_data_binom_range_long, 
            family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m2rA = glmer(increasing ~ scale(n_measure) + scale(n_threat) + (1|featurename), 
           data = model_data_binom_range_long, 
           family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m2rB = glmer(increasing ~ scale(n_measure) * scale(n_threat) + (1|featurename), 
          data = model_data_binom_range_long, 
          family = "binomial", control = glmerControl(optimizer = "bobyqa"))  
m2rC = glmer(increasing ~ scale(n_measure) + scale(n_pressure) + (1|featurename), 
           data = model_data_binom_range_long, 
           family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m2rD = glmer(increasing ~ scale(n_measure) * scale(n_pressure) + (1|featurename), 
          data = model_data_binom_range_long, 
          family = "binomial", control = glmerControl(optimizer = "bobyqa"))  

tab_model(m2r_NULL, m2r_threat, m2r_measure, m2r_pressure, m2rA, m2rB, m2rC, m2rD, show.aicc = TRUE)
  increasing increasing increasing increasing increasing increasing increasing increasing
Predictors Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p
(Intercept) 2.97 1.15 – 7.71 0.025 3.09 1.24 – 7.69 0.015 3.01 1.08 – 8.38 0.035 3.06 1.22 – 7.72 0.018 3.49 1.26 – 9.68 0.016 3.45 1.09 – 10.89 0.035 3.28 1.24 – 8.68 0.017 2.47 0.88 – 6.93 0.086
n_threat 1.42 0.71 – 2.84 0.315 2.73 0.92 – 8.10 0.071 2.73 0.91 – 8.23 0.073
n_measure 0.76 0.37 – 1.56 0.453 0.41 0.15 – 1.15 0.090 0.41 0.15 – 1.15 0.090 0.52 0.20 – 1.32 0.167 0.43 0.17 – 1.13 0.087
n_pressure 1.28 0.63 – 2.59 0.495 1.99 0.75 – 5.30 0.168 2.57 0.90 – 7.35 0.078
n_measure * n_threat 1.02 0.43 – 2.38 0.968
n_measure * n_pressure 1.69 0.69 – 4.18 0.253
Random Effects
σ2 3.29 3.29 3.29 3.29 3.29 3.29 3.29 3.29
τ00 1.43 featurename 1.12 featurename 1.70 featurename 1.19 featurename 1.38 featurename 1.37 featurename 1.29 featurename 1.12 featurename
ICC 0.30 0.25 0.34 0.27 0.29 0.29 0.28 0.25
N 14 featurename 14 featurename 14 featurename 14 featurename 14 featurename 14 featurename 14 featurename 14 featurename
Observations 68 68 68 68 68 68 68 68
Marginal R2 / Conditional R2 0.000 / 0.303 0.028 / 0.274 0.015 / 0.351 0.013 / 0.275 0.128 / 0.385 0.127 / 0.384 0.072 / 0.334 0.088 / 0.320
AIC 75.374 76.594 76.977 77.119 75.499 77.831 77.290 78.284
compare_performance(m2r_NULL, m2r_threat, m2r_measure, m2r_pressure, m2rA, m2rB, m2rC, m2rD)
## # Comparison of Model Performance Indices
## 
## Name         |    Model |    AIC |    BIC | R2 (cond.) | R2 (marg.) |   ICC |  RMSE | Sigma | Log_loss | Score_log | Score_spherical
## ------------------------------------------------------------------------------------------------------------------------------------
## m2r_NULL     | glmerMod | 75.189 | 79.628 |      0.303 |      0.000 | 0.303 | 0.359 | 1.000 |    0.410 |   -78.782 |           0.027
## m2r_threat   | glmerMod | 76.219 | 82.877 |      0.274 |      0.028 | 0.254 | 0.361 | 1.000 |    0.419 |   -79.489 |           0.023
## m2r_measure  | glmerMod | 76.602 | 83.260 |      0.351 |      0.015 | 0.341 | 0.353 | 1.000 |    0.396 |   -80.676 |           0.022
## m2r_pressure | glmerMod | 76.744 | 83.403 |      0.275 |      0.013 | 0.265 | 0.363 | 1.000 |    0.419 |   -78.913 |           0.019
## m2rA         | glmerMod | 74.864 | 83.742 |      0.385 |      0.128 | 0.295 | 0.340 | 1.000 |    0.386 |   -88.086 |           0.015
## m2rB         | glmerMod | 76.863 | 87.960 |      0.384 |      0.127 | 0.295 | 0.340 | 1.000 |    0.386 |   -88.017 |           0.015
## m2rC         | glmerMod | 76.655 | 85.533 |      0.334 |      0.072 | 0.282 | 0.353 | 1.000 |    0.401 |   -83.408 |           0.018
## m2rD         | glmerMod | 77.316 | 88.414 |      0.320 |      0.088 | 0.254 | 0.354 | 1.000 |    0.401 |   -83.353 |           0.015

No clear support for threats/measures helping predict long-term range increases - null model preferred

plot_model(m2r_NULL, show.intercept = TRUE)

tab_model(m2r_NULL) 
  increasing
Predictors Odds Ratios CI p
(Intercept) 2.97 1.15 – 7.71 0.025
Random Effects
σ2 3.29
τ00 featurename 1.43
ICC 0.30
N featurename 14
Observations 68
Marginal R2 / Conditional R2 0.000 / 0.303
plot_model(m2r_NULL, type = "pred")
## list()

Habitat-change vs Threats/Measures

Are species habitats more likely to be shrinking where there are more threats/measures?

model_data_binom_habitat = model_data %>%
  ungroup() %>%
  mutate(habitat_trend = factor(habitat_trend)) %>%
  filter(habitat_trend == "D" | habitat_trend == "I") %>%  # Subset to only increases or declines
  mutate(increasing = ifelse(habitat_trend == "I", 1, 0)) %>% # Response variable with be 'increasing' or otherwise 'decreasing'
  select(region, increasing, n_measure, n_threat, n_pressure, featurename) %>% # Columns for modelling
  drop_na() # Get rid of NAs in any of these columns

# Are species ranges more likely to be shrinking where there are more threats/measures
m1h_NULL = glmer(increasing ~ (1|featurename), 
            data = model_data_binom_habitat, 
            family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m1h_threat = glmer(increasing ~ scale(n_threat) + (1|featurename), 
            data = model_data_binom_habitat, 
            family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m1h_measure = glmer(increasing ~ scale(n_measure) + (1|featurename), 
            data = model_data_binom_habitat, 
            family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m1h_pressure = glmer(increasing ~ scale(n_pressure) + (1|featurename), 
            data = model_data_binom_habitat, 
            family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m1hA = glmer(increasing ~ scale(n_measure) + scale(n_threat) + (1|featurename), 
           data = model_data_binom_habitat, 
           family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m1hB = glmer(increasing ~ scale(n_measure) * scale(n_threat) + (1|featurename), 
          data = model_data_binom_habitat, 
          family = "binomial", control = glmerControl(optimizer = "bobyqa"))  
m1hC = glmer(increasing ~ scale(n_measure) + scale(n_pressure) + (1|featurename), 
           data = model_data_binom_habitat, 
           family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m1hD = glmer(increasing ~ scale(n_measure) * scale(n_pressure) + (1|featurename), 
          data = model_data_binom_habitat, 
          family = "binomial", control = glmerControl(optimizer = "bobyqa"))  

tab_model(m1h_NULL, m1h_threat, m1h_measure, m1h_pressure, m1hA, m1hB, m1hC, m1hD, show.aicc = TRUE)
  increasing increasing increasing increasing increasing increasing increasing increasing
Predictors Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p
(Intercept) 18.57 0.35 – 979.19 0.149 26154703.28 0.56 – 1219884105559612.75 0.058 34.05 0.21 – 5523.96 0.174 36.46 0.11 – 12071.11 0.224 25531198.20 0.47 – 1390786549911785.75 0.061 9256279.68 0.00 – 30596103632627248.00 0.151 44.81 0.11 – 19019.92 0.218 44.66 0.11 – 18833.93 0.218
n_threat 0.00 0.00 – 107.08 0.209 0.00 0.00 – 152.83 0.222 0.00 0.00 – 18.74 0.154
n_measure 0.37 0.06 – 2.24 0.282 0.94 0.08 – 10.89 0.963 6.49 0.08 – 515.47 0.402 0.60 0.07 – 5.11 0.640 0.60 0.05 – 7.75 0.698
n_pressure 0.31 0.04 – 2.58 0.278 0.41 0.04 – 4.35 0.457 0.40 0.03 – 5.88 0.507
n_measure * n_threat 0.02 0.00 – 12.87 0.228
n_measure * n_pressure 0.99 0.08 – 12.77 0.993
Random Effects
σ2 3.29 3.29 3.29 3.29 3.29 3.29 3.29 3.29
τ00 10.54 featurename 713.44 featurename 16.63 featurename 18.27 featurename 711.06 featurename 292.27 featurename 20.54 featurename 20.44 featurename
ICC 0.76 1.00 0.83 0.85 1.00 0.99 0.86 0.86
N 10 featurename 10 featurename 10 featurename 10 featurename 10 featurename 10 featurename 10 featurename 10 featurename
Observations 44 44 44 44 44 44 44 44
Marginal R2 / Conditional R2 0.000 / 0.762 0.089 / 0.996 0.046 / 0.842 0.060 / 0.857 0.089 / 0.996 0.094 / 0.990 0.066 / 0.871 0.066 / 0.870
AIC 35.164 33.491 36.011 35.576 35.915 37.336 37.770 40.323
compare_performance(m1h_NULL, m1h_threat, m1h_measure, m1h_pressure, m1hA, m1hB, m1hC, m1hD)
## # Comparison of Model Performance Indices
## 
## Name         |    Model |    AIC |    BIC | R2 (cond.) | R2 (marg.) |   ICC |  RMSE | Sigma | Log_loss | Score_log | Score_spherical
## ------------------------------------------------------------------------------------------------------------------------------------
## m1h_NULL     | glmerMod | 34.872 | 38.440 |      0.762 |      0.000 | 0.762 | 0.225 | 1.000 |    0.179 |   -69.197 |           0.072
## m1h_threat   | glmerMod | 32.891 | 38.244 |      0.996 |      0.089 | 0.995 | 0.138 | 1.000 |    0.064 |      -Inf |           0.073
## m1h_measure  | glmerMod | 35.411 | 40.764 |      0.842 |      0.046 | 0.835 | 0.211 | 1.000 |    0.151 |   -79.509 |           0.058
## m1h_pressure | glmerMod | 34.976 | 40.329 |      0.857 |      0.060 | 0.847 | 0.203 | 1.000 |    0.140 |   -80.982 |           0.061
## m1hA         | glmerMod | 34.889 | 42.026 |      0.996 |      0.089 | 0.995 | 0.138 | 1.000 |    0.064 |      -Inf |           0.073
## m1hB         | glmerMod | 35.757 | 44.678 |      0.990 |      0.094 | 0.989 | 0.150 | 1.000 |    0.071 |      -Inf |           0.071
## m1hC         | glmerMod | 36.744 | 43.881 |      0.871 |      0.066 | 0.862 | 0.202 | 1.000 |    0.136 |   -84.296 |           0.060
## m1hD         | glmerMod | 38.744 | 47.665 |      0.870 |      0.066 | 0.861 | 0.202 | 1.000 |    0.136 |   -84.215 |           0.060

Some (weak) evidence that populations with more threats in place have declining habitat trends.

plot_model(m1h_threat, show.intercept = TRUE)

tab_model(m1h_threat) 
  increasing
Predictors Odds Ratios CI p
(Intercept) 26154703.28 0.56 – 1219884105559612.75 0.058
n_threat 0.00 0.00 – 107.08 0.209
Random Effects
σ2 3.29
τ00 featurename 713.44
ICC 1.00
N featurename 10
Observations 44
Marginal R2 / Conditional R2 0.089 / 0.996
plot_model(m1h_threat, type = "pred")
## $n_threat

Are species long-term habitats more likely to be shrinking where there are more threats/measures?

model_data_binom_habitat_long = model_data %>%
  ungroup() %>%
  mutate(habitat_trend_long = factor(habitat_trend_long)) %>%
  filter(habitat_trend_long == "D" | habitat_trend_long == "I" | habitat_trend_long == "S") %>%  # Subset to only increases or declines
  mutate(increasing = ifelse(habitat_trend_long == "I", 1, 0)) %>% # Response variable with be 'increasing' or otherwise 'decreasing'
  select(region, increasing, n_measure, n_threat, n_pressure, featurename) %>% # Columns for modelling
  drop_na() # Get rid of NAs in any of these columns

# Are species ranges more likely to be shrinking where there are more threats/measures
m2h_NULL = glmer(increasing ~ (1|featurename), 
            data = model_data_binom_habitat_long, 
            family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m2h_threat = glmer(increasing ~ scale(n_threat) + (1|featurename), 
            data = model_data_binom_habitat_long, 
            family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m2h_measure = glmer(increasing ~ scale(n_measure) + (1|featurename), 
            data = model_data_binom_habitat_long, 
            family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m2h_pressure = glmer(increasing ~ scale(n_pressure) + (1|featurename), 
            data = model_data_binom_habitat_long, 
            family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m2hA = glmer(increasing ~ scale(n_measure) + scale(n_threat) + (1|featurename), 
           data = model_data_binom_habitat_long,
           family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m2hB = glmer(increasing ~ scale(n_measure) * scale(n_threat) + (1|featurename), 
          data = model_data_binom_habitat_long, 
          family = "binomial", control = glmerControl(optimizer = "bobyqa"))  
m2hC = glmer(increasing ~ scale(n_measure) + scale(n_pressure) + (1|featurename), 
           data = model_data_binom_habitat_long,
           family = "binomial", control = glmerControl(optimizer = "bobyqa")) 
m2hD = glmer(increasing ~ scale(n_measure) * scale(n_pressure) + (1|featurename), 
          data = model_data_binom_habitat_long, 
          family = "binomial", control = glmerControl(optimizer = "bobyqa"))  

tab_model(m2h_NULL, m2h_threat, m2h_measure, m2h_pressure, m2hA, m2hB, m2hC, m2hD, show.aicc = TRUE)
  increasing increasing increasing increasing increasing increasing increasing increasing
Predictors Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p Odds Ratios CI p
(Intercept) 0.46 0.20 – 1.05 0.065 0.46 0.20 – 1.05 0.065 0.46 0.20 – 1.05 0.065 0.47 0.21 – 1.05 0.065 0.46 0.20 – 1.05 0.065 0.51 0.21 – 1.25 0.139 0.46 0.21 – 1.05 0.065 0.58 0.24 – 1.42 0.234
n_threat 0.99 0.52 – 1.90 0.978 0.97 0.43 – 2.18 0.947 0.92 0.40 – 2.13 0.847
n_measure 1.01 0.54 – 1.91 0.965 1.03 0.47 – 2.26 0.941 1.11 0.48 – 2.56 0.813 0.96 0.46 – 2.00 0.907 1.26 0.53 – 3.03 0.599
n_pressure 1.10 0.58 – 2.09 0.778 1.12 0.53 – 2.39 0.762 0.88 0.37 – 2.11 0.781
n_measure * n_threat 0.85 0.41 – 1.77 0.665
n_measure * n_pressure 0.61 0.26 – 1.42 0.255
Random Effects
σ2 3.29 3.29 3.29 3.29 3.29 3.29 3.29 3.29
τ00 0.43 featurename 0.43 featurename 0.43 featurename 0.41 featurename 0.43 featurename 0.38 featurename 0.41 featurename 0.38 featurename
ICC 0.12 0.12 0.11 0.11 0.12 0.10 0.11 0.10
N 11 featurename 11 featurename 11 featurename 11 featurename 11 featurename 11 featurename 11 featurename 11 featurename
Observations 50 50 50 50 50 50 50 50
Marginal R2 / Conditional R2 0.000 / 0.116 0.000 / 0.116 0.000 / 0.115 0.002 / 0.112 0.000 / 0.116 0.006 / 0.109 0.003 / 0.114 0.040 / 0.139
AIC 67.774 70.039 70.038 69.961 72.401 74.690 72.314 73.431
compare_performance(m2h_NULL, m2h_threat, m2h_measure, m2h_pressure, m2hA, m2hB, m2hC, m2hD)
## # Comparison of Model Performance Indices
## 
## Name         |    Model |    AIC |    BIC | R2 (cond.) | R2 (marg.) |   ICC |  RMSE | Sigma | Log_loss | Score_log | Score_spherical
## ------------------------------------------------------------------------------------------------------------------------------------
## m2h_NULL     | glmerMod | 67.518 | 71.343 |      0.116 |      0.000 | 0.116 | 0.441 | 1.000 |    0.571 |    -6.203 |           0.087
## m2h_threat   | glmerMod | 69.518 | 75.254 |      0.116 |  2.282e-05 | 0.116 | 0.441 | 1.000 |    0.571 |    -6.202 |           0.087
## m2h_measure  | glmerMod | 69.517 | 75.253 |      0.115 |  5.423e-05 | 0.115 | 0.441 | 1.000 |    0.571 |    -6.203 |           0.087
## m2h_pressure | glmerMod | 69.439 | 75.175 |      0.112 |      0.002 | 0.110 | 0.442 | 1.000 |    0.573 |    -6.211 |           0.082
## m2hA         | glmerMod | 71.512 | 79.160 |      0.116 |  1.763e-04 | 0.115 | 0.441 | 1.000 |    0.571 |    -6.204 |           0.087
## m2hB         | glmerMod | 73.326 | 82.887 |      0.109 |      0.006 | 0.103 | 0.443 | 1.000 |    0.574 |    -6.226 |           0.083
## m2hC         | glmerMod | 71.425 | 79.073 |      0.114 |      0.003 | 0.112 | 0.441 | 1.000 |    0.572 |    -6.212 |           0.081
## m2hD         | glmerMod | 72.067 | 81.627 |      0.139 |      0.040 | 0.103 | 0.437 | 1.000 |    0.563 |    -6.347 |           0.077

This doesn’t appear to be the case for the long-term trends, no sig. relationship between threats/measures and habitat change

plot_model(m2h_NULL, show.intercept = TRUE)

tab_model(m2h_NULL) 
  increasing
Predictors Odds Ratios CI p
(Intercept) 0.46 0.20 – 1.05 0.065
Random Effects
σ2 3.29
τ00 featurename 0.43
ICC 0.12
N featurename 11
Observations 50
Marginal R2 / Conditional R2 0.000 / 0.116
plot_model(m2h_NULL, type = "pred")
## list()

Notes

  • Missing species? (these aren’t in Article 12 I think )
  • Do we have enough information to weight these species by pop size?
sessionInfo()
## R version 4.0.3 (2020-10-10)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Big Sur 10.16
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] performance_0.7.0 tidyr_1.1.2       sjPlot_2.8.7      lme4_1.1-26      
##  [5] Matrix_1.2-18     ggplot2_3.3.3     data.table_1.13.6 expss_0.10.7     
##  [9] dplyr_1.0.7       plyr_1.8.6       
## 
## loaded via a namespace (and not attached):
##  [1] splines_4.0.3      carData_3.0-4      modelr_0.1.8       assertthat_0.2.1  
##  [5] statmod_1.4.35     highr_0.9          cellranger_1.1.0   yaml_2.2.1        
##  [9] bayestestR_0.8.2   pillar_1.6.1       backports_1.2.1    lattice_0.20-41   
## [13] glue_1.4.2         digest_0.6.27      RColorBrewer_1.1-2 ggsignif_0.6.1    
## [17] checkmate_2.0.0    minqa_1.2.4        colorspace_2.0-0   htmltools_0.5.1.1 
## [21] pkgconfig_2.0.3    broom_0.7.5        haven_2.3.1        purrr_0.3.4       
## [25] xtable_1.8-4       mvtnorm_1.1-1      scales_1.1.1       openxlsx_4.2.3    
## [29] rio_0.5.26         emmeans_1.5.4      htmlTable_2.1.0    tibble_3.1.2      
## [33] farver_2.1.0       generics_0.1.0     car_3.0-10         sjlabelled_1.1.7  
## [37] ellipsis_0.3.2     ggpubr_0.4.0       withr_2.4.2        cli_3.0.0         
## [41] readxl_1.3.1       magrittr_2.0.1     crayon_1.4.1       effectsize_0.4.3  
## [45] estimability_1.3   evaluate_0.14      fansi_0.5.0        nlme_3.1-149      
## [49] MASS_7.3-53        rstatix_0.7.0      forcats_0.5.1      foreign_0.8-81    
## [53] tools_4.0.3        hms_1.0.0          lifecycle_1.0.0    matrixStats_0.58.0
## [57] stringr_1.4.0      munsell_0.5.0      zip_2.2.0          ggeffects_1.0.1   
## [61] compiler_4.0.3     rlang_0.4.11       grid_4.0.3         nloptr_1.2.2.2    
## [65] parameters_0.11.0  rstudioapi_0.13    htmlwidgets_1.5.3  labeling_0.4.2    
## [69] rmarkdown_2.6      boot_1.3-25        gtable_0.3.0       abind_1.4-5       
## [73] sjstats_0.18.1     DBI_1.1.1          curl_4.3.2         sjmisc_2.8.6      
## [77] R6_2.5.0           knitr_1.33         utf8_1.2.1         insight_0.12.0    
## [81] stringi_1.6.2      Rcpp_1.0.7         vctrs_0.3.8        tidyselect_1.1.1  
## [85] xfun_0.24          coda_0.19-4