training: Estimate an Agent Model with Supervised Learning

Description Usage Arguments Value

View source: R/training.R

Description

training uses a caret::train or stats::glm algorithm to estimate an individual-level model and return a list where each element is either a list of with element of class "train" (if caret::train was used) or a list with each element of class "glm" if (if stat::glm was used).

Usage

1
2
3
4
training(trainData, features, Formula, sampling = FALSE,
  sampling_size = 1000, package = c("caretglm", "caretglmnet", "glm",
  "caretnnet", "caretdnn"), tune_length = 10, parallel = FALSE,
  cv_type = c("cv", "repeatedcv"))

Arguments

trainData

data.frame with each row (obervational unit) being an individual agent decision. With a column called "group" specifying which group of agg_patterns each obseravtion is in.

features

list of the variables (columns in data) to be used in the prediction Formula. As many elements in the list as we want discrete models for different times. Each element of the list is a character vector, with each element of the character vector being a feature to use for training an individual-level model.

Formula

list where each element is a length one character vector that specifies a formula, e.g. "y ~ x". The character vector makes sense in the context of the features and data. There are as many elements in the list as there are discrete models for different times.

sampling

optional logical vector length one, default is FALSE. If sampling == TRUE, we sample equal numbers of observations from each 'group' to reduce potential problems with the final estimated model being too affected by groups with more observations.

sampling_size

optional numeric vector length one specifying how many observations from each group that training should sample to train the model, default is 1000. Only applicable when sampling argument is set to TRUE.

package

optional character vector length one, default is "caretglm", "caretglmnet", "glm", "caretnnet", "caretdnn".

tune_length

optional numeric vector length one specifying how many rows for caret::train to create in design matrix of hyper-parameter sets.

parallel

optional logical vector length one, default is FALSE. Uses doParallel::registerDoParallel(). Should be FALSE when training() is being called from inside cv_abm(), which, by default, is already running in parallel. @param cores optional numeric vector length one.

cv_type

optional character vector length one, default is c("cv", "repeatedcv"). Passed on to caret::trainControl().

Value

Returns a list length k where each element of the list is an estimated model (estimated agent decision function). @export


JohnNay/eat documentation built on May 7, 2019, noon