randomiser: Randomly reassign training and test samples

Description Usage Arguments Details Value Author(s) Examples

Description

This function is used to check for bias between a training and test data. It return a new index, which randomly re-assigns samples in the training data to the test dataset and vice versa.

Usage

1
randomiser(ntrain = 77, ntest = 19)

Arguments

ntrain

Numeric. A integer indicating the number of cases in the training dataset

ntest

Numeric. A integer indicating the number of cases in the test dataset

Details

Produces new indices that can be used for training/test datasets

Value

It returns a list, containing 2 vectors

train

A vector of length ntrain, which can be used to index a new training dataset

test

A vector of length ntest, which can be used to index a new test dataset

Author(s)

Aedin Culhane

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
randomiser(10,5)
train<-matrix(rnorm(400), ncol=20, nrow=20, dimnames=list(1:20,
paste("train",letters[1:20], sep=".")))
test<-matrix(rnorm(200), ncol=10, nrow=20, dimnames=list(1:20,
paste("test",LETTERS[1:10], sep=".")))
all<-cbind(train,test)

colnames(train)
colnames(test)
newInd<-randomiser(ntrain=20, ntest=10)

newtrain<-all[,newInd$train]
newtest<-all[,newInd$test]

colnames(newtrain)
colnames(newtest)

made4 documentation built on Nov. 8, 2020, 6:49 p.m.