Description Usage Arguments Value See Also Examples
A wrapper to run a BRT model using gbm.step
or gbm
with or without selecting the op[timal number of trees using gbm.perf
with parameter settings used in Bhatt et al. (2013). Covariate effect curves, relative influences and a prediction map on the probability scale are returned. A function to define regression weights can be specified through wt.fun
.
BRT models sometimes fail to converge and the gbm.step
implementation fails silently, returning NULL
. If method = 'step'
, runBRT
instead attempts to run the procedure max_tries
times and fails with an error if it still hasn't converged.
To run a BRT model without optimising the number of trees you can set method = 'gbm'
witha reasonable number of trees in n.trees
, which should be much faster.
At present, only method = 'step'
returns a model from which full validation statistics can be extracted.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | runBRT(data,
gbm.x,
gbm.y,
pred.raster = NULL,
gbm.coords = NULL,
wt = NULL,
max_tries = 5,
verbose = FALSE,
tree.complexity = 4,
learning.rate = 0.005,
bag.fraction = 0.75,
n.trees = 10,
n.folds = 10,
max.trees = 10000,
step.size = 10,
method = c('step', 'perf', 'gbm'),
family = 'bernoulli',
gbm.offset = NULL,
...)
|
data |
Input dataframe. |
gbm.x |
Index for columns containing covariate values. |
gbm.y |
Index for column containing presence/absence code (1s or 0s). |
pred.raster |
An optional |
gbm.coords |
Optional index for two columns (longitude then latitude) containing coordinates of records. This is required if you later want to calculate validation statistics using pair-wise distance sampling (setting |
wt |
An optional vector of regression weights, an index for a column giving regression weights or a function to create the weights from the presence/absence column. The default ( |
max_tries |
How many time to try and get gbm.step to converge before throwing an error. |
verbose |
Passed to |
tree.complexity |
Passed to |
learning.rate |
Passed to |
bag.fraction |
Passed to |
n.trees |
Passed to |
n.folds |
Passed to |
max.trees |
Passed to |
step.size |
Passed to |
method |
Whether to run the model using the |
family |
The probability distribution for the likelihood, passed to either the |
gbm.offset |
If |
... |
Additional functions to pass to |
A list containing four elements
model |
the fitted gbm model |
effects |
a list of effect curves with one element ofr each covariate |
relinf |
a vector of relative influence estimates for each covariate |
pred |
a |
coords |
a dataframe giving the coordinates of the training points (or |
gbm.step
, getRelInf
, getEffectPlots
, combinePreds
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 | # 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)
model <- runBRT(dat_all,
gbm.x = 4:6,
gbm.y = 1,
n.folds = 5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.