select: Select

Description Usage Arguments Details Value Examples

Description

This function performs a Genetic Algorithm based optimization on a user-supplied model.

Usage

1
2
Select(data, model=lm, methodBreed="oneScore", interaction=FALSE, Pop,
mutRate, scoreFunc=AIC, generations=10, ...)

Arguments

data

An object compatible with the model supplied by the user. The first column must be the dependent variable, the rest of the columns are explanatory variables. This is a data.frame() object under default parameters.

model

User specified fitting model. This must be compatible with the data and the scoreFunc parameters. The default is lm().

methodBreed

Method for how the second parental chromosomes are chosen for crossovers. This takes one of three values.

  • oneScore: (default) First parent is chosen by relative fitness, second parent is random.

  • twoScore: Both parents are chosen by relative fitness.

  • tournament: Parents are chosen using a tournament model. Effectively, chromosomes are grouped by score (2 groups used here), the best relative fitness score in each group is then chosen as parents for the next generation.

Pop

User defined population size. Otherwise, it is calculated as 1.5*(number of explanatory variables).

mutRate

Mutation rate used to increase diversity in the algorithm. If none is supplied, it is set as 1/(number of explanatory variables). If the model doesn't converge well, slowly increasing this parameter may help.

scoreFunc

Scoring function for the model. This function must be compatible with the output object of the model. Since the default is AIC(), all scores are treated as lowest=best. Therefore, user supplied score functions must have the lowest score as the best.

generations

How long to run the algorithm. Genetic algorithms typically don't have convergence critera, so this parameter is key for getting quality results.

...

Extra arguments to the model function.

interation

Interactions between explanatory variables are assumed independent (FALSE). If one wants more complex interactions to be explored, this parameter must be set to TRUE.

Details

This function attempts to maximize some score function over some model as supplied by the user. The default is to fit a linear model to the data and score each model using Aikake's Information Critera (AIC).

Value

A labeled list containing 3 parts.

Examples

1
2
3
4
5
6
#Tree data provided in R
select(data=trees, model=lm, methohdBreed="oneScore", interaction=FALSE, Pop=NULL, mutRate=NULL, scoreFunc=AIC, generations=25)

#Orange data has a categorical in the first column. Reorder to test with.
OrangeData <- data.frame(Orange[2:3], Orange[1])
Select(data=OrangeData, model=lm, methodBreed="twoScore", interaction=TRUE, scoreFunc=AIC, generations=50)

GilChrist19/GA documentation built on May 13, 2019, 5:32 p.m.