mlp_sdm: SDM fit with MLP

Description Usage Arguments Value Examples

View source: R/mlp_sdm.R

Description

Build a MLP species distribution model from the output from a operating model (or grid) using the neuralnet package. The model is fit with 3 neurons in the hidden layer (which is good for this particular simulation). If it gets much more complicated, can try different values. But training time increases exponentially with additional neurons. The variables are normalized to a common scale before training the MLPs. Models fit to both the presence (pres column) and log(abundance) are returned.

Usage

1
2
3
4
5
6
mlp_sdm(
  x,
  covariates = NULL,
  start.forecast.year = 2021,
  control = list(hidden = c(3), algorithm = "rprop+", threshold = 0.2)
)

Arguments

x

(required) An operating model as output from one of the operating model functions (such as sim <- SimulateWorld() OR list with meta$abund_enviro and grid from the operating model (sim$grid).

covariates

Covariates to use in the SDM. Must be in the operating model output (in the columns of x$grid). If left off, all covariates in x (in x$meta$covariates) are used.

start.forecast.year

The years before 'start.forecast.year' will be used for fitting (training data) and the years from 'start.forecast.year' onward are the forecasted years (testing data)

control

The control parameters for the 'neuralnet::neuralnet' call.

Value

A SDM object, which is a list with the presence and abundance fits and the meta data.

Examples

1
2
3
4
5
sim <- SimulateWorld(start.year=2015, n.year=20)
fit <- mlp_sdm(sim, "temp")$abundance
dat <- fit$data #data used for fit
dat$mlpAbun <- predict(fit, dat)
plot(dat$temp, dat$mlpAbun)

stephbrodie1/WRAP documentation built on Feb. 13, 2021, 12:55 a.m.