select: Genetic Algorithm for Variable Selection

Description Usage Arguments Examples

Description

A genetic algorithm for variable selection in regression problems

Usage

1
select(data, model, conv_criterion = 1e-07, steps = 50)

Arguments

data

The input data in the form of a dataframe. Each row is one entry with columns as different variables and the last column as the outcome.

model

A formula object ( eg. data$y ~ x1 + x2^2 + x2:x3 ). Note: must specify data source for dependent variable

conv_criterion

Convergence criterion

steps

Maximum number of steps to run GA

Examples

 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 ]

# define input parameters
data <- data.frame( initData, initOutcome )
model <- data$initOutcome ~ X1 + X2 + X3 + X4 + X5

# call select function
GAresults <- select( data = data , model = model )

# plot convergence results
plot( GAresults[[ 2 ]] , pch = 16 , cex = 0.75 , xlab = "Step" , ylab = "Convergene Criterion")

WaverlyWei/GA documentation built on May 28, 2019, 6:41 a.m.