# Faq how do I calculate my own T2 and Q limits

### Issue:

How do I calculate my own T^{2} and Q limits?

### Possible Solutions:

Confidence limits for Q residuals (also known as "SPE") and Hotellings T^{2} can be calculated using the commands:

>> residuallimi >> tsqlim

To calculate new residual limits, you must pass the eigenvalues for the residuals from the model. Assuming you have a model structure named "model":

>> qlimit = residuallimit(model.detail.reseig,cl);

where `cl`

is the confidence limit desired (in fractional confidence limit: 0.95 ). Note that for some model types, `.detail.reseig`

is not defined. In these cases, you'll need to calculate the raw residuals themselves. You can usually do this with `datahat`

, but you need to pass the original calibration data along with the model:

>> [xhat,residuals] = datahat(model,data); >> qlimit = residuallimit(residuals,cl);

To calculate new T^{2} limits, `tsqlim`

can be called very simply:

>> tsqcl = tsqlim(m,pc,cl);

where `m`

is the number of samples in the model, `pc`

is the number of PCs (or LVs) in the model, and `cl`

is the confidence limit desired.

Note that `tsqlim`

supplies the same result whether `cl`

is a percent or fractional but `residuallimit`

requires the fraction `cl`

.

To calculate limits for individual scores, see the related FAQ.

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