glmsel: Generalised linear models with variable selection

Description Usage Arguments Value Author(s) Examples

Description

glmsel is used to fit generalised linear models with optionally performing variable selection using stepwise regression, lasso or elastic net methods.

Usage

1
2
glmsel(formula, data=environment(), varsel=FALSE, criterion="AIC",
direction="backward", indices=NULL, train=0.3, family, enet.alpha=0.5)

Arguments

formula

an object of class "formula"; a symbolic description of the model to be fitted.

data

an optional data frame, list or environment containg the variables in the model. If not specified, the variables are taken from the current environment.

varsel

a method of variable selection to be used. The default is "FALSE". Available methods include: stepwise regression "step", LASSO "lasso", elastic net"enet".

criterion

when varsel="step", criterion allows to select a method of calculating statistic for model comparison. The default is "AIC". Less liberal, BIC penalty can be used by typing "BIC".

direction

the mode of stepwise search, can be one of "both", "backward", or "forward", with a default of "both". If the scope argument is missing the default for direction is "backward".

indices

vector of 0 and 1 values indicating which observations are to be used as train and test when varsel="lasso" or "enet".

train

if indices=NULL, the function will randomly assign observations as train and test. train specifies what percentage of data will be used as train observations. Can take values from 0.1 to 0.9.

family

a description of the error distribution and link function to be used in the model. This can be a character string naming a family function.

enet.alpha

The elastic net mixing parameter, with 0=a= 1. The penalty is defined as

(1-a)/2||β||\_{2}^2+a||β||_1

alpha=1 is the lasso penalty, and alpha=0 the ridge penalty. The default value is 0.5.

Value

A "glmsel" object is returned, for which print, plot and summary methods can be used.

Author(s)

Michal Knut 1105406k@student.gla.ac.uk.

Examples

1
2
3
4
data(bank)
glmsel(y~age+as.factor(job)+as.factor(marital)+as.factor(education)+as.factor(default)+balance
+as.factor(housing)+as.factor(loan)+as.factor(contact)+as.factor(day)+month+duration+campaign
+pdays+previous, data=bank, varsel="enet")

regsel documentation built on May 2, 2019, 1:44 p.m.

Related to glmsel in regsel...