
Project posterior-clustered environmental space onto a future climate scenario
Source:R/projectClustersBayes.R
projectClustersBayes.RdBayesian analogue of projectClusters(). The steps are:
Usage
projectClustersBayes(
bSDM_object,
posterior_clusters,
future_predictors,
current_predictors,
threshold_rasts,
planar_proj,
coord_wt = NULL,
mess_threshold = 0,
cluster_novel = TRUE,
n_novel_pts = 500,
n_sample_per_cluster = 50,
n_future_draws = NULL,
n_future_pts = 500,
nbclust_args = list(),
thresh_metric = "sensitivity"
)Arguments
- bSDM_object
Output list from
bayesianSDM().- posterior_clusters
Output list from
PosteriorCluster().- future_predictors
SpatRasterof future climate. Layer names must match those used inbSDM_object.- current_predictors
SpatRasterof current climate (used for MESS reference and MESS computation (raw units required).- threshold_rasts
Output list from
PostProcessSDM(), containing:$FinalRasters(aSpatRasterstack including a binary threshold layer) and$Threshold(a one-rowdata.frameof threshold metric values).- planar_proj
EPSG code or proj4 string for a planar projection in metres (same as used in the current analysis).
- coord_wt
Ignored. Coordinate weighting is read directly from
posterior_clusters$ScalingParams$coord_wtto guarantee the future feature space matches the scale the KNNs were trained on. The parameter is retained in the signature for backwards compatibility only.- mess_threshold
MESS values below this are treated as novel climate. Default
0.- cluster_novel
Logical, default
TRUE. IfTRUEand novel cells exist, cluster them independently with NbClust + KNN. IfFALSEnovel cells are left asNA.- n_novel_pts
Numeric, default
500. Number of points to sample from novel areas for independent clustering.- n_sample_per_cluster
Number of points to sample from each cluster (existing and novel) for the silhouette relationship analysis. Default
50.- n_future_draws
Integer. Number of posterior beta draws to use when computing future cluster-assignment stability. Defaults to the number of draws stored in
posterior_clusters$ScalingParams$beta_draws(i.e. however many were used inPosteriorCluster()), capped at100. Pass an explicit integer to override.- n_future_pts
Integer. Number of points to sample from the future suitable-habitat surface for the draw loop. These are analogous to the fixed sample points in
PosteriorCluster()and serve the same purpose: stability is computed on this point set, then painted to raster once via KNN. Default500.- nbclust_args
Named list of arguments forwarded to
NbClust::NbClust. Sensible defaults are set internally (min.nc = 2,max.nc = 10,method = "ward.D2",index = "all").- thresh_metric
Character. Default
"sensitivity". Thedismo::thresholdmetric used to cut the future SDM into a binary surface.
Value
A named list:
clusters_rasterSmoothed
SpatRasterof consensus cluster IDs.clusters_sfsfpolygons with columnID.suitable_habitatSpatRaster- binary suitable habitat under future conditions.novel_maskSpatRaster-1where MESS < threshold.messSpatRaster- raw MESS scores.stabilitySpatRaster- draw-based cluster-assignment stability under future climate. Fraction of posterior draws agreeing on each cell's modal cluster. Values in (0, 1); low values flag cells where beta uncertainty produces ambiguous cluster assignment in future space. Unlike the current-era stability surface, this is computed directly in future climate space and is not a transfer fromPosteriorCluster().changesdata.frame- per-cluster area and centroid-shift metrics.novel_similaritydata.frame- nearest existing cluster and mean silhouette width for each novel cluster. Zero-row if none.
Details
Rescale future predictors via
RescaleRasters_bayesto match the feature space thatPosteriorCluster()used when training the consensus KNN.Run
dismo::messto identify novel climate cells.Predict known-climate cells with the consensus KNN classifier from
PosteriorCluster().If novel cells exist and
cluster_novel = TRUE, cluster them independently withNbClust/ KNN (cluster_novel_areas).Sample points from every cluster (existing + novel), build a single tree, and extract nearest-existing-cluster relationships via silhouette (
analyze_cluster_relationships).Project future stability by replaying posterior beta draws on the future climate surface (
project_future_draws). Stability here is a genuinely forward-looking quantity: the fraction of draws in which each cell's modal cluster assignment was agreed upon. This sidesteps the concern of transferring a current-era stability surface trained in current climate space onto a future surface that may differ substantially.Polygonise and calculate area / centroid changes.
See also
projectClusters() for the elastic-net equivalent,
PosteriorCluster(), bayesianSDM()