1math::PCA(n) Principal Components Analysis math::PCA(n)
2
3
4
5______________________________________________________________________________
6
8 math::PCA - Package for Principal Component Analysis
9
11 package require Tcl ?8.6?
12
13 package require math::pca ?1.0?
14
15 package require math::linearalgebra 1
16
17 ::math::PCA::createPCA data ?args?
18
19 $pca using ?number?|?-minproportion value?
20
21 $pca eigenvectors ?option?
22
23 $pca eigenvalues ?option?
24
25 $pca proportions ?option?
26
27 $pca approximate observation
28
29 $pca approximatOriginal
30
31 $pca scores observation
32
33 $pca distance observation
34
35 $pca qstatistic observation ?option?
36
37______________________________________________________________________________
38
40 The PCA package provides a means to perform principal components analy‐
41 sis in Tcl, using an object-oriented technique as facilitated by TclOO.
42 It actually defines a single public method, ::math::PCA::createPCA,
43 which constructs an object based on the data that are passed to perform
44 the actual analysis.
45
46 The methods of the PCA objects that are created with this command allow
47 one to examine the principal components, to approximate (new) observa‐
48 tions using all or a selected number of components only and to examine
49 the properties of the components and the statistics of the approxima‐
50 tions.
51
52 The package has been modelled after the PCA example provided by the
53 original linear algebra package by Ed Hume.
54
56 The math::PCA package provides one public command:
57
58 ::math::PCA::createPCA data ?args?
59 Create a new object, based on the data that are passed via the
60 data argument. The principal components may be based on either
61 correlations or covariances. All observations will be nor‐
62 malised according to the mean and standard deviation of the
63 original data.
64
65 list data
66 - A list of observations (see the example below).
67
68 list args
69 - A list of key-value pairs defining the options. Cur‐
70 rently there is only one key: -covariances. This indi‐
71 cates if covariances are to be used (if the value is 1)
72 or instead correlations (value is 0). The default is to
73 use correlations.
74
75 The PCA object that is created has the following methods:
76
77 $pca using ?number?|?-minproportion value?
78 Set the number of components to be used in the analysis (the
79 number of retained components). Returns the number of compo‐
80 nents, also if no argument is given.
81
82 int number
83 - The number of components to be retained
84
85 double value
86 - Select the number of components based on the minimum
87 proportion of variation that is retained by them. Should
88 be a value between 0 and 1.
89
90 $pca eigenvectors ?option?
91 Return the eigenvectors as a list of lists.
92
93 string option
94 - By default only the retained components are returned.
95 If all eigenvectors are required, use the option -all.
96
97 $pca eigenvalues ?option?
98 Return the eigenvalues as a list of lists.
99
100 string option
101 - By default only the eigenvalues of the retained compo‐
102 nents are returned. If all eigenvalues are required, use
103 the option -all.
104
105 $pca proportions ?option?
106 Return the proportions for all components, that is, the amount
107 of variations that each components can explain.
108
109 $pca approximate observation
110 Return an approximation of the observation based on the retained
111 components
112
113 list observation
114 - The values for the observation.
115
116 $pca approximatOriginal
117 Return an approximation of the original data, using the retained
118 components. It is a convenience method that works on the com‐
119 plete set of original data.
120
121 $pca scores observation
122 Return the scores per retained component for the given observa‐
123 tion.
124
125 list observation
126 - The values for the observation.
127
128 $pca distance observation
129 Return the distance between the given observation and its
130 approximation. (Note: this distance is based on the normalised
131 vectors.)
132
133 list observation
134 - The values for the observation.
135
136 $pca qstatistic observation ?option?
137 Return the Q statistic, basically the square of the distance,
138 for the given observation.
139
140 list observation
141 - The values for the observation.
142
143 string option
144 - If the observation is part of the original data, you
145 may want to use the corrected Q statistic. This is
146 achieved with the option "-original".
147
149 TODO: NIST example
150
152 This document, and the package it describes, will undoubtedly contain
153 bugs and other problems. Please report such in the category PCA of the
154 Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. Please also
155 report any ideas for enhancements you may have for either package
156 and/or documentation.
157
158 When proposing code changes, please provide unified diffs, i.e the out‐
159 put of diff -u.
160
161 Note further that attachments are strongly preferred over inlined
162 patches. Attachments can be made by going to the Edit form of the
163 ticket immediately after its creation, and then using the left-most
164 button in the secondary navigation bar.
165
167 PCA, math, statistics, tcl
168
170 Mathematics
171
172
173
174tcllib 1.0 math::PCA(n)