spca.Rd
spca
computes supervised principal component analysis as
described in Barshan et al.
spca(x, y = diag(1, nrow(x)), center = TRUE, scale = FALSE, retx = FALSE, debug = FALSE)
x | a data matrix (features in columns, samples in rows) |
---|---|
y | target classification of x (logical, numeric, or a factor), or a kernel matrix of the target. If not specified, it defaults to identity matrix, in which case SPCA becomes equivalent to classical PCA (as the matrix being decomposed equals the covariance matrix of 'x'. (Strictly speaking, when centering is in use, SPCA becomes the classical PCA. Otherwise, SPCA yields components similar to those yielded by PCA over centered data, but shifted.) |
center | a logical value indicating whether to center the data. This is advisable. |
scale | a logical value indicating whether to scale the data to have unit variance. |
retx | a logical value indicating whether to return the rotated version of 'x' |
debug | if TRUE, debugs will be printed. If numeric of value greater than 1, verbose debugs will be produced. |
Eigenvalue decomposition of Q
(see the paper). The value is a
list of values
and vectors
components (see
eigen
,
Q
, the matrix being decomposed, and center
and scale
holding the centering and scaling used, or FALSE
.
If retx
is TRUE
, the rotated version of x
is returned in x
.
The number of eigenvalues and eigenvectors correspond to the
dimension of the output space.
Barshan, E., Ghodsi, A., Azimifar, Z., Jahromi, M. Z. _Supervised principal component analysis: Visualization, classification and regression on subspaces and submanifolds_. Pattern Recognition, Vol. 44, No. 7. (29 July 2011), pp. 1357-1371, doi:10.1016/j.patcog.2010.12.015.
spca(iris[,1:4],iris$Species)#> eigen() decomposition #> $values #> [1] 2.935001e+04 2.536475e+02 2.238877e-12 -1.989520e-13 #> #> $vectors #> SPC1 SPC2 SPC3 SPC4 #> Sepal.Length 0.3267087 -0.3312274 0.8851835 0.0000000 #> Sepal.Width -0.1118250 -0.8884827 -0.2911889 -0.3366046 #> Petal.Length 0.8628349 0.1335625 -0.2684823 -0.4069328 #> Petal.Width 0.3691512 -0.2881804 -0.2440829 0.8491779 #> #> $Q #> Sepal.Length Sepal.Width Petal.Length Petal.Width #> Sepal.Length 3160.6067 -997.6333 8262.42 3563.967 #> Sepal.Width -997.6333 567.2467 -2861.98 -1146.633 #> Petal.Length 8262.4200 -2861.9800 21855.14 9338.700 #> Petal.Width 3563.9667 -1146.6333 9338.70 4020.667 #> #> $center #> Sepal.Length Sepal.Width Petal.Length Petal.Width #> 5.843333 3.057333 3.758000 1.199333 #> #> $scale #> [1] FALSE #>