multivariate_forecast_ml Takes matrix or data frame of responses and data frame of predictors and automates forecasts

multivariate_forecast_ml(
  response,
  predictors,
  model_type,
  n_forecast = 10,
  n_years_ahead = 1,
  control = list(alpha = seq(0.1, 0.9, by = 0.05), lambda = seq(0, 2, by = 0.05), ntree =
    seq(300, 2000, by = 100), mtry = seq(2, 10))
)

Arguments

response

A data frame of responses for the modeling (values to be forecast) containing a "time" column, "species" column, and "dev" column

predictors

A data frame of predictors used for forecasting recruitment

model_type

The type of model used to link predictors to forecasted recruitment. Can be "randomForest", "glmnet"

n_forecast

How many years to use as a holdout / test set

n_years_ahead

How many years ahead to forecast (defaults to 1) 1:n_vars variables, and then results are combined and sorted to remove duplicates

control

a list of the range and steps of tuning parameters to perform a grid search over. This includes alpha (defaults from 0.1 to 0.9, by steps of 0.05) and lambda (defaults from 0 to 2, by steps of 0.05) for glmnet; for randomForest this includes ntree (defaults from 300 to 2000, by steps of 100) and mtry (defaults from 2 to 10, by steps of 1)

Value

a list containing predictions and the variables used in making predictions