Learn R Programming

idm (version 1.3.1)

i_mca: Incremental Multiple Correspondence Analysis (MCA)

Description

This function computes the Multiple Correspondence Analysis (MCA) solution on the indicator matrix using two incremental methods described in Iodice D'Enza & Markos (2015)

Usage

i_mca(data1, data2, method=c("exact","live"), nchunk = 2, current_rank, ff = 0, 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
method
String specifying the type of implementation: "exact" or "live". "exact" refers to the case when all the data is available from the start and dimension reduction is based on the method of Hall et al. (2002). "live" refers to the case when new data comes in as data flows and dimension reduction is based on the method of Ross et al. (2008). The main difference between the two approaches lies in the calculation of the column margins of the input matrix. For the "exact" approach, the analysis is based on the "global" margins, that is, the margins of the whole indicator matrix, which is available in advance. For the "live" approach, the whole matrix is unknown and the global margins are approximated by the "local" margins, that is, the average margins of the data analysed insofar. A detailed description of the two implementations is provided in Iodice D' Enza & Markos (2015).
nchunk
Number of incoming data chunks (equal splits of 'data2') or a Vector with the row size of each incoming data chunk
current_rank
Rank of approximation; if empty then full rank is used
ff
Number between 0 and 1 indicating the "forgetting factor" used to down-weight the contribution of earlier data blocks to the current solution. When ff = 0 (default) no forgetting occurs; applicable only when method ="live"
disk
Logical indicating whether then output is saved to hard disk

Value

rowpcoord
Row principal coordinates
colpcoord
Column principal coordinates
rowcoord
Row standard coordinates
colcoord
Column standard coordinates
levelnames
Column labels
colctr
Column contributions
colcor
Column squared correlations
rowctr
Row contributions
rowcor
Row squared correlations
sv
Singular values
rowmass
Row masses
colmass
Column masses
inertia_e
Percentages of explained (adjusted) inertia
nchunk
Number of incoming data chunks
disk
Logical indicating whether then 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
ff
Number between 0 and 1 indicating the "forgetting factor" used to down-weight the contribution of earlier data blocks to the current solution; applicable only when method = "live"
allcolcoords
A list containing the variable loadings on the principal components produced after each data chunk is analyzed; applicable only when disk = FALSE
allcolctr
A list containing the column contributions after each data chunk is analyzed; applicable only when disk = FALSE
allcolcor
A list containing the column squared correlations 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. Ross, D. A., Lim, J., Lin, R. S., & Yang, M. H. (2008). Incremental learning for robust visual tracking. International Journal of Computer Vision, 77(1-3), 125-141. 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_mca, i_pca, update.i_pca, add_es

Examples

Run this code
##Example 1 - Exact case
data("women", package = "idm")
nc = 5 # number of chunks
res_iMCAh = i_mca(data1 = women[1:300,1:7], data2 = women[301:2107,1:7]
,method = "exact", nchunk = nc)
#static MCA plot of attributes on axes 2 and 3
plot(x = res_iMCAh, dim = c(2,3), what = c(FALSE,TRUE), 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_iMCAh, animation = TRUE, frames = 10)


##Example 2 - Live case
data("tweet", package = "idm")
nc = 5
#provide attributes with custom labels
labels = c("HLTN", "ICN", "MRT","BWN","SWD","HYT","CH", "-", "-/+", "+", "++", "Low", "Med","High")
#mimics the 'live' MCA implementation 
res_iMCAl = i_mca(data1 = tweet[1:100,], data2 = tweet[101:1000,],
method="live", nchunk = nc, current_rank=2)


#\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_iMCAl, labels = labels, animation = TRUE, frames = 10)

Run the code above in your browser using DataLab