DA {MVar} | R Documentation |
Linear (LDA) and quadratic discriminant analysis (QDA).
Description
Perform linear and quadratic discriminant analysis.
Usage
DA(data, class = NA, type = "lda", validation = "learning",
method = "moment", prior = NA, testing = NA)
Arguments
data |
Data to be classified. |
class |
Vector with data classes names. |
type |
"lda": linear discriminant analysis (default), or |
validation |
Type of validation: |
method |
Classification method: |
prior |
Probabilities of occurrence of classes. If not specified, it will take the proportions of the classes. If specified, probabilities must follow the order of factor levels. |
testing |
Vector with indices that will be used in data as test. For validation = "learning", one has testing = NA. |
Value
confusion |
Confusion table. |
error.rate |
Overall error ratio. |
prior |
Probability of classes. |
type |
Type of discriminant analysis. |
validation |
Type of validation. |
num.class |
Number of classes. |
class.names |
Class names. |
method |
Classification method. |
num.correct |
Number of correct observations. |
results |
Matrix with comparative classification results. |
Author(s)
Paulo Cesar Ossani
Marcelo Angelo Cirillo
References
Ferreira, D. F. Estatistica Multivariada. 2a ed. revisada e ampliada. Lavras: Editora UFLA, 2011. 676 p.
Mingoti, S. A. Analise de dados atraves de metodos de estatistica multivariada: uma abordagem aplicada. Belo Horizonte: UFMG, 2005. 297 p.
Rencher, A. C. Methods of multivariate analysis. 2th. ed. New York: J.Wiley, 2002. 708 p.
Ripley, B. D. Pattern Recognition and Neural Networks. Cambridge University Press, 1996.
Venabless, W. N.; Ripley, B. D. Modern Applied Statistics with S. Fourth edition. Springer, 2002.
Examples
data(iris) # data set
data = iris[,1:4] # data to be classified
class = iris[,5] # data class
prior = c(1,1,1)/3 # a priori probability of the classs
res <- DA(data, class, type = "lda", validation = "learning",
method = "mle", prior = prior, testing = NA)
print("confusion table:"); res$confusion
print("Overall hit ratio:"); 1 - res$error.rate
print("Probability of classes:"); res$prior
print("classification method:"); res$method
print("type of discriminant analysis:"); res$type
print("class names:"); res$class.names
print("Number of classess:"); res$num.class
print("type of validation:"); res$validation
print("Number of correct observations:"); res$num.correct
print("Matrix with comparative classification results:"); res$results
### cross-validation ###
amostra = sample(2, nrow(data), replace = TRUE, prob = c(0.7,0.3))
datatrain = data[amostra == 1,] # training data
datatest = data[amostra == 2,] # test data
dim(datatrain) # training data dimension
dim(datatest) # test data dimension
testing = as.integer(rownames(datatest)) # test data index
res <- DA(data, class, type = "qda", validation = "testing",
method = "moment", prior = NA, testing = testing)
print("confusion table:"); res$confusion
print("Overall hit ratio:"); 1 - res$error.rate
print("Number of correct observations:"); res$num.correct
print("Matrix with comparative classification results:"); res$results