computeMemory: Quantifies ecological memory with Random Forest.

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Takes the oputput of prepareLaggedData to fit the following model with Random Forest:

p_{t} = p_{t-1} +...+ p_{t-n} + d_{t} + d_{t-1} +...+ d_{t-n} + r

where:

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
computeMemory(
 lagged.data = NULL,
 drivers = NULL,
 response = "Response",
 add.random = TRUE,
 random.mode = "autocorrelated",
 repetitions = 10,
 subset.response = "none",
 min.node.size = 5,
 num.trees = 2000,
 mtry = 2
 )

Arguments

lagged.data

a lagged dataset resulting from prepareLaggedData. See palaeodataLagged as example.

drivers

a character string or vector of character strings with variables to be used as predictors in the model (i.e. c("Suitability", "Driver.A")). Important: drivers names must not have the character "_".

response

character string, name of the response variable (typically, "Response_0").

add.random

if TRUE, adds a random term to the model, useful to assess the significance of the variable importance scores.

random.mode

either "white.noise" or "autocorrelated". See details.

repetitions

integer, number of random forest models to fit.

subset.response

character string with values "up", "down" or "none", triggers the subsetting of the input dataset. "up" only models memory on cases where the response's trend is positive, "down" selectes cases with negative trends, and "none" selects all cases.

min.node.size

integer, argument of the ranger function. Minimal number of samples to be allocated in a terminal node. Default is 5.

num.trees

integer, argument of the ranger function. Number of regression trees to be fitted (size of the forest). Default is 2000.

mtry

integer, argument of the ranger function. Number of variables to possibly split at in each node. Default is 2.

Details

This function uses the ranger package to fit Random Forest models. Please, check the help of the ranger function to better understand how Random Forest is parameterized in this library. This function fits the model explained above as many times as defined in the argument repetitions. To test the statistical significance of the variable importance scores returned by random forest, on each repetition the model is fitted with a different r (random) term. If random.mode equals "autocorrelated", the random term will have a temporal autocorrelation, and if it equals "white.noise", it will be a pseudo-random sequence of numbers generated with rnorm, with no temporal autocorrelation. The importance of the random sequence (as computed by random forest) is stored for each model run, and used as a benchmark to assess the importance of the other predictors used in the models. Importance values of other predictors that are above the median of the importance of the random term should be interpreted as non-random, and therefore, significant.

Value

A list with 4 slots:

Author(s)

Blas M. Benito <blasbenito@gmail.com>

See Also

plotMemory, extractMemoryFeatures

##'

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#loading data
data(palaeodataLagged)

memory.output <- computeMemory(
 lagged.data = palaeodataLagged,
 drivers = c("climate.temperatureAverage", "climate.rainfallAverage"),
 response = "Response",
 add.random = TRUE,
 random.mode = "autocorrelated",
 repetitions = 10,
 subset.response = "none"
)

str(memory.output)
str(memory.output$memory)

#plotting output
plotMemory(memory.output = memory.output)

memoria documentation built on May 17, 2019, 9 a.m.