combinePreds: Combine multiple prediction rasters

Description Usage Arguments Value See Also Examples

Description

Given a multilayer raster preds where each layer is a single bootstrap or ensemble prediction, calculate mean, median and and quantile (specified by quantiles) rasters.

Usage

1
2
combinePreds(preds, quantiles = c(0.025, 0.975),
              parallel = FALSE, ncore = NULL)

Arguments

preds

A RasterBrick or RasterStack object, where each layer is a single prediction.

quantiles

A vector of length two giving the quantiles of the prediciton distribution to return.

parallel

Whether to run the function in parallel. The user can specify the number of cores to run on via the ncore argument, or if this is NULL and a snowfall cluster is running the existing cluster will be used. If parallel = TRUE but ncore is not provided and a snowfall cluster isn't running, only one core will be used.

ncore

If parallel = TRUE the number of cores to use, see parallel for details.

Value

A RasterBrick or RasterStack object (whichever preds was) giving the mean, median and as many quantiles as were requested (default 2) of the predictive distribution at each pixel.

See Also

RasterBrick, RasterStack, quantile

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# load a test raster
r <- raster(system.file("external/test.grd", package="raster"))
# generate multiple layers with random perturbations
preds <- lapply(1:10, function(i, raster) {
  raster[] <- raster[] + rnorm(ncell(raster), 0, 10 * sqrt(raster[] + 1))
  raster
}, r)

# turn them into a brick
preds <- brick(preds)

# combine them, returning the mean and the 10% and 90% quantiles
preds_comb <- combinePreds(preds, quantiles = c(0.1, 0.9))

# calculate the inter-quantile range
preds_comb[[5]] <- preds_comb[[4]] - preds_comb[[3]]
names(preds_comb)[5] <- 'iq_range'

# plot them
plot(preds_comb)

SEEG-Oxford/seegSDM documentation built on May 9, 2019, 11:08 a.m.