Learn R Programming

binda (version 1.0.4)

binda: Binary Discriminant Analysis: Model Fit and Class Prediction

Description

binda trains a diagonal multivariate Bernoulli model. predict.binda performs corresponding class prediction.

Usage

binda(Xtrain, L, lambda.freqs, verbose=TRUE)
# S3 method for binda
predict(object, Xtest, verbose=TRUE, ...)

Arguments

Xtrain

A matrix containing the training data set. Note that the rows correspond to observations and the columns to variables.

L

A factor with the class labels of the training samples.

lambda.freqs

Shrinkage intensity for the frequencies. If not specified it is estimated from the data. lambda.freqs=0 implies no shrinkage (i.e. empirical frequencies) and lambda.freqs=1 complete shrinkage (i.e. uniform frequencies).

verbose

Report shrinkage intensities (binda) and number of used features (predict.binda).

object

An binda fit object obtained from the function binda.

Xtest

A matrix containing the test data set. Note that the rows correspond to observations and the columns to variables.

...

Additional arguments for generic predict.

Value

predict.binda predicts class probabilities for each test sample and returns a list with two components:

class

a factor with the most probable class assignment for each test sample, and

posterior

a matrix containing the respective class posterior probabilities.

Details

For detailed description of binary discriminant analysis as implented in binda see Gibb and Strimmer (2015).

References

Gibb, S., and K. Strimmer. 2015. Differential protein expression and peak selection in mass spectrometry data by binary discriminant analysis. Bioinformatics 31:3156-3162. <DOI:10.1093/bioinformatics/btv334>

See Also

binda.ranking.

Examples

Run this code
# NOT RUN {
# load "binda" library
library("binda")

# training data set with labels
Xtrain = matrix(c(1, 1, 0, 1, 0, 0,
             1, 1, 1, 1, 0, 0,
             1, 0, 0, 0, 1, 1,
             1, 0, 0, 0, 1, 1), nrow=4, byrow=TRUE)
colnames(Xtrain) = paste0("V", 1:ncol(Xtrain))
is.binaryMatrix(Xtrain) # TRUE
L = factor(c("Treatment", "Treatment", "Control", "Control") )

# learn predictor
binda.fit = binda(Xtrain, L)

# predict classes using new test data
Xtest = matrix(c(1, 1, 0, 1, 1, 1,
                 1, 0, 0, 0, 1, 1), nrow=2, byrow=TRUE)
colnames(Xtest) = paste0("V", 1:ncol(Xtest))

predict(binda.fit, Xtest)

# }

Run the code above in your browser using DataLab