Description Usage Arguments Value References
View source: R/evolve_model_cv.R
evolve_model_cv
calls evolve_model
with varied numbers of
states and compares their performance with crossvalidation.
1 2  evolve_model_cv(data, measure, k, actions, max_states, seed, popSize,
pcrossover, pmutation, maxiter, run, parallel, verbose, ntimes)

data 
data.frame that has columns named "period" and "outcome" (period
is the time period that the outcome action was taken), and the rest of the
columns are predictors, ranging from one to three predictors. All of the
(35 columns) should be named. The period and outcome columns should be
integer vectors and the columns with the predictor variable data should be
logical vectors 
measure 
Optional length one character vector that is either:
"accuracy", "sens", "spec", or "ppv". This specifies what measure of
predictive performance to use for training and evaluating the model. The
default measure is 
k 
Optional numeric vector length one only relevant if cv==TRUE, specifying number of folds for crossvalidation. 
actions 
Optional numeric vector with the number of actions. If not provided, then actions will be set as the number of unique values in the outcome vector. 
max_states 
Optional numeric vector length one only relevant if

seed 
Optional numeric vector length one. 
popSize 
Optional numeric vector length one specifying the size of the GA population. A larger number will increase the probability of finding a very good solution but will also increase the computation time. This is passed to the GA::ga() function of the GA package. 
pcrossover 
Optional numeric vector length one specifying probability of crossover for GA. This is passed to the GA::ga() function of the GA package. 
pmutation 
Optional numeric vector length one specifying probability of mutation for GA. This is passed to the GA::ga() function of the GA package. 
maxiter 
Optional numeric vector length one specifying max number of
iterations for stopping the GA evolution. A larger number will increase the
probability of finding a very good solution but will also increase the
computation time. This is passed to the GA::ga() function of the GA
package. 
run 
Optional numeric vector length one specifying max number of consecutive iterations without improvement in best fitness score for stopping the GA evolution. A larger number will increase the probability of finding a very good solution but will also increase the computation time. This is passed to the GA::ga() function of the GA package. 
parallel 
Optional logical vector length one. For running the GA evolution in parallel. Depending on the number of cores registered and the memory on your machine, this can make the process much faster, but only works for Unixbased machines that can fork the processes. 
verbose 
Optional logical vector length one specifying whether helpful messages should be displayed on the user's console or not. 
ntimes 
Optional integer vector length one specifying the number of times to estimate model. Default is 1 time. 
Returns the number of states that maximizes the measure
, e.g.
accuracy.
Luca Scrucca (2013). GA: A Package for Genetic Algorithms in R. Journal of Statistical Software, 53(4), 137. URL http://www.jstatsoft.org/v53/i04/.
Hastie, T., R. Tibshirani, and J. Friedman. (2009). The Elements of Statistical Learning: Data Mining, Inference, and Prediction, Second Edition. 2nd ed. New York, NY: Springer.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.