Linear Discriminant Analysis (LDA) Calculator: Group Separation and Classification Accuracy
Find the combinations of variables that best separate known groups, and see how accurately the groups can be predicted. Paste your data with a group column, pick the predictors, and get the discriminant functions, Wilks’ lambda, standardised coefficients, a classification table with leave-one-out cross-validated accuracy, an LD1–LD2 plot and predictions for new samples.
Predictor variables
- PriceFree, no login or sign-up needed
- Your dataProcessed in your browser, never uploaded
- Works onPhone, tablet or computer, any modern browser
- Made byDr. Muhammad Aammar Tufail, Codanics
- Published17 November 2026
- Last updated16 November 2026
📚 How to cite this tool
This tool is free. If it helped your thesis, paper, report or assignment, please cite it. It keeps the tools free and helps other students find them.
Tufail, M. A. (2026). Linear discriminant analysis calculator [Online tool]. Codanics. Retrieved 16 November 2026, from https://codanics.com/tools/linear-discriminant-analysis-calculator/
In-text citation: (Tufail, 2026) · Narrative: Tufail (2026)
The access date is today’s date, filled in automatically. Author: Muhammad Aammar Tufail. Published 17 November 2026.
How to use the Linear Discriminant Analysis Calculator
- Paste your table or use Paste from Excel / Upload CSV / Excel: one row per case, numeric predictor columns and one column with the known group (species, variety, disease status, region). The iris data is loaded as an example.
- Choose the group column and tick the predictors. Keep proportional priors if your sample reflects the real group sizes; choose equal priors if the groups were sampled in fixed numbers by design.
- Click Run discriminant analysis. Check Wilks’ lambda, the cross-validated accuracy and the discriminant plot, then read the standardised coefficients and the structure matrix to see which variables separate the groups.
- Copy the tables into Word, download the plot, classify new samples by pasting their values, and download the scores and posterior probabilities as CSV.
What is linear discriminant analysis?
Linear discriminant analysis (LDA, also called discriminant function analysis) does two things. It finds the linear combinations of your variables, the discriminant functions, that separate known groups as much as possible, and it uses them to classify cases into the groups. With g groups and p variables there are at most min(p, g − 1) functions.
It is used to show which traits distinguish varieties, species or populations, to classify samples by origin from chemical or spectral profiles, to predict diagnoses from clinical measurements, and as a follow-up to a significant MANOVA. It is related to PCA, but PCA ignores the groups, whereas LDA uses them to find the directions that separate them best.
How to read the output
- Wilks’ lambda: the share of variance not explained by group differences (0 = perfect separation, 1 = none). A significant F test means the group centroids differ.
- Eigenvalue, % of variance and canonical correlation: how much separation each function provides. Often the first function does most of the work.
- Standardised coefficients and structure matrix: which variables drive each function. The structure matrix (correlations) is more stable when predictors are correlated.
- Classification table: report the leave-one-out accuracy. Resubstitution accuracy reuses the same cases to build and test the rule and is too optimistic.
How LDA is calculated
The coefficients, proportion of trace, posterior probabilities and leave-one-out classifications match R’s MASS::lda() and lda(..., CV = TRUE) (the sign of each function is arbitrary). Wilks’ lambda and its F test match summary(manova(...), test = "Wilks").
Assumptions
- Predictors are roughly multivariate normal within each group.
- The groups have similar covariance matrices (otherwise quadratic discriminant analysis may classify better).
- No predictor is a perfect combination of the others, and each group has more cases than predictors (ideally at least 5 times as many).
How to report LDA
Learn the multivariate toolkit in R in the R with Aammar course, or start with the free ABC of statistics.
Frequently asked questions
What is the difference between LDA and logistic regression?
Both can predict group membership. LDA assumes normally distributed predictors with equal covariance matrices and handles three or more groups naturally; it also describes how the groups differ. Logistic regression makes fewer assumptions about the predictors and is often preferred for two groups with categorical or skewed predictors.
Why should I report the leave-one-out accuracy?
Resubstitution accuracy uses the same cases to build and to test the classification rule, so it overstates how well the rule would work on new cases. Leave-one-out cross-validation classifies each case with a rule built from all the other cases, which gives a more honest estimate.
What are prior probabilities?
Priors are the probabilities of each group before looking at the predictors. Proportional priors (the default in R and SPSS’s ‘compute from group sizes’) suit samples that reflect the population. Equal priors suit designs where you sampled a fixed number per group. Priors change the classifications but not the discriminant functions’ directions.
How many cases do I need?
Each group needs more cases than there are predictors, and a common rule of thumb is at least 20 cases in the smallest group and 5 cases per predictor. With small samples, the cross-validated accuracy will be much lower than the resubstitution accuracy, which is a warning sign of overfitting.
Can I use categorical predictors?
LDA is designed for continuous predictors. A binary predictor coded 0/1 is sometimes included, but the normality assumption no longer holds. For mostly categorical predictors, use logistic regression instead.
Is LDA the same as MANOVA?
They use the same matrices. MANOVA tests whether the group centroids differ (Wilks’ lambda here is the MANOVA test), and LDA goes on to describe the dimensions of the difference and to classify cases.
Is my data uploaded?
No. The analysis runs entirely in your browser. Pasted and uploaded data never leave your device.
Do I need to log in or create an account to use the Linear Discriminant Analysis Calculator?
No. There is no login, no sign-up and no email required. Open the page and start using it straight away, for free, on any device.
How do I cite this tool in my thesis or paper?
Use the citation box on this page. In APA 7th edition: Tufail, M. A. (2026). Linear discriminant analysis calculator [Online tool]. Codanics. Retrieved [date you used it], from https://codanics.com/tools/linear-discriminant-analysis-calculator/. BibTeX, RIS (EndNote, Mendeley, Zotero), MLA, Harvard, Chicago and Vancouver formats are also available.
Free guides and courses from Codanics
More free tools
See all free Codanics tools → · Codanics on YouTube · WhatsApp channel