select: select()

View source: R/select.R

selectR Documentation

select()

Description

Find the best covariates in X such that the regression on y by a specific type has a low fitness value.

Usage

select(
  X,
  y,
  fit.function = AIC,
  glm.family = "gaussian",
  operator = NULL,
  pop.size = 100,
  select.type = "tournament",
  mutate.rate = NULL,
  min_iter = 5,
  max_iter = 100,
  converge.thres = 0.01,
  verbose = 0
)

Arguments

X

m by n matrix of X as covariate

y

list of numbers; the variable to be regressed on

fit.function

a user-defined function; this function will give the fitness value of any given gene and X, and y variable. By defaut, it is the AIC.

glm.family

String; user-defined regression type, e.g. Gaussian for lm, binomial for logistic

operator

a user-defined function; this function determines how to mutate the genes. By default it is NULL.

pop.size

integer; population size

select.type

String; type for selection, rank or tournament

mutate.rate

double; rate for mutation, default to be 0.01

min_iter

integer; minimum number of iterations

max_iter

integer; maximum number of iterations

converge.thres

double; threshold to determine whether to stop iterating early. If it is 0.01, that means if the ratio of the change of mean of fitness value from last generation and the mean of fitness value from last generation < 0.01, then we finish our iterations early, ignoring the max_iter.

verbose

integer; determine the type of log to be printed.

Author(s)

Jiayang Nie

Examples

library(GA)
X = matrix(rnorm(120*100, 10, 5), 120, 100)
y = rowSums(X)
X_noise = matrix(rnorm(120*100, -10, 1), 120, 100)
X = cbind(X, X_noise)
test1 <- select(X,y, max_iter = 100, verbose=2)
test2 <- select(X,y, max_iter = 100, select.type="rank", verbose=2)
test1$HallOfFame$genes[,1]

jnieser/GeneticAlgorithmRPackage documentation built on March 19, 2022, 5:35 a.m.