SPSS command: SPSS DETECTANOMALY
Anomaly detection by peer groups in your browser
Anomaly detection flags cases that look unusual compared with similar cases.
Free · No account · Files stay on your device · Updated 18 October 2026
What it tells you
Crosstabs runs the SPSS DETECTANOMALY procedure on your device: it forms peer groups with TwoStep clustering, scores each case's deviation from its group, and lists the most anomalous cases with the variables that explain them.
- Each case's anomaly index: its deviation from its peer group divided by the group's average deviation.
- Which peer group each anomalous case belongs to and how large that group is.
- The variables that make each case unusual, with their impact, the case's value and the group norm.
- The norms (means, standard deviations, modes) of every peer group.
When to use it
Use it when
- Auditing a survey or customer file for suspicious records before analysis.
- Spotting respondents whose combination of answers is rare even when each answer alone is not.
Use something else when
- You need a single variable's outliers: a box plot or the Explore procedure is simpler.
- You need survey or frequency weights: the SPSS algorithm defines no case weights, so results are unweighted.
How to run it in Crosstabs
- 01
Open your data
Open a .sav, CSV or Excel file in the workspace and switch to Statistics mode. The file is read in your browser and never uploaded.
- 02
Choose Anomaly detection
In the Machine learning group, pick Anomaly detection (DETECTANOMALY).
- 03
Pick the analysis variables
Tick Scale analysis variables and Categorical analysis variables; optionally choose a Case identifier.
- 04
Set the options
Set the minimum and maximum number of peer groups, the anomaly list (percentage or fixed number), the cut point and the number of reasons; tick Include missing values to replace rather than drop missing values.
- 05
Run and download
Click Run, read the anomaly and reason lists, and download the anomaly index, peer group and impacts for every case as CSV.
Output tables explained
- Anomaly Case Index List
- The anomalous cases sorted by anomaly index; only cases above the cut point are listed.
- Anomaly Case Reason List
- For each anomaly, the reason variable, its impact (share of the deviation), the case's value and the peer-group norm.
- Scale Variable Norms
- Mean and standard deviation of each scale variable in each peer group.
- Reason Summary
- How often each variable appears as a reason and the range of its impact.
Assumptions and notes
- Peer groups come from TwoStep clustering with the log-likelihood distance, whose variance adjustment is σ²/m (m = 6 by default), with noise handling on.
- Continuous variables are treated as normal and categorical ones as multinomial within each group; the method is robust to moderate violations.
How the results are validated
An independent NumPy implementation of the DETECTANOMALY chapter reproduces peer groups, BIC values, every variable deviation index, group deviation index and anomaly index within 1e-9, and the anomaly and reason lists exactly, with listwise deletion, missing-value handling and the missing-proportion variable. Validation evidence
Questions
What anomaly index counts as unusual?
An index of 1 is an average deviation for the group. The default cut point is 2, twice the group's average; only cases above it are listed.
Why are my planted outliers not flagged?
If several extreme cases are similar to each other, TwoStep can give them their own small peer group, and within it they are not unusual. Check the case processing summary for small groups.
Are weights used?
No. As in SPSS, DETECTANOMALY ignores case weights.
Will the results match SPSS exactly?
On small files the clustering is exact. On large files TwoStep's pre-cluster tree depends on case order, so peer groups can differ from SPSS's.
Related procedures
- TwoStep ClusterTWOSTEP CLUSTER
- ExploreEXAMINE
- K-Means ClusterQUICK CLUSTER
- Automated Data Preparation (ADP)ADP
- Free SPSS alternative: full coverage list
Run Anomaly Detection (DETECTANOMALY) on your own data
Open a .sav, CSV or Excel file. Everything runs in your browser; the file never leaves your device.
SPSS is a trademark of IBM Corp. Crosstabs is not affiliated with or endorsed by IBM.