getConditionalEffectPlots: Combine conditional effect plots for ensemble BRT runs

Description Usage Arguments Value See Also Examples

Description

Given a list of BRT model bootstraps (each element an output from runBRT), return a list of matrices for, and optionally plot (plot), the mean conditional effect curve for each covariate in the model with confidence regions bounded by quantiles. There is also an option to specify (using hold) a covariate value for which conditional effect curves are generated. The ... argument is passed to plot and allows some customisation of the plotting outputs.

Usage

1
getConditionalEffectPlots(models, plot = FALSE, quantiles = c(0.025, 0.975), hold = NULL, value = NULL, ...)

Arguments

models

A list of BRT model bootstraps, each element being an output from runBRT.

plot

Whether to plot the overall conditional effect curves.

quantiles

Quantiles from which to calculate the uncertainty regions.

hold

Option to specify the column number of a covariate which is to be held at a particular value or level (if discrete) to generate the conditional effect curves.

value

Value or level (if discrete) at which to hold a specified covariate.

...

Additional arguments to be passed to plot.

Value

A list of matrices, one for each covariate, giving the mean and quantiles of the conditional effect curve as well as the conditional effect curves for each submodel. Optionally a plot as a side-effect.

See Also

plot, runBRT, quantile, getEffectPlots

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# load the data
data(occurrence)

# load the covariate rasters
data(covariates)

# load evidence consensus layer
data(consensus)

background <- bgSample(consensus,
                       n= 100,
                       replace=FALSE,
                       spatial=FALSE)

colnames(background) <- c('Longitude', 'Latitude')
background <- data.frame(background)

# combine the occurrence and background records
dat <- rbind(cbind(PA = rep(1, nrow(occurrence)),
                   occurrence[, c('Longitude', 'Latitude')]),
             cbind(PA = rep(0, nrow(background)),
                   background[ ,c('Longitude', 'Latitude')]))

# extract covariate values for each data point
dat_covs <- extract(covariates, dat[, c('Longitude', 'Latitude')])

# combine covariates with the other info
dat_all <- cbind(dat, dat_covs)

# let runBRT know that cov_c is a discrete variable 
dat_all$cov_c <- factor(dat_all$cov_c)

# get random bootstraps of the data (minimum 5 pres/5 abs)
data_list <- replicate(4,
                       subsample(dat_all,
                                 nrow(dat_all),
                                 replace = TRUE,
                                 minimum = c(5, 5)),
                       simplify = FALSE)

model_list <- sfLapply(data_list,
                       runBRT,
                       gbm.x = 4:6,
                       gbm.y = 1,
                       n.folds = 5)

effects <- getConditionalEffectPlots(model_list,
                                     plot = TRUE)

effects2 <- getConditionalEffectPlots(model_list,
                                     plot = TRUE, hold = 2, value = 2)

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