Multivariate & ML · Classification

Linear Discriminant Analysis

Classify a categorical outcome from continuous predictors using Fisher's linear discriminant analysis: group means, discriminant scalings, confusion matrix with seeded k-fold CV accuracy, Wilks' la...

In the menus Multivariate & ML › Classification › Linear Discriminant Analysis

Also searched as lda discriminant analysis discriminant linear discriminant

When to use it

Predict which class (2+) an observation belongs to from numeric predictors when classes are roughly Gaussian with similar spreads, or to find the linear combinations of predictors that best separate the classes.

When not to: Classes have clearly different spreads/covariance structures (Box's M fails badly; use QDA instead), predictors are far from normal within classes even after checking, or the classification boundary is expected to be genuinely non-linear (LDA can only produce straight-line/plane boundaries).

Step by step

  1. Open it from the menu

    Click Multivariate & ML in the menu bar; under Classification choose Linear Discriminant Analysis.

  2. Fill in the form

    Choose the columns: Groups to predict, Columns that may explain it. The form lists only columns whose type fits each field.

  3. Check the options

    The options start at their defaults: Class priors, CV folds, Store discriminant scores. Change one only when your question needs it.

  4. Run the analysis

    Press Run analysis. The Result Card opens on its Results tab.

What to choose in the form

Fields of the Linear Discriminant Analysis form
Groups to predict Outcome requiredOne categorical or binary column. Categorical class label to predict (2+ classes).
Columns that may explain it Predictors requiredOne numeric column. Numeric predictor columns.
Class priorsPrior class probabilities: proportional to observed class frequencies, or equal across classes. Default: proportional.
CV foldsStratified k-fold cross-validation folds for an honest accuracy estimate (seeded, shuffled; 0 = off). Default: 5.
Store discriminant scoresInclude per-row LD1/LD2 scores and predicted classes in the result statistics. Default: off.

How to read the card

The Results tab starts with what to know first (rows left out, checks that did not pass), then the interpretation in words and the Key Results; charts and assumption checks follow further down. Learn More explains the method in plain words. Read a Result Card covers all four tabs.

What it assumes

Normality (of residuals, not of the raw data)

If it does not hold: LDA's linear decision boundaries are derived assuming each predictor is approximately normally distributed WITHIN each class; strong non-normality (skew, heavy tails) in one or more predictors makes the boundary and the reported classification accuracy less trustworthy, especially with small classes.

How to check: Shapiro-Wilk per predictor within each class, reported directly on the card, with predictors named and skipped when there are too few or too many rows to test.

Homogeneity of variance (homoscedasticity)

If it does not hold: LDA assumes every class shares the SAME covariance matrix (spread and correlation among predictors); when classes have genuinely different covariance structures, LDA's shared linear boundary is the wrong shape and QDA's per-class boundaries fit better.

How to check: Box's M test, reported directly on the card at a stricter alpha = .001 (Box's M is hypersensitive to large samples); reported honestly as 'could not be computed' when a class has too few rows or a singular covariance, rather than a false pass.

Independence of observations

If it does not hold: Rows must be independent (no repeated measures of the same subject in different rows); violated independence distorts both the fitted boundary and the cross-validated accuracy estimate.

How to check: Not checked by KernelStats: stated directly as a standing 'Independent observations' reminder.

A worked example

Classifying three penguin species from bill length, bill depth, flipper length, and body mass, with proportional priors and 5-fold cross-validation.

Result: In-sample accuracy = 98.8%, 5-fold cross-validated accuracy = 98.5% (fold SD 1.3 points); Wilks' lambda = 0.019, Rao's F(8, 672) = 528.9, p < .001; the in-sample confusion matrix shows the four errors are all between Adelie and Chinstrap, never involving Gentoo. Box's M rejects equal covariances (chi-square(20) = 76.8, p < .001).

The close in-sample/CV agreement suggests the model generalizes well, and the confusion matrix pinpoints which two species are hardest to tell apart, information a single pooled accuracy number would hide. The Box's M rejection says the shared-covariance assumption is strained; with classes this large, comparing against QDA's cross-validated accuracy is the sensible check.

From the Statistics Library.

The code tabs

Code gives this analysis as Python, R and MATLAB code (and SAS where the tab offers it), reading the data the way KernelStats did. Export sends the card to a report or to slides. See The Code tab.

Understand the statistics

Ask Oobi

Type one of these into Ask Oobi beside your data:

  • Can bill and flipper measurements tell penguin species apart, and which combination of measurements separates them best?
  • Explain the linear discriminant analysis (LDA) in plain words.
  • What does normality (of residuals, not of the raw data) mean?

Last reviewed November 16, 2026.

Report an unclear step