Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PCA Q statistic (SPE) Hotelling T2

1,585 views
Skip to first unread message

alkan alkaya

unread,
Nov 19, 2009, 10:30:31 AM11/19/09
to
I want to use PCA (Principle component analysis) Q and T statistics test for fault detection control process. How can I use and how can I plot the Q or T2 statistics of the measured data?

Peter Perkins

unread,
Nov 22, 2009, 10:49:59 AM11/22/09
to
alkan alkaya wrote:
> I want to use PCA (Principle component analysis) Q and T statistics test for fault detection control process. How can I use and how can I plot the Q or T2 statistics of the measured data?

The PRINCOMP function in the Statistics Toolbox returns the T^2 statistics; the PCARES function returns residuals that are used to compute the Q statistics. Hope this helps.

alkan alkaya

unread,
Nov 23, 2009, 10:30:20 AM11/23/09
to
Peter Perkins <Peter....@MathRemoveThisWorks.com> wrote in message <hebmj7$m4f$1...@fred.mathworks.com>...

> alkan alkaya wrote:
> > I want to use PCA (Principle component analysis) Q and T statistics test for fault detection control process. How can I use and how can I plot the Q or T2 statistics of the measured data?
>
> The PRINCOMP function in the Statistics Toolbox returns the T^2 statistics; the PCARES function returns residuals that are used to compute the Q statistics. Hope this helps.


Thank you peter perkins,

I could see the T2 plot by using PRINCOMP function but I couldn't plot the Q statistic. I have 1024*4 matrix 4= variables,1024= samples. When I use PCARES function I have RESIDUAL=R with same dimension (1024*4). for Q statistic as I know Q=R'*R after this calculation Q matrix occurs with 4*4 dimension but I think It should be 1*1024 dimension in order to plot Q test like T2 testing. I think I miss something. Thanks for your help.

Peter Perkins

unread,
Nov 23, 2009, 4:02:09 PM11/23/09
to
alkan alkaya wrote:

> I could see the T2 plot by using PRINCOMP function but I couldn't plot the Q statistic. I have 1024*4 matrix 4= variables,1024= samples. When I use PCARES function I have RESIDUAL=R with same dimension (1024*4). for Q statistic as I know Q=R'*R after this calculation Q matrix occurs with 4*4 dimension but I think It should be 1*1024 dimension in order to plot Q test like T2 testing. I think I miss something. Thanks for your help.

I suspect what you want is diag(R*R'), or equivalently, sum(R.^2,2).

alkan

unread,
Dec 28, 2009, 3:44:09 AM12/28/09
to
On 23 Kasım, 23:02, Peter Perkins

I can calculate the confidence limit for T^2 test in matlab with
"T2Upper=p*(n-1)/(n-p)*finv(0.98,p,n-p); here p =PCs,n= sample number"
like this how can I calculate the confidence limits for Q test?

alkan alkaya

unread,
Dec 28, 2009, 3:47:03 AM12/28/09
to

a.m.r.pg-h...@student.lboro.ac.uk

unread,
Aug 15, 2013, 1:25:46 PM8/15/13
to
On Thursday, November 19, 2009 3:30:31 PM UTC, alkan alkaya wrote:
> I want to use PCA (Principle component analysis) Q and T statistics test for fault detection control process. How can I use and how can I plot the Q or T2 statistics of the measured data?

Just wanted to ask, what is SPE stands for?

zhou

unread,
Nov 19, 2014, 9:11:15 AM11/19/14
to
Peter Perkins <Peter....@MathRemoveThisWorks.com> wrote in message <hebmj7$m4f$1...@fred.mathworks.com>...
> alkan alkaya wrote:
> > I want to use PCA (Principle component analysis) Q and T statistics test for fault detection control process. How can I use and how can I plot the Q or T2 statistics of the measured data?
>
> The PRINCOMP function in the Statistics Toolbox returns the T^2 statistics; the PCARES function returns residuals that are used to compute the Q statistics. Hope this helps.

Now I have the same problem, I can't compute the Q statistics. Hope your help. Thank you very much.

Shashank

unread,
Aug 16, 2015, 1:26:06 AM8/16/15
to
"zhou " <zh_h...@163.com> wrote in message <m4i8dt$dqp$1...@newscl01ah.mathworks.com>...
I did this, please cross-check: I have a N by 2 data matrix 'A', 2 = variables = Voltage, current. I retained only the 1st principal component obtained from princomp. Then I got the residuals matrix 'residuals' from pcares(A,1); after that---- I did Qr = residuals'*residuals--this gave me a 2*2 matrix; For 98% confidence interval upper limit, i found Qalpha =P/2m*chi2inv(0.98,V):-
where, P = var(Qr(:,1)), m = mean (Qr(:,1)), V=(2*(m^2))/p;

Stephen Murray

unread,
Apr 4, 2017, 10:29:07 AM4/4/17
to
"zhou" wrote in message <m4i8dt$dqp$1...@newscl01ah.mathworks.com>...
I know this thread has lain fallow for a long time, but Ive been struggling with this myself, and because of the variety of different notation schemes and equations in different papers and books, Ive decided to try and pitch in.

Assume x is a data matrix with rows as observations, and columns as system variables. P is a loading matrix that can be calculated usign pca.m

In order to calculate the errors (e), you can use pcares.m, or alternatively:

e = x* (eye(size(x,2)) - P(:,1:N)*P(:,1:N)' ); % (use both and check result) N is number of retained components

Q = e*e' ; % this gives an nx1 vector of q-stat corresponding to each column

To find an upper control limit for Q:

theta1 = trace(e*e'/(size(x,1)-1));
theta2 = trace((e*e'/(size(x,1)-1)).^2);
theta3 = trace((e*e'/(size(x,1)-1)).^3);
h0 = 1 - (2*theta1*theta3)/(3*theta2^2);
ca=2.57; % standard deviate for alpha=0.01
Qa = theta1*( ca*sqrt(2*theta2*h0^2)/theta1 + 1 + (theta2*h0*(h0-1))/(theta1^2))^(1/h0);

To check if this works, compare your Q vector against Qa; youll expect about 2% of your results to be greater than Qa


Source: This Paper
http://www.ans.org/pubs/journals/nt/a_3240
Kaistha & Upadhyaya: Incipient Fault Detection and Isolation of Field Devices in Nuclear Power Systems Using Principal Component Analysis

Stephen Murray

unread,
Apr 4, 2017, 10:57:08 AM4/4/17
to
"Stephen Murray" wrote in message <oc0ajf$3n0$1...@newscl01ah.mathworks.com>...
CORRECTION
- dont use e, this is reserved by MATLAB, use something liuke err instead
- Q = e*e' ; should read Q = diag(e*e') ;

profess...@gmail.com

unread,
May 31, 2017, 5:23:14 PM5/31/17
to
Squared Prediction Error

Rafael Lima

unread,
May 31, 2017, 5:41:12 PM5/31/17
to
Mr. Murray,
you've wrote that:
"> > ca=2.57; % standard deviate for alpha=0.01"

Do you know which Matlab command does this calculation? I would like to compute ca for all "alphas" inside the interval [0 1] (most precisely: (0:0.01:1)).

Thank you in advance.

mastropie...@gmail.com

unread,
Mar 7, 2018, 3:42:23 AM3/7/18
to
ca=norminv(p,m,sigma); %%m=mean and sigma=standard deviation
0 new messages