21 Aug 2022 · 7 min read
LDA vs QDA, with examples in R
Linear and Quadratic Discriminant Analysis are attractive because there is nothing to tune. Both come from a classical probabilistic model via Bayes' rule, and both assume the classes are drawn from Gaussian distributions. The entire difference between them is one assumption.
The shared setup
Start from Bayes' rule: the posterior probability that an observation belongs to class k is proportional to the class prior times the class-conditional density. Assume that density is Gaussian, and you can write it out in closed form for each class. Since the denominator doesn't depend on the class, it drops out of the comparison.


LDA
Take the log of the posterior and assume every class shares the same covariance matrix. The quadratic terms cancel, and what remains is linear in x. The predicted class is whichever maximises that expression - and the decision boundaries between classes are straight lines (hyperplanes in higher dimensions).

QDA
Drop the shared-covariance assumption and let each class have its own. The quadratic terms no longer cancel, so the discriminant is quadratic in x and the boundaries become curves. More flexible, and more parameters to estimate - one covariance matrix per class instead of one overall.

Choosing between them
- Few observations per class: prefer LDA. Estimating a separate covariance matrix per class needs data you may not have.
- Clearly different class spreads: prefer QDA. Forcing a shared covariance will underfit visibly.
- Neither is a substitute for checking the Gaussian assumption. If the classes aren't remotely normal, both are the wrong tool.
library(MASS)
lda_fit <- lda(class ~ ., data = train)
qda_fit <- qda(class ~ ., data = train)
mean(predict(lda_fit, test)$class == test$class)
mean(predict(qda_fit, test)$class == test$class)Dataset 1 - two classes, unequal spread


Dataset 2 - four classes, similar covariance


Dataset 3 - four classes, heavier overlap


Dataset 4 - four dimensions, pairwise view



That's the honest summary: QDA is rarely much worse and often marginally better, and the gap only becomes interesting when class covariances genuinely differ. If you have plenty of data, start with QDA. If you don't, LDA's lower variance usually wins.