The qda() function prints a quadratic discriminant function while lda() function print the discriminant functions based on the centered variable.
In R, the qda() and lda() functions are used for classification, but they are associated with different methods:
qda() – Quadratic Discriminant Analysis:
qda() stands for Quadratic Discriminant Analysis.
It is used when the assumption of equal covariance matrices across classes is not valid.
It allows for different covariance matrices for each class.
Assumes that the observations within each class are normally distributed.
Example usage:
library(MASS)
model_qda <- qda(Species ~ ., data = iris)
lda() – Linear Discriminant Analysis:
lda() stands for Linear Discriminant Analysis.
It assumes that the observations within each class are multivariate normally distributed with a common covariance matrix.
It is more computationally efficient when compared to qda().
Example usage:
library(MASS)
model_lda <- lda(Species ~ ., data = iris)
In summary, the key difference lies in the assumptions about the covariance matrices. If the assumption of equal covariance matrices is reasonable, lda() might be preferred due to its computational efficiency. However, if the assumption does not hold, qda() can be a better choice as it allows for different covariance matrices for each class. The choice between qda() and lda() depends on the underlying distributional assumptions of your data.