Description Usage Arguments Details Value Examples
A genetic algorithm to find "good" variable subsets based on internal PLS evaluation or a user specified evaluation function
1  genAlg(y, X, control, evaluator = evaluatorPLS(), seed)

y 
The numeric response vector of length n 
X 
A n x p numeric matrix with all p covariates 
control 
Options for controlling the genetic algorithm. See 
evaluator 
The evaluator used to evaluate the fitness of a variable subset. See

seed 
Integer with the seed for the random number generator or NULL to automatically seed the RNG 
The GA generates an initial "population" of populationSize
chromosomes where each initial
chromosome has a random number of randomly selected variables. The fitness of every chromosome is evaluated by
the specified evaluator. The default builtin PLS evaluator (see evaluatorPLS
) is the preferred
evaluator.
Chromosomes with higher fitness have higher probability of mating with another chromosome. populationSize / 2
couples each create
2 children. The children are created by randomly mixing the parents' variables. These children make up the new generation and are again
selected for mating based on their fitness. A total of numGenerations
generations are built this way.
The algorithm returns the last generation as well as the best elitism
chromosomes from all generations.
An object of type GenAlg
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19  ctrl < genAlgControl(populationSize = 100, numGenerations = 15, minVariables = 5,
maxVariables = 12, verbosity = 1)
evaluatorSRCV < evaluatorPLS(numReplications = 2, innerSegments = 7, testSetSize = 0.4,
numThreads = 1)
evaluatorRDCV < evaluatorPLS(numReplications = 2, innerSegments = 5, outerSegments = 3,
numThreads = 1)
# Generate demodata
set.seed(12345)
X < matrix(rnorm(10000, sd = 1:5), ncol = 50, byrow = TRUE)
y < drop(1.2 + rowSums(X[, seq(1, 43, length = 8)]) + rnorm(nrow(X), 1.5));
resultSRCV < genAlg(y, X, control = ctrl, evaluator = evaluatorSRCV, seed = 123)
resultRDCV < genAlg(y, X, control = ctrl, evaluator = evaluatorRDCV, seed = 123)
subsets(resultSRCV, 1:5)
subsets(resultRDCV, 1:5)

Generating initial population
Generating generation 1
Generating generation 2
Generating generation 3
Generating generation 4
Generating generation 5
Generating generation 6
Generating generation 7
Generating generation 8
Generating generation 9
Generating generation 10
Generating generation 11
Generating generation 12
Generating generation 13
Generating generation 14
Generating generation 15
Generating initial population
Generating generation 1
Generating generation 2
Generating generation 3
Generating generation 4
Generating generation 5
Generating generation 6
Generating generation 7
Generating generation 8
Generating generation 9
Generating generation 10
Generating generation 11
Generating generation 12
Generating generation 13
Generating generation 14
Generating generation 15
$`1`
[1] 1 5 6 7 13 16 19 20 25 37 43 47
$`2`
[1] 1 5 6 7 13 16 19 25 36 37 43
$`3`
[1] 1 5 6 7 13 16 19 25 36 37 43 46
$`4`
[1] 1 5 7 13 19 25 36 37 43 47
$`5`
[1] 1 5 6 7 13 16 19 20 25 36 37 43
$`1`
[1] 1 7 11 13 19 25 33 36 37 42 43 49
$`2`
[1] 1 7 11 13 15 19 25 33 36 37 42 43
$`3`
[1] 1 7 11 13 14 19 25 33 36 37 42 43
$`4`
[1] 1 7 11 13 19 25 37 42 43
$`5`
[1] 1 6 7 13 19 25 37 42 43
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.