This is the main function to apply a gbm::gbm()
model to a data set.
Arguments
- input_data
Data frame to analyse. Must contain a POSIXct field called
date
.- vars
Explanatory variables to use. These variables will be used to build the
gbm::gbm()
model. Note that the model must include a trend component. Several variables can be automatically calculated (seeprepData()
for details).- pollutant
The name of the variable to apply meteorological normalisation to.
- sam.size
The number of random samples to extract from the data for model building. While it is possible to use the full data set, for data sets spanning years the model building can take a very long time to run. Additionally, there will be diminishing returns in terms of model accuracy. If
sam.size
is greater than the number of number of rows of data, the number of rows of data is used instead.- n.trees
Number of trees to fit.
- shrinkage
A shrinkage parameter applied to each tree in the expansion. Also known as the learning rate or step-size reduction;
0.001
to0.1
usually work, but a smaller learning rate typically requires more trees. Default is0.1
.- interaction.depth
Integer specifying the maximum depth of each tree (i.e., the highest level of variable interactions allowed). A value of
1
implies an additive model, a value of2
implies a model with up to 2-way interactions, etc. Default is5
.- bag.fraction
The fraction of the training set observations randomly selected to propose the next tree in the expansion. This introduces randomness into the model fit. If
bag.fraction < 1
then running the same model twice will result in similar but different.- n.minobsinnode
Integer specifying the minimum number of observations in the terminal nodes of the trees. Note that this is the actual number of observations, not the total weight.
- cv.folds
Number of cross-validation folds to perform. If
cv.folds > 1
thengbm::gbm()
, in addition to the usual fit, will perform a cross-validation, calculate an estimate of generalization error returned incv.error
.- simulate
Should the original time series be randomly sampled with replacement? The default is
FALSE
. Settingsimulate = TRUE
can be useful for estimating model uncertainties. In which case models should be run multiple times withB = 1
and a different value ofseed
e.g.seed = runif(1)
.- B
Number of bootstrap simulations for partial dependence plots.
- n.core
Number of cores to use for parallel processing.
- seed
Random number seed for reproducibility in returned model.
See also
testMod()
for testing models before they are built.
metSim()
for using a built model with meteorological simulations.
plot2Way()
, plotInfluence()
and plotPD()
for visualising built
models.