Takeoff points are calculated essentially as described in the reference below.
The steps are:
1) Fitting a linear model to background cycles \(1:n\), starting with \(n = 5\).
2) Calculation of the external studentized residuals using rstudent
, which uses the hat matrix of the linear model and leave-one-out:
$$\langle \hat{\varepsilon}_i \rangle = \frac{\hat{\varepsilon}_i}{\hat{\sigma}_{(i)} \sqrt{1-h_{ii}}}, \hat{\sigma}_{(i)} = \sqrt{\frac{1}{n - p - 1} \sum_{j = 1 \atop j \ne i }^n \hat{\varepsilon}_j^2}$$
with \(h_{ii}\) being the \(i\)th diagonal entry in the hat matrix \(H = X(X^TX)^{-1}X^T\).
3) Test if the last studentized residual \(\langle \hat{\varepsilon}_n \rangle\) is an outlier in terms of t-distribution:
$$1 - pt(\langle \hat{\varepsilon}_n \rangle, n - p) < 0.05$$ with \(n\) = number of residuals and \(p\) = number of parameters.
4) Test if the next nsig
- 1 cycles are also outlier cycles.
5) If so, take cycle number from 3), otherwise \(n = n + 1\) and start at 1).