hotelling T2 calculator
hotelling: a product of my affinity for distraction.
|
| introduction: |
|
|
it's common practice to perform principle component analysis (pca) on
binned proton (1h) spectra in nmr metabolomics, with each sample
collected and processed in triplicate or higher to provide a statistical
basis for its location in pca scores space. in the same way that the
student's t statistic may be used to calculate confidence intervals on
the real line, the hotelling T2 statistic may be used in two
dimensions or higher to determine confidence regions.
|
|
| the program: |
|
|
almost on a whim, i decided to write hotelling to calculate
confidence ellipses for pca scores space data in two dimensions. it's
written in highly portable and efficient ansi c, directly reads scores
exported from SIMCA-P (the statistical package used in our group), and
outputs ellipse data readable by gnuplot.
|
|
calculation of the parameters of the hotelling T2 ellipses
requires an eigendecomposition of the covariance matrix calculated from
the individual scores space points. since the problem is constrained to
two dimensions, the matrix's characteristic function is quadratic in form
and the eigenvalues and eigenvectors may be calculated easily in closed
form. hotelling then uses the parametric form of the ellipse
equation to generate gnuplot-plottable ellipse contours such
as these:
|
|
|
|
| the code: |
|
|
of course, this page would be useless without source code, huh? :P
|
|
|
|