Author: Gabriel Caetano
Date: 2026-04-17

# Proactive Conservation Index tutorial

#### Gabriel Caetano

#### 2026-04-17

This tutorial teaches how to install and use package ‘pciR’, which calculates the Proactive Conservation Prioritization Index, a conservation priority index focused on the future. PCI is an easy to calculate index to prioritize species for conservation, which is flexible enough to incorporate any threat correlate. It also allows modulating the effects of threats using other variables such as species traits. PCI’s rationale, methods, applications and guidelines are presented in the publication ‘The future-focused Proactive Conservation Index highlights unrecognized global priorities for vertebrate conservation’ (Caetano et al. 2025). A Shiny app to explore the results of this paper and the effects of different weighting schemes on PCI scores for global vertebrates can be found at: gabrielhoc.shinyapps.io/pci_app

# Vertebrate traits and threats data set

‘PCI’ includes a data set on threat correlates and traits for 33565 global vertebrate species, see (Caetano et al. 2025 for sources and descriptions of all data columns). The functions in the package can be used with any data set, not only the one included here. You can access the global vertebrate data using the command below:

    data("vert_df", package = "pciR")

    head(vert_df)

    ##                binomial     class       family iucn_cat   range_area body_mass
    ## 1    Abavorana luctuosa Amphibian      Ranidae       LC  114771.2859 29.886849
    ## 2   Acanthixalus sonjae Amphibian Hyperoliidae       VU    5966.2012  4.934016
    ## 3 Acanthixalus spinosus Amphibian Hyperoliidae       LC 1213773.0847  4.934016
    ## 4       Acris crepitans Amphibian      Hylidae       LC 3209475.1497  4.535760
    ## 5         Acris gryllus Amphibian      Hylidae       LC  667570.0093  2.871682
    ## 6   Adelastes hylonomos Amphibian Microhylidae       DD     127.8153  1.889386
    ##   brood_size protected_area AHI clim_2050_245 clim_2050_585 clim_2100_245
    ## 1   1163.513     0.17531511 0.5  0.0000000000  0.0063371356   0.009332872
    ## 2      8.060     0.60563380 1.0  0.0000000000  0.0196078431   0.048128342
    ## 3      8.940     0.08214847 0.0  0.0000000000  0.0000000000   0.019830963
    ## 4    141.420     0.01366837 0.0  0.0002267188  0.0006801564   0.007759967
    ## 5    183.470     0.03942045 0.0  0.0000000000  0.0063391442   0.060149834
    ## 6   1103.549     1.00000000 1.0  0.6666666667  1.0000000000   0.818181818
    ##   clim_2100_585 landuse_2050_245 landuse_2050_585 landuse_2100_245
    ## 1    0.07466298      0.245105870     2.333882e-01      0.320193332
    ## 2    0.57219251      0.308864678     8.261402e-01      0.481850680
    ## 3    0.14714492      0.191106861     3.873485e-01      0.169498840
    ## 4    0.20845249      0.590611038     6.465005e-01      0.550806229
    ## 5    0.30190174      0.238183355     2.947990e-01      0.192171734
    ## 6    1.00000000      0.003843569     2.981774e-05      0.002055046
    ##   landuse_2100_585 popdens_2050_245 popdens_2050_585 popdens_2100_245
    ## 1     1.214028e-01     5.5813681741     5.1663431735     5.5424653541
    ## 2     8.741837e-01     2.4306237162     1.8412160728     2.6148111109
    ## 3     3.884704e-01     1.9699580927     1.7602878551     2.5661056527
    ## 4     6.739553e-01     2.3064385661     2.7258558380     2.6103187074
    ## 5     3.304962e-01     2.9952078388     3.5458850067     3.3905897656
    ## 6     2.197629e-05     0.0004242429     0.0004242429     0.0003986398
    ##   popdens_2100_585 inv_threat
    ## 1      4.284011800  0.4363636
    ## 2      1.441322133  0.2857143
    ## 3      1.928993990  0.1295337
    ## 4      4.061888483  0.7376943
    ## 5      5.280735276  0.7318436
    ## 6      0.000270027  0.0000000

You can see above that this data set contains the vertebrate species names (‘binomial’); their taxonomic class (‘class’); their taxonomic family (‘family’); their threat category on the IUCN Red List of Threatened Species (‘iucn_cat’); their maximum body mass, in grams (‘body_mass’); their maximum brood size (‘brood_size’); the area of their distribution range, in km2 (‘range_area’); an index of how sensitive the species is to human-made habitats (‘AHI’); the average human population density across the species range in four future scenarios (‘popdens_2050_245’, ‘popdens_2050_585’, ‘popdens_2100_245’, ‘popdens_2100_585’); the proportion of the species range lost due to climate change in four future scenarios (‘clim_2050_245’, ‘clim_2100_245’, ‘clim_2050_585’, ‘clim_2100_585’); the proportion of the species range lost due to land use change in four future scenarios (‘landuse_2050_245’, ‘landuse_2100_245’, ‘landuse_2050_585’, ‘landuse_2100_585’) the proportion of the species range under high threat of biological invasions in 2100 (‘inv_threat’).

Some of these variables represent threats to species conservation (human population density, climate change, land use change, biological invasions), while others represent species characteristics that might make them more or less vulnerable to those threats (body mass, brood size, range size, protected area, AHI). Some variables such as range area, brood size and protected area are negatively associated with conservation priority To calculate the index, all variables must have the same direction (i.e. higher values are associated with higher extinction risk) so we must invert these variables:

    vert_df$log_body_mass <- log(vert_df$body_mass)
    vert_df$inv_range_area <- 1/vert_df$range_area
    vert_df$inv_brood_size <- 1/vert_df$brood_size
    vert_df$inv_protected_area <- 1/((vert_df$protected_area*vert_df$range_area+0.0001)) #add small number to avoid division by zero

We will divide variables into two classes, extrinsic and intrinsic variables. Extrinsic variables refer to the threatening processes themselves, while intrinsic variables are characteristics of species that modulate their response to external threats. First we check the column names in our data table, so we can choose the variables we want.

    traits_vertebrates <-
       vert_df[c("log_body_mass",
                 "inv_range_area",
                 "inv_brood_size",
                 "inv_protected_area",
                 "AHI")]

We are going to calculate PCI for four different future scenarios (years 2050 and 2100 under carbon emission scenarios SSP 2.45 and SSP 5.85). Therefore we need to create separate data frames containing the extrinsic variables for each scenario. We want columns 7 and 8 for all scenarios (human_footprint and human population density), plus the columns for climate change (columns 9 to 12) and land use change (columns 13 to 16) corresponding to each scenario.

    threats_2050_245 <-
       vert_df[c("clim_2050_245",
                 "landuse_2050_245",
                 "popdens_2050_245",
                 "inv_threat")]

    threats_2050_585 <-
       vert_df[c("clim_2050_585",
                 "landuse_2050_585",
                 "popdens_2050_585",
                 "inv_threat")]

    threats_2100_245 <-
       vert_df[c("clim_2100_245",
                 "landuse_2100_245",
                 "popdens_2100_245",
                 "inv_threat")]

    threats_2100_585 <-
       vert_df[c("clim_2100_585",
                 "landuse_2100_585",
                 "popdens_2100_585",
                 "inv_threat")]

# Calculating PCI

We will output the top PCI scores for the top 6 species in each scenario, as well as the distribution of the index against its rank.

    vert_pci_2050_45 <-
      pciR::pci(sp = vert_df$binomial,
               var_out = threats_2050_245,
               var_in = traits_vertebrates)

    head(vert_pci_2050_45[order(vert_pci_2050_45$rank),])

    ##                                  sp       pci rank
    ## 2311             Fejervarya moodiei 0.7948818    1
    ## 13369           Lycodon tessellatus 0.7777183    2
    ## 17394 Tropiocolotes wolfgangboehmei 0.7493590    3
    ## 17302      Tropidophis nigriventris 0.7100654    4
    ## 17783     Xerotyphlops luristanicus 0.7086627    5
    ## 8125              Arrhyton ainictum 0.7053705    6

    vert_pci_2050_85 <-
      pciR::pci(sp = vert_df$binomial,
               var_out = threats_2050_585,
               var_in = traits_vertebrates)

    head(vert_pci_2050_85[order(vert_pci_2050_85$rank),])

    ##                                  sp       pci rank
    ## 2311             Fejervarya moodiei 0.7948538    1
    ## 13369           Lycodon tessellatus 0.7778530    2
    ## 17394 Tropiocolotes wolfgangboehmei 0.7493611    3
    ## 8158             Asaccus zagrosicus 0.7009201    4
    ## 3181            Latonia nigriventer 0.6946980    5
    ## 17783     Xerotyphlops luristanicus 0.6936973    6

    vert_pci_2100_45 <-
      pciR::pci(sp = vert_df$binomial,
               var_out = threats_2100_245,
               var_in = traits_vertebrates)

    head(vert_pci_2100_45[order(vert_pci_2100_45$rank),])

    ##                                  sp       pci rank
    ## 13369           Lycodon tessellatus 0.7989348    1
    ## 2311             Fejervarya moodiei 0.7954779    2
    ## 17394 Tropiocolotes wolfgangboehmei 0.7485539    3
    ## 20613           Microcebus marohita 0.7269778    4
    ## 9169               Chalcides ebneri 0.7086554    5
    ## 15297              Pristurus mazbah 0.7067463    6

    vert_pci_2100_85 <-
      pciR::pci(sp = vert_df$binomial,
               var_out = threats_2100_585,
               var_in = traits_vertebrates)

    head(vert_pci_2100_85[order(vert_pci_2100_85$rank),])

    ##                                  sp       pci rank
    ## 2311             Fejervarya moodiei 0.7917232    1
    ## 13369           Lycodon tessellatus 0.7724071    2
    ## 17126     Tricheilostoma greenwelli 0.7504837    3
    ## 10041           Cynisca nigeriensis 0.7503524    4
    ## 10033            Cynisca ivoirensis 0.7494783    5
    ## 17394 Tropiocolotes wolfgangboehmei 0.7492676    6

# Weighting

PCI allows users to assign custom weights to threats, and to the interactions between threats and species traits. Using this tool, users can adjust PCI to emphasize threats or traits more relevant to their taxa or region of interest. Weights must be input in the same order as the variables they are meant to weight.

We are going to use arbitrary weights only to exemplify the functions working. Users should base their weighting system on previous evidence about the relative effect of threats in a given taxonomic group or region, or use an analytical method to derive weights empirically (we demonstrate an example of such a method below, and expand more on this topic in Caetano et al. 2025). In this example, we will assign a weight of 3 to climate change, 2 to land use change, 1 to human population density and 0 to biological invasions.

    names(threats_2100_585)

    ## [1] "clim_2100_585"    "landuse_2100_585" "popdens_2100_585" "inv_threat"

    # [1] "clim_2100_245"    "landuse_2100_245" "popdens_2100_245" "inv_threat"

    weights_threats <- c(3, 2, 1, 0)

The weights for interactions between threats and traits must be input as a matrix, with a number of rows equal to the number of threats and a number of columns equal to the number of traits. Let’s first create a matrix with all weights equal to 1, to figure out the position of each interaction.

    names(traits_vertebrates)

    ## [1] "log_body_mass"      "inv_range_area"     "inv_brood_size"
    ## [4] "inv_protected_area" "AHI"

    # [1] "log_body_mass"      "inv_range_area"     "inv_brood_size"     "inv_protected_area" "AHI"

    weights_traits <-
    matrix(1,
           ncol(threats_2100_585),
           ncol(traits_vertebrates))

    rownames(weights_traits) <- names(threats_2100_585)
    colnames(weights_traits) <- names(traits_vertebrates)

    weights_traits

    ##                  log_body_mass inv_range_area inv_brood_size inv_protected_area
    ## clim_2100_585                1              1              1                  1
    ## landuse_2100_585             1              1              1                  1
    ## popdens_2100_585             1              1              1                  1
    ## inv_threat                   1              1              1                  1
    ##                  AHI
    ## clim_2100_585      1
    ## landuse_2100_585   1
    ## popdens_2100_585   1
    ## inv_threat         1

We can, for example, change the weights of the interactions between body mass and with all threats to 2, and the weights of the interactions of range area with climate change and land use change to 3.

    # climate change, all rows
    weights_traits[,1] <- 2

    # land use change, first two rows
    weights_traits[1,2] <- 3
    weights_traits[2,2] <- 3

    weights_traits

    ##                  log_body_mass inv_range_area inv_brood_size inv_protected_area
    ## clim_2100_585                2              3              1                  1
    ## landuse_2100_585             2              3              1                  1
    ## popdens_2100_585             2              1              1                  1
    ## inv_threat                   2              1              1                  1
    ##                  AHI
    ## clim_2100_585      1
    ## landuse_2100_585   1
    ## popdens_2100_585   1
    ## inv_threat         1

We can now use the new weights to recalculate PCI for all species in the year 2100, under scenario SSP 5.85.

    vert_pci_2100_85_weighted <-
      pciR::pci(sp = vert_df$binomial,
               var_out = threats_2100_585,
               var_in = traits_vertebrates,
               weight_out = weights_threats,
               weight_in = weights_traits)

    head(vert_pci_2100_85_weighted[order(vert_pci_2100_85_weighted$rank),])

    ##                              sp       pci rank
    ## 9382            Cnemaspis gigas 0.8320410    1
    ## 10041       Cynisca nigeriensis 0.8318839    2
    ## 10046         Cynisca williamsi 0.8316785    3
    ## 10034        Cynisca kigomensis 0.8313976    4
    ## 7521             Anilios fossor 0.8313492    5
    ## 17126 Tricheilostoma greenwelli 0.8311167    6

# Weight optimization

So far, we have used arbitrary weights as examples. However, the PCI package includes a function (‘optim_weights’) that allows the estimation of weights so PCI matches an external reference. This is useful, for example, if another conservation prioritization scheme is available for a subset of the species in the taxonomic group or region of interest, then this subset can be used to estimate the weights, which can then be applied to calculate PCI for the entire set of species.

For this example, we are going to use IUCN Red List categories as our reference, but users should refer to Caetano et al. 2025 for an extended comparison between PCI and the Red List. First, let’s select only the subset of species that were assigned Red List categories that can be used in conservation prioritization schemes (‘LC’, ‘NT’, ‘VU’, ‘EN’, and ‘CR’), then convert the categories into ordinate integers, with value increasing from less threatened to more threatened. We will also select only reptile species for this example, to reduce computation time, as the weight optimization function can take a while to run on larger data sets.

    rept_df <-
    vert_df[vert_df$class == "Reptile",]

    rept_df_iucn <-
      rept_df[rept_df$iucn_cat %in%
                c("LC", "NT", "VU", "EN", "CR"),]

    rept_df_iucn$iucn_cat_num <-
      as.numeric(factor(rept_df_iucn$iucn_cat,
             levels = c("LC", "NT", "VU", "EN", "CR")))

We must also subset the threat and trait data so it contains the same species as our weight calibration data set.

    threats_2100_585_rept_iucn <-
    threats_2100_585[vert_df$binomial %in% rept_df_iucn$binomial,]

    traits_rept_iucn <-
    traits_vertebrates[vert_df$binomial %in% rept_df_iucn$binomial,]

Now we can calibrate our weights, inputting the subsets of threat and trait data and the IUCN calibration reference. The function also allows the user to choose if they want to optimize weights only for threat variables (“out”), for threat/trait interactions (“in”) or both (“both”). The optimization function then tries to find the set of weights that leads to the maximum correlation between PCI and the reference.

    optim_weights_rept <-
      pciR::optim_weights(sp = rept_df_iucn$binomial,
                         var_out = threats_2100_585_rept_iucn,
                         var_in = traits_rept_iucn,
                         reference = rept_df_iucn$iucn_cat_num,
                         type = "both",
                         control = list(maxit = 5))

    ## correlation = 0.28046746607841correlation = 0.280497708720258correlation =
    ## 0.280437178587746correlation = 0.280448986026225correlation =
    ## 0.280485947194759correlation = 0.280468051885405correlation =
    ## 0.280466880104225correlation = 0.280455092495907correlation =
    ## 0.280479833205897correlation = 0.280467499282903correlation =
    ## 0.280467432873881correlation = 0.280467463507707correlation =
    ## 0.280467468649104correlation = 0.280467466245679correlation =
    ## 0.280467465911141correlation = 0.280467477244001correlation =
    ## 0.280467454912801correlation = 0.280467443507147correlation =
    ## 0.280467488649682correlation = 0.280467466496001correlation =
    ## 0.280467465660819correlation = 0.280467466082576correlation =
    ## 0.280467466074244correlation = 0.280467476368511correlation =
    ## 0.280467455788288correlation = 0.280467471807728correlation =
    ## 0.280467460349092correlation = 0.280467465286595correlation =
    ## 0.280467466870225correlation = 0.28046746609162correlation =
    ## 0.2804674660652correlation = 0.280467466749735correlation =
    ## 0.280467465407085correlation = 0.280467434877294correlation =
    ## 0.280467497341901correlation = 0.280467468096231correlation =
    ## 0.280467464056538correlation = 0.280467465804496correlation =
    ## 0.280467466352872correlation = 0.280467438748289correlation =
    ## 0.280467493463169correlation = 0.28046748094812correlation =
    ## 0.280467451208698correlation = 0.280467467003488correlation =
    ## 0.280467465153331correlation = 0.280467466167953correlation =
    ## 0.280467465988867correlation = 0.280467471308786correlation =
    ## 0.280467460848033correlation = 0.281853216565874correlation =
    ## 0.281881903217868correlation = 0.281824487291658correlation =
    ## 0.281834801427058correlation = 0.281871632542121correlation =
    ## 0.281853791077654correlation = 0.281852641888121correlation =
    ## 0.281840985413101correlation = 0.281865440933133correlation =
    ## 0.281853251047871correlation = 0.281853182083841correlation =
    ## 0.281853214227474correlation = 0.281853218904265correlation =
    ## 0.281853216733626correlation = 0.281853216398123correlation =
    ## 0.281853227658841correlation = 0.28185320547289correlation =
    ## 0.28185319458887correlation = 0.281853238542886correlation =
    ## 0.281853216972185correlation = 0.281853216159564correlation =
    ## 0.281853216570064correlation = 0.281853216561684correlation =
    ## 0.281853226610817correlation = 0.281853206520911correlation =
    ## 0.281853222408519correlation = 0.281853210723229correlation =
    ## 0.281853215805251correlation = 0.281853217326497correlation =
    ## 0.281853216579164correlation = 0.281853216552584correlation =
    ## 0.281853217238634correlation = 0.281853215893114correlation =
    ## 0.281853182939767correlation = 0.281853250259209correlation =
    ## 0.281853218318539correlation = 0.28185321480969correlation =
    ## 0.281853216291532correlation = 0.281853216840765correlation =
    ## 0.281853189621957correlation = 0.281853243563657correlation =
    ## 0.281853231874955correlation = 0.28185320125679correlation =
    ## 0.281853217504147correlation = 0.2818532156276correlation =
    ## 0.281853216655259correlation = 0.28185321647649correlation =
    ## 0.281853221725016correlation = 0.281853211406731correlation =
    ## 0.308882653861149correlation = 0.308881914499258correlation =
    ## 0.308883392765686correlation = 0.308875620578425correlation =
    ## 0.308882653861149correlation = 0.308883133221386correlation =
    ## 0.308882174325579correlation = 0.308884821124156correlation =
    ## 0.308880460822963correlation = 0.308882727495132correlation =
    ## 0.308882580227094correlation = 0.308882653861149correlation =
    ## 0.308882653861149correlation = 0.308882654053787correlation =
    ## 0.308882653668511correlation = 0.30888265802613correlation =
    ## 0.308882649696163correlation = 0.308882657864649correlation =
    ## 0.308882649857646correlation = 0.308882653861149correlation =
    ## 0.308882653861149correlation = 0.308882653865619correlation =
    ## 0.308882653856679correlation = 0.308882653180494correlation =
    ## 0.308882654541803correlation = 0.308882662695213correlation =
    ## 0.308882645027084correlation = 0.308882653861149correlation =
    ## 0.308882653861149correlation = 0.308882653876452correlation =
    ## 0.308882653845846correlation = 0.308882654447435correlation =
    ## 0.308882653274863correlation = 0.308882537929715correlation =
    ## 0.30888277002528correlation = 0.308882653861149correlation =
    ## 0.308882653861149correlation = 0.308882653555442correlation =
    ## 0.308882654167468correlation = 0.308882647772111correlation =
    ## 0.308882659962373correlation = 0.308882682850532correlation =
    ## 0.308882624871761correlation = 0.308882653861149correlation =
    ## 0.308882653861149correlation = 0.308882653954744correlation =
    ## 0.308882653767554correlation = 0.308882655874977correlation =
    ## 0.308882651847321correlation = 0.308989339415352correlation =
    ## 0.30898900995824correlation = 0.308989667557562correlation =
    ## 0.308981831215706correlation = 0.308989339415352correlation =
    ## 0.308989807428216correlation = 0.308988871230192correlation =
    ## 0.308989546884801correlation = 0.308989108179937correlation =
    ## 0.308989412135802correlation = 0.308989266694831correlation =
    ## 0.308989339415352correlation = 0.308989339415352correlation =
    ## 0.308989339609947correlation = 0.308989339220757correlation =
    ## 0.308989344522773correlation = 0.308989334307924correlation =
    ## 0.308989342788131correlation = 0.308989336042568correlation =
    ## 0.308989339415352correlation = 0.308989339415352correlation =
    ## 0.308989339419905correlation = 0.308989339410798correlation =
    ## 0.308989339349637correlation = 0.308989339481063correlation =
    ## 0.308989348174589correlation = 0.308989330656113correlation =
    ## 0.308989339415352correlation = 0.308989339415352correlation =
    ## 0.308989339430836correlation = 0.308989339399868correlation =
    ## 0.308989340066359correlation = 0.308989338764345correlation =
    ## 0.308989224815992correlation = 0.30898945424564correlation =
    ## 0.308989339415352correlation = 0.308989339415352correlation =
    ## 0.308989339106575correlation = 0.308989339724747correlation =
    ## 0.308989331305058correlation = 0.30898934754188correlation =
    ## 0.30898936803314correlation = 0.308989310797558correlation =
    ## 0.308989339415352correlation = 0.308989339415352correlation =
    ## 0.308989339509793correlation = 0.30898933932091correlation =
    ## 0.3089893418242correlation = 0.308989337006503correlation =
    ## 0.309002937257589correlation = 0.309002700220992correlation =
    ## 0.309003172782777correlation = 0.30899531894065correlation =
    ## 0.309002937257589correlation = 0.309003401057973correlation =
    ## 0.309002473284512correlation = 0.30900277492283correlation =
    ## 0.309003076070359correlation = 0.30900301029499correlation =
    ## 0.309002864411625correlation = 0.309002937257589correlation =
    ## 0.309002937257589correlation = 0.309002937456803correlation =
    ## 0.309002937058376correlation = 0.309002942552414correlation =
    ## 0.309002931962758correlation = 0.309002940502526correlation =
    ## 0.309002934201968correlation = 0.309002937257589correlation =
    ## 0.309002937257589correlation = 0.309002937262264correlation =
    ## 0.309002937252915correlation = 0.309002937335357correlation =
    ## 0.309002937179818correlation = 0.309002946039886correlation =
    ## 0.309002928475292correlation = 0.309002937257589correlation =
    ## 0.309002937257589correlation = 0.309002937273437correlation =
    ## 0.309002937241741correlation = 0.309002937919588correlation =
    ## 0.309002936595591correlation = 0.309002821707054correlation =
    ## 0.309003053042185correlation = 0.309002937257589correlation =
    ## 0.309002937257589correlation = 0.309002936941598correlation =
    ## 0.309002937574213correlation = 0.309002928723335correlation =
    ## 0.309002945808932correlation = 0.309002965924148correlation =
    ## 0.309002908591025correlation = 0.309002937257589correlation =
    ## 0.309002937257589correlation = 0.309002937354141correlation =
    ## 0.309002937161037correlation = 0.309002939743485correlation =
    ## 0.309002934771692correlation = 0.309041699803616correlation =
    ## 0.309041643603514correlation = 0.309041754070122correlation =
    ## 0.309033809240881correlation = 0.309041699803616correlation =
    ## 0.309042149378257correlation = 0.309041250052858correlation =
    ## 0.309040839957152correlation = 0.309042536211802correlation =
    ## 0.309041773870381correlation = 0.309041625736758correlation =
    ## 0.309041699803616correlation = 0.309041699803616correlation =
    ## 0.30904170002352correlation = 0.309041699583712correlation =
    ## 0.30904170545513correlation = 0.309041694152095correlation =
    ## 0.309041702750576correlation = 0.309041696856656correlation =
    ## 0.309041699803616correlation = 0.309041699803616correlation =
    ## 0.309041699808819correlation = 0.309041699798413correlation =
    ## 0.309041700171235correlation = 0.309041699435993correlation =
    ## 0.309041708736622correlation = 0.309041690870609correlation =
    ## 0.309041699803616correlation = 0.309041699803616correlation =
    ## 0.30904169982108correlation = 0.309041699786153correlation =
    ## 0.309041700484934correlation = 0.309041699122298correlation =
    ## 0.309041578818447correlation = 0.309041821039397correlation =
    ## 0.309041699803616correlation = 0.309041699803616correlation =
    ## 0.309041699455379correlation = 0.309041700152551correlation =
    ## 0.309041690435435correlation = 0.309041709190585correlation =
    ## 0.309041728915921correlation = 0.309041670691306correlation =
    ## 0.309041699803616correlation = 0.309041699803616correlation =
    ## 0.30904169990958correlation = 0.309041699697653correlation =
    ## 0.309041702434761correlation = 0.309041697172471correlation =
    ## 0.30912560083842correlation = 0.309125829445749correlation =
    ## 0.309125369521341correlation = 0.309117159620947correlation =
    ## 0.30912560083842correlation = 0.309126012762325correlation =
    ## 0.309125188726879correlation = 0.309123723302429correlation =
    ## 0.309127454157618correlation = 0.309125678413845correlation =
    ## 0.309125523262886correlation = 0.30912560083842correlation =
    ## 0.30912560083842correlation = 0.309125601118255correlation =
    ## 0.309125600558584correlation = 0.309125606998825correlation =
    ## 0.309125594678006correlation = 0.309125603958513correlation =
    ## 0.309125597718325correlation = 0.30912560083842correlation =
    ## 0.30912560083842correlation = 0.309125600845165correlation =
    ## 0.309125600831674correlation = 0.309125601653553correlation =
    ## 0.309125600023281correlation = 0.309125610276504correlation =
    ## 0.309125591400333correlation = 0.30912560083842correlation =
    ## 0.30912560083842correlation = 0.309125600860518correlation =
    ## 0.309125600816321correlation = 0.309125601543974correlation =
    ## 0.309125600132865correlation = 0.309125461963331correlation =
    ## 0.309125740019716correlation = 0.30912560083842correlation =
    ## 0.30912560083842correlation = 0.30912560039729correlation =
    ## 0.309125601280432correlation = 0.30912559021603correlation =
    ## 0.309125611482203correlation = 0.309125631499899correlation =
    ## 0.309125570176934correlation = 0.30912560083842correlation =
    ## 0.30912560083842correlation = 0.30912560097114correlation =
    ## 0.309125600705699correlation = 0.309125603673945correlation = 0.309125598002894

We can now check the results of the weight optimization.

    optim_weights_rept$weight_out

    ##    clim_2100_585 landuse_2100_585 popdens_2100_585       inv_threat
    ##     1.678578e+00    1.000000e-100     1.387445e+00     5.133708e-01

    optim_weights_rept$weight_in

    ##                  log_body_mass inv_range_area inv_brood_size inv_protected_area
    ## clim_2100_585        1.0589808       1.001614      1.0071771          0.9074199
    ## landuse_2100_585     0.9999695       1.000017      0.9999716          0.9999849
    ## popdens_2100_585     1.0001632       1.000004      1.0000130          0.9997405
    ## inv_threat           1.0045601       1.000425      1.0005426          0.9923266
    ##                       AHI
    ## clim_2100_585    1.023267
    ## landuse_2100_585 1.000057
    ## popdens_2100_585 1.000079
    ## inv_threat       1.002129

And finally apply these weights to calculate PCI for all reptiles.

    threats_2100_585_rept <-
    threats_2100_585[vert_df$class == "Reptile",]

    traits_rept <-
    traits_vertebrates[vert_df$class == "Reptile",]

    rept_pci_2100_85_opt <-
      pciR::pci(sp = rept_df$binomial,
               var_out = threats_2100_585_rept,
               var_in = traits_rept,
               weight_out = optim_weights_rept$weight_out,
               weight_in = optim_weights_rept$weight_in)

    head(rept_pci_2100_85_opt[order(rept_pci_2100_85_opt$rank),])

    ##                                sp       pci rank
    ## 6437          Lycodon tessellatus 0.9993270    1
    ## 3265     Cyrtodactylus metropolis 0.6859633    2
    ## 4224           Eremias papenfussi 0.6564987    3
    ## 8618    Pseudorabdion modiglianii 0.6481455    4
    ## 10195   Tricheilostoma kongoensis 0.6406514    5
    ## 3203  Cyrtodactylus guwahatiensis 0.6365882    6