Learn R Programming

CARRoT (version 3.0.2)

make_numeric_sets: Transforming the set of predictors into a numeric set

Description

Function which turns a set of predictors containing non-numeric variables into a fully numeric set

Usage

make_numeric_sets(a,ai,k,vari,ra,l,mode)

Value

Returns a list containing two objects: tr and test

tr

training set transformed into a numeric one

test

test set transformed into a numeric one

Arguments

a

An M x N matrix, containing all possible subsets (N overall) of the size M of predictors' indices; therefore each column of a defines a unique subset of the predictors

ai

array of indices of the array a

k

index of the array ai

vari

set of all predictors

ra

array of sample indices of vari

l

size of the sample

mode

'binary' (logistic regression), 'multin' (multinomial regression)

Details

Function transforms the whole set of predictors into a numeric set by consecutively calling function make_numeric for each predictor

See Also

make_numeric

Examples

Run this code
#creating a categorical numeric variable

a<-t(rmultinom(100,1,c(0.2,0.3,0.5)))%*%c(1,2,3)

#creating an analogous non-numeric variable

c<-array(NA,100)
c[a==1]='red'
c[a==2]='green'
c[a==3]='blue'

#creating a data-set

b<-data.frame(matrix(c(a,rbinom(100,1,0.3),runif(100,0,1)),ncol=3))

#making the first column of the data-set non-numeric

b[,1]=data.frame(c)

#running the function

make_numeric_sets(combn(3,2),1:3,1,b,sample(1:100,60),100,"binary")

Run the code above in your browser using DataLab