univariate_forecast_ml.Rdunivariate_forecast_ml vector of responses and dataframe of predictors and automates
A data frame of responses for the modeling (values to be forecast) containing a "time" column and "dev" column
A data frame of predictors used for forecasting recruitment
The type of model used to link predictors to forecasted recruitment. Can be "randomForest", "glmnet"
How many years to use as a holdout / test set
How many years ahead to forecast (defaults to 1) 1:n_vars variables, and then results are combined and sorted to remove duplicates
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)
a list containing predictions, with elements
pred: the predictions
vars: the variable values used to fit the models
coefs: tidy summaries from each year:iteration. Zeros not included for glmnet
#' @examples response <- data.frame(time = 1:40, dev = rnorm(40))
predictors <- matrix(rnorm(400), ncol = 10) #colnames(predictors) = paste0("X",1:ncol(predictors)) predictors <- as.data.frame(predictors) predictors$time <- 1:40 lm_example <- univariate_forecast_ml(response, predictors, model_type = "glmnet", n_forecast = 10, n_years_ahead = 1)