# Faq how are Q residuals and Hotellings T2 calculated in PLS models

### Issue:

How are the Q-residuals and Hotelling's T^{2} values calculated for PLS models?

### Possible Solutions:

Q and T^{2} are done in PLS exactly the as they are for PCA (see the PLS_Toolbox manual for a description) except that the basis that is being used for T^{2} is the PLS loads rather than the PCA loads. For Q, we actually calculate the eigenvalues of the residual subspace and it is exactly the same as in PCA.

For T^{2}, there is an approximation made of the eigenvalues. If `Tcal`

is the column vectors of scores from your calibration model (extract from the `model.loads{1,1}`

field) :

f = diag(Tcal'*Tcal)/size(Tcal,1); f = sqrt(1./f);

OR you can use:

f = sum(Tcal.^2)./size(Tcal,1); f = sqrt(1./f);

Either method gives you `f`

, a normalized vector of lengths of each of your original scores. Next, you take each of those lengths and divide your new scores (`Tnew`

) by the corresponding length: (again, here are two methods of doing it)

Method 1:

T2 = sum( (Tnew * diag(f)).^2 ,2);

Method 2:

for j=1:length(f); Tnew(:,j) = Tnew(:,j)*f(j); end T2 = sum( Tnew.^2 ,2);

**Still having problems? Please contact our helpdesk at helpdesk@eigenvector.com**