Calculator
Example data table
| ID | A | B | C | D |
|---|---|---|---|---|
| S01 | 10 | 12 | 11 | 9 |
| S02 | 11 | 11 | 10 | 10 |
| S03 | 9 | 13 | 12 | 8 |
| S04 | 10 | 12 | 10 | 9 |
| S05 | 12 | 10 | 11 | 11 |
| S06 | 11 | 12 | 9 | 10 |
| S07 | 10 | 11 | 12 | 9 |
| S08 | 9 | 10 | 11 | 10 |
| S09 | 10 | 12 | 10 | 8 |
| S10 | 45 | 40 | 44 | 46 |
Formula used
- Scaling: each variable is optionally centered and scaled: z = (x − location) / scale.
- PCA model: compute covariance S, then solve S = P Λ Pᵀ.
- Scores: project rows: T = X·Pₖ, keeping k components.
- Reconstruction: X̂ = T·Pₖᵀ, residuals E = X − X̂.
- Hotelling’s T²: T²ᵢ = Σₐ (tᵢₐ² / λₐ).
- SPE (Q-residual): SPEᵢ = Σⱼ eᵢⱼ².
- Limits: T² uses an F-approximation; SPE uses Jackson–Mudholkar with a normal quantile.
How to use this calculator
- Paste a numeric dataset into the text area.
- Confirm whether you included a header and IDs.
- Pick a scaling method matching your measurement units.
- Select component mode and confidence level.
- Choose an outlier statistic and submit.
- Review flagged rows, then export CSV or PDF.
Why PCA reveals multivariate outliers
PCA compresses correlated variables into a few orthogonal components, so unusual combinations stand out even when single columns look normal. The calculator standardizes or robustly scales inputs, then builds a covariance model and projects each row into score space. In many operational datasets, the first 2–5 components capture most structure; setting a 0.95 variance target often keeps enough signal while filtering noise for dependable screening.
Preparing data for consistent results
Reliable detection starts with clean numeric columns and stable handling of missing values. Mean imputation preserves row count and is suitable when gaps are small and random. Dropping incomplete rows is safer when missingness is systematic. If variables use different units, standardization avoids one column dominating. For heavy-tailed measurements, median/MAD scaling reduces leverage from extreme points and improves interpretability across runs.
Interpreting T² and SPE together
Two statistics flag different anomaly types. Hotelling’s T² measures how far a point lies within the retained component subspace, scaled by eigenvalues. It is sensitive to strong shifts along major patterns. SPE (Q‑residual) measures reconstruction error and highlights points that do not fit the PCA model, even if their scores are moderate. Using the union rule catches more anomalies; intersection is stricter.
Choosing component count and confidence
Component choice trades sensitivity against overfitting. Too few components inflate SPE because normal structure is left in the residuals; too many can absorb anomalies into the model. Auto selection by cumulative variance is a pragmatic default, while fixed k helps align monitoring periods. Confidence levels such as 0.99 or 0.995 typically surface the most extreme cases; 0.95 is useful for exploratory triage with manual review.
Operationalizing outputs and review
After computation, export CSV for downstream filtering, dashboards, or incident tickets, and export PDF for audits or stakeholder summaries. For streaming use, keep a consistent training window, and periodically retrain PCA when seasonality or product mix shifts noticeably materially. Track the limits, scaling choice, and component settings alongside each run so changes in policy are explicit. When a row is flagged, compare its scores and loadings to see which variables drove separation. Re-run with robust scaling to confirm stability before taking corrective action.
FAQs
What format should my dataset use?
Paste delimited text with one row per observation and numeric columns. You may include a header row and an ID column. Comma, semicolon, and tab separators work, and auto-detect helps when you are unsure.
How many variables and rows work best?
PCA is more stable with at least 10–20 rows and two or more variables. For smooth performance in the browser, keep variables modest; the calculator can cap columns using the performance guard while still producing reliable screening.
Which scaling option should I choose?
Use standardization when units differ, center-only when units match and scale is meaningful, and robust scaling when outliers or heavy tails are expected. No scaling is appropriate only when variables are already comparable and well-behaved.
What is the difference between T² and SPE?
T² measures distance within the retained component subspace, highlighting extreme scores along dominant patterns. SPE measures residual error from reconstruction, highlighting rows that do not fit the PCA model. Using both improves coverage of different anomaly types.
How do I choose the confidence level?
Start at 0.99 for focused detection and review the top flagged rows. If you need broader triage, try 0.95. For highly regulated or costly false positives, use 0.995 or 0.999 and verify with domain rules.
Can I use this for ongoing monitoring?
Yes. Keep preprocessing, component settings, and training window consistent across runs. Export CSV for your pipeline and log the limits. Retrain the PCA model periodically when the process changes, and compare trends in T² and SPE.