Learn R Programming

quantileDA (version 1.2)

theta.cl: A function to perform the quantile classifier for a given quantile probability

Description

Given a certain quantile probability, the function compute the quantile classifier on the training set and gives the predicted class labels in the training and test set.It also computes the training misclassification rate and the test misclassification rate, when the truth labels of the test set are available. When the quantile probability is 0.5 the function compute the median classifier.

Usage

theta.cl(train, test, cl, theta, cl.test = NULL)

Value

A list with components

cl.train

Predicted classification in the training set

cl.test

Predicted classification in the test set

me.train

Misclassification error in the training set

me.test

Misclassification error in the test set (only if cl.test is available)

Arguments

train

A matrix of data (the training set) with observations in rows and variables in columns. It can be a matrix or a dataframe.

test

A matrix of data (the test set) with observations in rows and variables in columns. It can be a matrix or a dataframe.

cl

A vector of class labels for each sample of the training set. It can be factor or numerical.

theta

The quantile probability. If 0.5 the median classifier is applied

cl.test

If available, a vector of class labels for each sample of the test set (optional)

Author

Christian Hennig, Cinzia Viroli

Details

theta.cl carries out quantile classifier for a given quantile probability.

See Also

See Also centroidcl

Examples

Run this code
data(ais)
x=ais[,3:13]
cl=as.double(ais[,1])
set.seed(22)
index=sample(1:202,152,replace=FALSE)
train=x[index,]
test=x[-index,]
cl.train=cl[index]
cl.test=cl[-index]
out.m=theta.cl(train,test,cl.train,0.5,cl.test)
out.m$me.test
misc(out.m$cl.test,cl.test)

Run the code above in your browser using DataLab