Learn R Programming

idm (version 1.3.1)

i_pca: Incremental Principal Component Analysis (PCA)

Description

This function computes the Principal Component Analysis (PCA) solution on the covariance matrix using the incremental method of Hall, Marshall & Martin (2002).

Usage

i_pca(data1, data2, nchunk = 2, disk = FALSE)

Arguments

data1
Matrix or data frame of starting data, or full data if data2 = NULL
data2
Matrix or data frame of incoming data; omitted when full data is given in data1
nchunk
Number of incoming data chunks (equal splits of 'data2') or a Vector with the row size of each incoming data chunk
disk
Logical indicating whether then output is saved to hard disk

Value

rowpcoord
Row scores on the principal components
colpcoord
Variable loadings
eg
A list describing the eigenspace of a data matrix, with components u Left eigenvectors v Right eigenvectors m Number of cases d Eigenvalues orgn Data mean
inertia_e
Percentage of explained variance
sv
Singular values
levelnames
Column labels
rowctr
Row contributions
colctr
Column contributions
rowcor
Row squared correlations
colcor
Column squared correlations
nchunk
Number of incoming data chunks
disk
Logical indicating whether the output is saved to hard disk
allrowcoords
A list containing the row scores on the principal components produced after each data chunk is analyzed; applicable only when disk = FALSE
allcolcoords
A list containing the variable loadings on the principal components produced after each data chunk is analyzed; applicable only when disk = FALSE
allrowctr
A list containing the row contributions after each data chunk is analyzed; applicable only when disk = FALSE
allrowcor
A list containing the row squared correlations produced after each data chunk is analyzed; applicable only when disk = FALSE

References

Hall, P., Marshall, D., & Martin, R. (2002). Adding and subtracting eigenspaces with eigenvalue decomposition and singular value decomposition. Image and Vision Computing, 20(13), 1009-1016. Iodice D' Enza, A., & Markos, A. (2015). Low-dimensional tracking of association structures in categorical data, Statistics and Computing, 25(5), 1009-1022.

See Also

update.i_pca, i_mca, update.i_mca, add_es

Examples

Run this code
#Iris Species 
data("iris", package = "datasets")
X = scale(iris[,-5])
res_iPCA = i_pca(data1 = X[1:50,], data2 = X[51:150,], nchunk = 2)
#static plot
plot(res_iPCA, animation = FALSE) 

#\donttest is used here because the code calls the saveGIF function of the animation package 
#which requires ImageMagick or GraphicsMagick to be installed in your system 
#See help(im.convert) for details on the configuration of ImageMagick or GraphicsMagick.
#Creates animated GIF movies for objects and variables
plot(res_iPCA, animation = TRUE, frames = 10)


#Daily Closing Prices of Major European Stock Indices, 1991-1998 
data("EuStockMarkets", package = "datasets") 
res_iPCA = i_pca(data1 = EuStockMarkets[1:50,], data2 = EuStockMarkets[51:1860,], nchunk = 5) 

#\donttest is used here because the code calls the saveGIF function of the animation package 
#which requires ImageMagick or GraphicsMagick to be installed in your system 
#See help(im.convert) for details on the configuration of ImageMagick or GraphicsMagick.
#Creates animated GIF movies for objects and variables
plot(res_iPCA, animation = TRUE, frames = 10)

Run the code above in your browser using DataLab