Skip to contents

Climate indices from monthly data, composite bioclimatic variables, comparing climate products, terrain and soil layers, and selecting predictor sets that stay uncorrelated across periods and regions.

4. Predictors: climate, terrain and soil

Three kinds of predictors are prepared here: climate indices from monthly climatologies (4.1 to 4.3), terrain indices from an elevation model (4.4) and soil layers from SoilGrids (4.5). All are listed, with their meanings, units and sources, by climate_index_names(table = TRUE), and enter variable selection (section 5 below) like any other layer.

4.1 Climate indices from monthly data

Bioclimatic variables describe temperature and precipitation, but not the water balance, the heat and cold stress, the length of the season or the light that limit many species. climate_indices() computes such variables from monthly climatologies: the 12 monthly means of maximum (tasmax), minimum (tasmin) and mean (tas) temperature and precipitation (pr). Daily data are not needed.

Index Group Meaning Unit Useful for Source
vpd water mean vapour pressure deficit (dew point from Tmin; a climatological approximation) kPa dryness of the air: stomatal closure and transpiration of plants, desiccation of amphibians, snails and insects Allen et al. 1998; Grossiord et al. 2020
pet water potential evapotranspiration (Hargreaves-Samani, temperature-based; not Penman-Monteith) mm/year evaporative demand and available energy; plant productivity and species richness Hargreaves & Samani 1985; Allen et al. 1998
cmd water climatic moisture deficit: sum of monthly PET − P where positive mm/year drought not met by rain: forest-steppe limits, drought-sensitive trees, C3 versus C4 grasses Stephenson 1990; Wang et al. 2012
aridity water aridity index P / PET (< 0.05 hyper-arid, > 0.65 humid) – the humid-arid gradient: biome limits, dryland and desert taxa UNEP 1992
heat_stress heat sum over months of Tmax above heat_threshold °C × months exposure to hot months: upper thermal limits of alpine and boreal taxa and of ectotherms; C4 advantage this package; Ehleringer et al. 1997
sri ⚑ season summer rain index: precipitation of the warmest quarter / annual (bio18 / bio12) 0-1 rain in the warm season: C4 versus C3 grasses, monsoon versus Mediterranean taxa Teeri & Stowe 1976; Paruelo & Lauenroth 1996
synchronicity ⚑ season heat-rain synchrony: 1 = the warmest and the wettest month coincide, 0 = six months apart 0-1 whether water arrives when it is warm: summer-rain versus winter-rain floras, C3/C4 balance this package; Paruelo & Lauenroth 1996
t_wet season mean temperature weighted by monthly precipitation (smooth bio8) °C temperature when water is available this package; after Booth 2022
t_dry season mean temperature weighted by monthly dryness, max(P) − P (smooth bio9) °C temperature of the dry season this package; after Booth 2022
p_warm season precipitation weighted by monthly warmth, T − min(T), × 3 (smooth bio18) mm/quarter rain in the warm season, like bio18 and sri this package; after Booth 2022
p_cold season precipitation weighted by monthly coldness, max(T) − T, × 3 (smooth bio19) mm/quarter rain in the cold season, like bio19 this package; after Booth 2022
tp_correlation season correlation of the 12 monthly mean temperatures with the 12 monthly precipitation sums (smooth synchronicity) −1 to 1 rain in the warm season (+1) or the cold season (−1), from the whole cycle this package; after Paruelo & Lauenroth 1996
bio1 … bio19 bioclim the standard bioclimatic variables from the same monthly layers; bio8, bio9, bio18, bio19 ⚑ °C, mm the usual predictors, on exactly the grid and period of the other indices Busby 1991; Hijmans et al. 2005; O’Donnell & Ignizio 2012
gdd heat growing degree days: monthly Tmean above gdd_base × days °C × days heat sum for growth and development: cold range limits of plants, number of insect generations Woodward 1987; Prentice et al. 1992
cold_stress cold sum over months of Tmin below frost_threshold °C × months winter severity: frost-sensitive plants, survival of overwintering stages Woodward 1987; Sakai & Larcher 1987
frost_months cold number of months with Tmin below frost_threshold months duration of frost: evergreen versus deciduous plants, length of dormancy or hibernation Woodward 1987; Sakai & Larcher 1987
continentality heat Tmean of the warmest month − that of the coldest °C annual temperature amplitude: oceanic versus continental species Rivas-Martínez et al. 2011
dry_months water months with P < 2 × Tmean (the dry season of Walter-Lieth diagrams) months length of the dry season: Mediterranean and savanna taxa, drought-deciduous plants Bagnouls & Gaussen 1953; Walter & Lieth 1960
lgp season length of the growing period: months with Tmean ≥ gdd_base and P ≥ PET / 2 months time when both warmth and water allow growth: crops and their wild relatives, annual plants FAO 1978
emberger water Emberger’s pluviothermic quotient 2000 P / (M² − m²), M and m in Kelvin – Mediterranean bioclimatic stages (arid to humid); lower = drier Emberger 1955; Daget 1977
ellenberg water Ellenberg’s quotient: Tmean of the warmest month / annual P × 1000 °C/mm × 1000 humidity gradient of temperate forests: beech dominates below about 30, oaks above Ellenberg 1963; Fang & Lechowicz 2006
kira_warmth heat Kira’s warmth index WI = Σ(Tmean − 5) over months with Tmean > 5 °C °C × months vegetation zones of East Asia (evergreen broad-leaved forest between 85 and 180) Kira 1945; Kira 1991
kira_coldness cold Kira’s coldness index CI = −Σ(5 − Tmean) over months with Tmean < 5 °C: zero or negative, as defined by Kira °C × months cold limit of evergreen broad-leaved trees in East Asia (about -10) Kira 1945; Kira 1991
ra light mean extraterrestrial radiation over the year (latitude only) MJ m⁻² day⁻¹ light at the top of the atmosphere; in a model a smooth stand-in for latitude Allen et al. 1998
ra_gs light extraterrestrial radiation received in the months with Tmean ≥ gdd_base MJ m⁻² light available while it is warm enough to grow: productivity at high latitudes and elevations this package; Allen et al. 1998
daylength_start light day length in the middle of the month in which the growing season starts hours photoperiod at the onset of growth: bud burst, flowering of long-day plants, end of diapause Körner & Basler 2010; Way & Montgomery 2015
daylength_end light day length in the middle of the month in which the growing season ends hours photoperiod at the end of the season: growth cessation and bud set of trees, start of diapause Bradshaw & Holzapfel 2007; Way & Montgomery 2015
daylength_gs light mean day length of the months with Tmean ≥ gdd_base hours photoperiod during growth: long-day versus short-day plants, daily activity time of diurnal animals Saikkonen et al. 2012
daylight_gs light hours of daylight in the months with Tmean ≥ gdd_base hours time for photosynthesis or foraging in the season: a short northern summer with long days against a long southern one this package; Saikkonen et al. 2012
daylength_max light day length on the summer solstice (latitude only; 24 = midnight sun) hours the longest day: species that need a critical day length to flower or to breed; like ra a stand-in for latitude Allen et al. 1998; Bradshaw & Holzapfel 2007
days_to_solstice light days from the start of the growing season to the summer solstice (negative = it starts later) days share of the season on lengthening days: phenological timing, species whose flowering is triggered before the solstice this package; Körner & Basler 2010

⚑ = flagged as a composite variable (see 4.2 below); flagged variables are left out by default.

“Useful for” gives examples of the questions an index was made for or is commonly used in; it is not a limit on its use. “Source” is the origin of the index or of its ecological use (full references in ?climate_indices); “this package” marks definitions that are ours.

Six of the indices for a synthetic climate
Six of the indices for a synthetic climate

All unflagged indices from monthly data (42) are computed by default. Choose some by name or by group (the Group column) with climate_index_names():

climate_index_names()                       # all names, without the flagged
climate_index_names(flagged = TRUE)         # with bio8, bio9, bio18, bio19, sri, synchronicity
climate_index_names(table = TRUE)           # group, meaning, unit, relevance, source, flag
climate_indices(tmax, tmin, prec, indices = climate_index_names("water"))
climate_indices(tmax, tmin, prec, indices = c("cold", "gdd"))   # a group and a name
climate_indices(tmax, tmin, prec, indices = climate_index_names(drop = "light"))

The indices are computed from monthly means, so gdd, lgp, frost_months, cold_stress, dry_months and the day-length indices of the growing season approximate the daily quantities (days_to_solstice to about one or two weeks). Several are correlated with each other and with bioclim variables; let select_variables() choose among them, and variable_relevance() tell which ones the species responds to.

Light and day length. Day length needs no extra data: it follows from latitude and the day of the year. ra and daylength_max depend on latitude alone, so in a model they stand in for latitude. The other light indices combine latitude with the temperature season (when it is warm enough to grow, gdd_base), so they differ between a mountain and its foreland and change with the climate of another period: the photoperiod when growth starts (daylength_start) and ends (daylength_end), the mean day length and the hours of daylight of the season (daylength_gs, daylight_gs), and how long before the summer solstice the season starts (days_to_solstice). They are meant for photoperiod-sensitive organisms (bud burst and bud set of trees, flowering of long-day plants, diapause of insects), and can be useful outside niche modelling, e.g. in phenology or growth models.

1. Get the monthly files. They can be downloaded automatically from CHELSA V2.1 (no account needed). With extent, only your region is read from the global files over the internet and saved, with the original values, scale and offset:

# present climate (1981-2010), 4 variables x 12 months
download_chelsa_monthly("chelsa_monthly", extent = c(-170, -30, -56, 72))
# future: any period, GCM and scenario
for (gcm in c("IPSL-CM6A-LR", "MPI-ESM1-2-HR", "UKESM1-0-LL"))
  for (ssp in c("ssp126", "ssp370", "ssp585"))
    download_chelsa_monthly("chelsa_monthly", period = "2071-2100",
                            gcm = gcm, ssp = ssp, extent = c(-170, -30, -56, 72))

A large region still means a large download (each global file is about 110 MB, and at least the full rows of the region are read; 48 files per period and scenario). Interrupted downloads continue where they stopped. You can also download the files by hand from chelsa-climate.org (Downloads → V2.1 → climatologies: tasmax, tasmin, tas, pr for months 01–12), or use WorldClim monthly tmax, tmin, tavg, prec; any 12-layer monthly data in °C and mm/month work. Cite CHELSA (Karger et al. 2017) when you use it. Every download function of preENM also adds a row per file to preENM_sources.csv in its folder (source, version, address, extent read, date and preENM version), so that the data can be cited exactly.

2. Compute the indices.

f <- function(v, ...) monthly_files("chelsa_monthly", v, must_contain = c(...))
ci <- climate_indices(tmax = f("tasmax", "1981-2010"), tmin = f("tasmin", "1981-2010"),
                      prec = f("pr", "1981-2010"), tmean = f("tas", "1981-2010"),
                      path = "indices", prefix = "CHELSA_1981-2010_")

# the same for every future scenario
for (gcm in c("ipsl-cm6a-lr", "mpi-esm1-2-hr", "ukesm1-0-ll"))
  for (ssp in c("ssp126", "ssp370", "ssp585"))
    climate_indices(f("tasmax", gcm, ssp), f("tasmin", gcm, ssp),
                    f("pr", gcm, ssp), tmean = f("tas", gcm, ssp),
                    path = "indices", prefix = paste0("CHELSA_", gcm, "_", ssp, "_"))

Existing output files are kept, so interrupted runs continue. Compute on the original longitude/latitude grid (cut to your region with crop_rasters() if you downloaded global files) and project the results afterwards if you need another projection: that is faster than projecting 48 monthly layers, and the indices are computed from unsmoothed values. Then add the new variables to sample_environment() / select_variables() like any other layer.

3. The same indices for the past. CHELSA-TraCE21k (Karger et al. 2023) gives monthly tasmax, tasmin and pr for every century of the last 22,000 years at about 1 km, so all indices can also be computed for, say, the Last Glacial Maximum or the Younger Dryas, on the same grid as the present. download_chelsa_trace21k() gets the files, for a region if you give extent:

trace21k_time(c(0, 12, 21))        # ka BP -> time id: 20, -100, -190
download_chelsa_trace21k("trace_monthly", kyr_bp = c(0, 12, 21),
                         extent = c(-26, 74, 38, 82))

for (id in c(20, -100, -190)) {
  f <- function(v) monthly_files("trace_monthly", v,
                                 must_contain = paste0("_", id, "_V1"))
  climate_indices(f("tasmax"), f("tasmin"), f("pr"),     # no tas: (tmax + tmin) / 2
                  path = "indices", prefix = paste0("TraCE21k_", id, "_"))
}

# the 19 bioclimatic variables of the same time steps
download_chelsa_trace21k("trace_bio", vars = "bio", kyr_bp = c(0, 12, 21),
                         extent = c(-26, 74, 38, 82))

Compare the past with the present of the same source (time step 0 ka BP) or use an anomaly (sample_environment(anomalies = ...)), so that differences between data sources are not read as climate change. Day length is computed for today’s orbit; at 21 ka BP the difference is small compared with the monthly resolution, but it is an approximation. Check the units of the downloaded files once (terra::rast(file)): temperatures are stored in tenths of Kelvin, which climate_indices() recognises.

Units. Temperatures must be in °C and precipitation in mm/month. CHELSA V2.1 stores temperature as Kelvin × 10 with a scale and offset in the file, which terra applies on reading: the values are already °C, so do not divide them by 10. climate_indices() checks this: Kelvin is converted, and values that look divided by 10 stop with an explanation.

Formulas (all of them in ?climate_indices): saturation vapour pressure e(T) = 0.6108 exp(17.27 T / (T + 237.3)); VPD = (e(Tmax) + e(Tmin)) / 2 − e(Tmin); PET = 0.0023 × 0.408 × Ra × (Tmean + 17.8) × √(Tmax − Tmin) mm/day, with extraterrestrial radiation Ra (MJ m⁻² day⁻¹) from latitude and the mid-month day (FAO-56 eq. 21; 0.408 converts it to mm of water); summer quarters are any three consecutive months, including December–February.

Both are approximations from monthly means. VPD takes Tmin as the dew point, so it is not the monthly mean of daily VPD and uses no humidity data. Hargreaves-Samani PET uses no humidity, wind or measured radiation, so PET, cmd and aridity are not equivalent to FAO Penman-Monteith values.

4.2 Composite bioclimatic variables and smooth substitutes

bio8 (mean temperature of the wettest quarter), bio9 (of the driest quarter), bio18 (precipitation of the warmest quarter) and bio19 (of the coldest quarter) combine temperature and precipitation over a quarter that is chosen anew in every cell. Where two quarters are nearly equally wet or warm, neighbouring cells pick different quarters, and the variable jumps by many degrees or hundreds of millimetres along a line that has no climatic meaning (Booth 2022, Austral Ecology 47, 1506–1514). The artefacts are regional, often in equatorial and bimodal-rainfall areas, and Booth advises to check the maps of the study area before use rather than drop the variables everywhere. preENM’s sri (bio18 / bio12) and synchronicity (based on the months of the maxima) share the problem.

These six variables carry a flag in climate_index_names(table = TRUE). climate_index_names() leaves them out unless flagged = TRUE, with a message the first time; climate_indices() computes them when asked by name, with a message; and select_variables() warns when a top-ranked set contains one (it recognises the usual layer names, e.g. wc2.1_30s_bio_18 or CHELSA_bio8_1981-2010_V.2.1).

As substitutes, t_wet, t_dry, p_warm and p_cold keep the contrast of the four variables without choosing a quarter: every month counts, weighted by how wet, dry, warm or cold it is. They change smoothly where the quarters switch, so they can replace bio8, bio9, bio18 (and sri) and bio19 in a model. tp_correlation, the correlation of the 12 monthly temperatures with the 12 monthly precipitation sums, replaces synchronicity: +1 when the warm months are the wet ones, −1 when they are the dry ones, from the whole cycle and so without ties or switching months. They are our construction after Booth’s suggestions, not variables from the literature.

ci <- climate_indices(tmax, tmin, prec, indices = c("season", "bioclim"))
# flagged variables only on request (then check their maps)
climate_indices(tmax, tmin, prec, indices = c("bio8", "bio18"))
bio8 switches where the wettest quarter changes; its smooth substitute t_wet does not
bio8 switches where the wettest quarter changes; its smooth substitute t_wet does not

4.3 Which climate product? Comparing sources before choosing one

WorldClim, CHELSA, regional atlases and reanalyses differ, most where stations are sparse. Models fitted with different products differ too, and some algorithms are more sensitive to the choice than others (Rodríguez-Rey & Jiménez-Valverde 2024, Ecological Informatics 79, 102387). If you have downloaded two or more products, climate_source_compare() shows how exposed your data are before you commit to one. It reads every product at the records and at a sample of cells of M, only at those points, and reports per variable:

  • agreement (Lin’s concordance correlation, graded after McBride 2005);
  • Pearson and Spearman correlation;
  • the systematic offset and the RMSE, in units and in SD of the reference;
  • the overlapping index of the two distributions and the range covered;
  • whether the correlations among the variables, which guide variable selection, are the same in each product (Mantel r);
  • where the products disagree.
wc <- terra::rast(list.files("worldclim", "bio_.*tif$", full.names = TRUE))
ch <- terra::rast(list.files("chelsa", "bio.*tif$", full.names = TRUE))
cs <- climate_source_compare(list(WorldClim = wc, CHELSA = ch), records,
                             m = m$m, reference = "CHELSA")
cs                                       # IN SHORT, exposure per variable
plot_climate_sources(cs)                 # agreement, correlation, offset
plot_climate_sources(cs, "map", variable = "bio12", file = "bio12_disagreement")
plot_climate_sources(cs, "scatter")      # product against reference
plot_climate_sources(cs, "density")      # the two distributions
write_climate_sources(cs, "climate_sources")

Layer names in the usual bioclim schemes (bio_01, wc2.1_30s_bio_1, CHELSA_bio1_1981-2010_V.2.1) are matched automatically; other layers need the same names in every product. The map shows the standardised difference at the cells of M, with the records marked and the 5% of cells with the largest disagreement ringed. It shows whether the records sit where the products disagree.

Where agreement is poor, fit the model with each product and compare the results, prefer the product validated for your region, or drop the variable if others carry the same information. An offset of more than 3 SD usually means different units (°C against kelvin, values × 10).

Disagreement between two climate products
Disagreement between two climate products

4.4 Terrain variables

At fine grain, terrain shapes the microclimate, moisture and soils that climate grids miss; for plants, especially in mountains, terrain and remote-sensing variables add to climate (Schwager & Berg 2021, Basic and Applied Ecology 54, 1–13). topo_indices() derives them from an elevation raster. They form the terrain group of climate_index_names(table = TRUE), so climate_index_names("terrain") lists them and the layers join any predictor stack for sample_environment() and select_variables().

Index Meaning Unit Source
slope steepest gradient degrees Horn 1981
northness, eastness cos / sin of aspect × sin of slope: 0 on flat ground −1 to 1 after Guisan et al. 1999
tri terrain ruggedness: root of the summed squared differences to the 8 neighbours m Riley et al. 1999
tpi_<r> topographic position: elevation minus the mean within radius r (one layer per radius); + ridges, − valleys m Weiss 2001
dev_<r> deviation from mean elevation: TPI / SD of elevation in the same window, comparable between hills and mountains – De Reu et al. 2013
twi topographic wetness index ln(a / tan β) with D8 flow accumulation – Beven & Kirkby 1979
hli heat load: potential annual direct radiation from slope, aspect and latitude MJ cm⁻² yr⁻¹ McCune & Keon 2002
ti <- topo_indices(dem, radius = c(0.5, 2, 5), radius_unit = "km",
                   path = "terrain", prefix = "DEM_")
Terrain indices from an elevation model (the volcano data of R)
Terrain indices from an elevation model (the volcano data of R)

Compared with terra::terrain(), topo_indices() adds:

  • TPI at several radii, in cells or km, with round windows on longitude/latitude grids;
  • its scale-free form, DEV;
  • a TWI whose upslope area is summed from true cell areas, so it is correct on longitude/latitude grids;
  • an HLI that uses each cell’s latitude and folds aspect by hemisphere, so south-west slopes are warmest in the north and north-west slopes in the south.

The TWI needs the whole DEM in memory, so it stops above max_cells (clip or aggregate the DEM first). The other indices are computed in blocks and can be written straight to disk.

4.5 Soil variables

Soil is missing from climate grids, yet for plants it can matter as much as topography: in-situ soil chemistry (B-horizon C:N, exchangeable calcium) predicted forest understorey plants as well as topographic variables did (Roe et al. 2022, Journal of Biogeography 49, 753–766). download_soilgrids() fetches the mapped counterparts from SoilGrids 2.0 (Poggio et al. 2021, about 250 m): pH, organic carbon, nitrogen, CEC, clay, sand and silt by default, plus bulk density, coarse fragments and organic carbon density on request. It adds the C:N ratio and the depth to bedrock from SoilGrids 2017 (Shangguan et al. 2017; not mapped in SoilGrids 2.0). As with the CHELSA download, only your region is read from the global files. Values are converted to the usual units (pH, g/kg, %, cmol(c)/kg).

# top 5 cm (the default), on its own 250 m grid
soil <- download_soilgrids("soil", extent = c(5, 30, 45, 56))
# 5-15 cm, warped onto the climate grid (averaging the 250 m cells)
soil <- download_soilgrids("soil", depth = "5-15cm",
                           template = "chelsa/CHELSA_bio1_1981-2010_V.2.1.tif")
climate_index_names("soil", table = TRUE)   # meanings, units, sources

SoilGrids maps six depth intervals: 0–5, 5–15, 15–30, 30–60, 60–100 and 100–200 cm. The top one or two suit most plants. The layers are themselves predictions with large uncertainty where soil profiles are few: download stat = "Q0.05" and "Q0.95", or "uncertainty", to see where. Exchangeable cations, the strongest soil predictors in Roe et al., are not mapped, and pH is a poor indicator of fertility in acidic soils, so C:N and CEC are worth keeping alongside it. If the server cannot be reached, the function stops with an explanation; layers already downloaded are kept, and an interrupted run continues where it stopped.

5. Selecting predictor variables across periods and regions

Collinearity between predictors can change through time. A set that is uncorrelated today may be collinear at the Last Glacial Maximum or in 2070, or inside a mountain range, and a model projected there then rests on unstable relationships. select_variables() therefore searches every subset of the candidate variables. It keeps the sets uncorrelated in all periods (or scenarios) and regions, scores them on transferability, and returns a ranked list of sets for you to choose from on ecological grounds, instead of one automatic answer.

  1. sample_environment() draws area-proportional random cells from each data set (e.g. present, LGM, future scenarios), plus cells common to all. It can add anomaly (“delta”) data sets at those cells, and assigns cells to regions (polygons such as mountain ranges, or a grid of tiles).
  2. Screen: a set passes when every pair has |Spearman rho| < 0.8 and the rank-based VIF is at most 5 in every data set. Inside regions the limits are softer (0.85 and 10). Optionally, every set must contain at least one variable of each group, e.g. one temperature and one moisture variable. Only sets whose pairs are all compatible are enumerated (as cliques of the graph of compatible pairs), so the search stays exhaustive and fast with many candidates, as long as the limits rule out most pairs.
  3. Scores:
    • novelty: the share of cells of the target period outside present conditions (MESS < 0);
    • gradient_min: whether each variable keeps its spatial pattern between periods;
    • agreement_min: the agreement of two data sources for the same period;
    • worst_vif and regional_vif.
  4. Ranking: within each set size, the Pareto front and a transparent mean rank. There is no hand-made total score.
vars <- c("bio01", "bio04", "bio05", "bio06", "bio07", "bio10", "bio11",
          "bio12", "bio13", "bio14", "bio15", "bio16", "bio17")
regions <- sf::st_read("regions.gpkg")     # polygons, e.g. mountain ranges;
                                           # or tiles: list(x = c(-30, 20, 70), y = c(35, 60, 85))
es <- sample_environment(
  list(present = "M_area_present",         # folders, files or SpatRasters;
       YDS     = "M_area_12ka",            # layers are matched by name,
       LGM     = "M_area_21ka"),           # e.g. ..._bio01_... -> bio01
  vars = vars, regions = regions, n = 1e5, seed = 1,
  fix_scale = TRUE)    # same scale in all data sets (e.g. a layer stored x 10 in one of them)

vs <- select_variables(
  es, sizes = 3:6,
  targets = c("YDS", "LGM"),                     # periods scored for novelty
  require_one_of = list(
    temperature = c("bio01", "bio05", "bio06", "bio10", "bio11"),
    moisture    = c("bio12", "bio13", "bio14", "bio16", "bio17")),
  reference_sets = list(first_choice = c("bio04", "bio05", "bio06",
                                         "bio14", "bio15")))
vs                               # best sets, a summary in words, then the details
best_sets(vs, n = 10, size = 4)  # ranked sets of one size with their scores
recommend_sets(vs)               # the summary alone
vs$frequency                     # how often each variable is in good sets
vs$pairs                         # each pair: rho per data set, driver, ...
plot_variable_sets(vs)           # score card of the best sets
plot_variable_tree(vs)           # tree of the variables with the best sets below

# save the results
write.csv(best_sets(vs, n = 10), "best_variable_sets.csv", row.names = FALSE)
write_variable_selection(vs, "correlation", "species")   # all tables and figures

Printing vs shows the result in the order you need it: the best sets of every size, then in short a few sentences (the suggested set and how good it is, close alternatives, the sizes for which nothing passes and why, variables that the good sets share or that never pass, correlations that change between periods, what the regional screen excluded), then the details. The suggested set is the best-ranked one of the largest size that passes; treat it as a starting point and choose among the top sets on ecological grounds. If no set of a size passes, best_sets(vs, size = 4) returns no rows and says at which filter they were lost, e.g. that every combination of four variables contains a collinear pair.

Score card of the best sets
Score card of the best sets

In the score card each row is a set and each column a score, and * marks the Pareto front. The shading compares the passing sets of one size: darker = better, i.e. the lowest value in columns marked “lower is better” (novelty, VIF, correlations) and the highest in columns marked “higher is better”. Choose what it shows and save it:

plot_variable_sets(vs, sizes = 2:3, n = 4)       # sizes 2 and 3, 4 sets each
plot_variable_sets(vs, sizes = 3, n = "all")     # every passing set of size 3
plot_variable_sets(vs, file = "variable_sets.pdf")   # or .png, .svg
write_variable_selection(vs, "out", format = c("png", "pdf"))

plot_variable_sets(vs, type = "scatter") shows all passing sets on two scores instead.

Union tree with the best sets
Union tree with the best sets

In the tree, variables joined below the dashed line are collinear in at least one data set; these clusters are shaded alternately. Each row below the tree is one set (its size and rank on the left) and the dots mark its variables, so you can see that a set takes one variable from a cluster and which variables are interchangeable. The first row is in blue and its variables are in bold. Show your own choice next to the best set with plot_variable_tree(vs, c(best = best_sets(vs)$set[1], mine = "bio05 bio15 bio17")).

Regions. Each region of each data set is reported on its own line, so you can see where a correlation comes from:

correlation_by_region(vs)        # all candidate variables
#>  data_set      region cells screened max_abs_rho          pair pairs_above max_vif passes
#>   present        Alps 12350     TRUE       0.991 bio05 ~ bio10          21   310.2  FALSE
#>   present Carpathians  8120     TRUE       0.987 bio01 ~ bio10          19   270.8  FALSE
#>       LGM        Alps 11980     TRUE       0.994 bio12 ~ bio16          24   402.5  FALSE
#>   ...
correlation_by_region(vs, best_sets(vs)$set[1])   # the set you chose
#>  data_set      region cells screened max_abs_rho          pair pairs_above max_vif passes
#>   present        Alps 12350     TRUE       0.612 bio04 ~ bio15           0    2.31   TRUE
#>   present Carpathians  8120     TRUE       0.701 bio06 ~ bio14           0    2.87   TRUE
#>       LGM        Alps 11980     TRUE       0.823 bio05 ~ bio14           0    4.90   TRUE
#>   ...

(The numbers are illustrative.) The first table shows the whole pool, where nearly every region holds collinear pairs; the second shows a set, with passes for the regional limits. best_sets() gives for every set its largest regional correlation (regional_maxr) and the region where it occurs (worst_region), and vs$pairs the same for every pair (max_abs_regional, regional_driver). Regions with fewer than min_region_n sampled cells are listed with screened = FALSE and not used; draw more cells (n) or lower the limit to include them.

Ice and sea in past periods. Palaeoclimate layers usually have values under the ice sheets and over what was sea. Those cells are sampled like any other, and a region that was glaciated is screened as if it were land, which can exclude good sets for no reason. Leave such cells out per data set with exclude (polygons or a raster) or restrict a data set with keep, or leave a region out of the screen for one period:

es <- sample_environment(
  list(present = "M_area_present", YDS = "M_area_12ka", LGM = "M_area_21ka"),
  vars = vars, regions = regions, n = 1e5, seed = 1,
  exclude = list(YDS = "ice_12ka.gpkg",       # e.g. DATED-1 ice extents (Hughes et al. 2016),
                 LGM = "ice_21ka.gpkg"),      # or a glacier raster such as TraCE21k glz
  keep    = list(LGM = "land_21ka.tif"))      # optional: the land of that period

vs <- select_variables(es, sizes = 3:6,
                       skip_regions = "LGM | Scandes")   # or skip one region in one period

A raster mask takes every cell with a value other than NA and 0, so look at the layer first. Nothing is downloaded automatically: ice reconstructions differ between regions and authors, and the choice is yours. Without a mask, data sets whose names or files look like past periods (LGM, 21ka, TraCE21k time ids, …) give a warning; if your layers are already cut to the land of each period, switch it off with options(preENM.past_warning = FALSE). The summary also names the regions in which pairs are excluded only by the regional screen, which is where to look first.

Two sources for one period, and anomalies. If you have the calibration period from two sources (e.g. an observation-based climatology and the present-day step of the palaeoclimate model), add both and name them in agreement: variables on which the sources disagree are scored down. anomalies builds “delta” data sets at the sampled cells, the high-resolution present plus the model’s change:

es <- sample_environment(
  list(present = "M_area_present", model_present = "M_area_0ka",
       LGM = "M_area_21ka"),
  vars = vars, n = 1e5, seed = 1, fix_scale = TRUE,
  anomalies = list(LGM_delta = c(current = "present", past = "LGM",
                                 model_present = "model_present")),
  ratio_vars = c("bio12", "bio13", "bio14", "bio16", "bio17"))  # change as a ratio
vs <- select_variables(es, sizes = 3:6, targets = c("LGM", "LGM_delta"),
                       agreement = c("present", "model_present"))

For future climate, use the scenarios as data sets, e.g. list(present = ..., ssp126_2070 = ..., ssp585_2070 = ...). Every scenario then enters the screen, and novelty reports the worst one.

The figures above use simulated climate (thirteen layers in five groups of collinear variables, three periods, six regions).