n = number of observations
A = number of principal components
Xci = the standardized data for the ith observation
T2 Statistic
The T2 statistic for the ith observation is calculated as follows:
where PA is a matrix containing the first A eigenvectors and L is a diagonal matrix containing the first A eigenvalues.
The median and UCL for the T2 plot are calculated as follows:
To calculate the median, use q = 0.5. To calculate the UCL, use q = (1 - α).
The vector of T2 contribution statistics for the ith observation is calculated as follows:

Help created on 7/12/2018