*Post by zhou **Post by Peter Perkins**Post by alkan alkaya*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.

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