Description Usage Arguments Examples
Selects independent variables to be bred by genetic algorithm based on AIC fitness function
1 | selection(mm, model, parents, P)
|
mm |
Model matrix object with intercept and column for each independent variable specified in model |
model |
A formula object ( eg. data$y ~ x1 + x2^2 + x2:x3 ). Note: must specify data source for dependent variable |
parents |
Parents matrix of P rows indicating with 0 or 1 which variable selection |
P |
Population size for each generation |
1 2 3 4 5 6 7 8 9 10 11 12 13 | # simulate data
initData <- matrix( rnorm( 2500 , sd = c(1, 5, 7 , 100 , 40 ) ) , ncol = 5 , byrow = TRUE )
initOutcome <- 10 - 15 * initData[ , 1 ] + 2 * initData[ , 3 ] + 1.1 * initData[ , 5 ]
data <- data.frame( initData, initOutcome )
# define input parameters
P <- 30
parents <- initiation( C = 5 , P = P )
model <- data$initOutcome ~ X1 + X2 + X3 + X4 + X5
mm <- model.matrix( model , data = data )
# call selection function
selection( mm = mm , model = model , parents = parents , P = P )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.