# MCA and K-Means simultaneously

I was reading the article Multiple Correspondence K-means: Simultaneous versus sequential approach for dimension reduction https://link.springer.com/chapter/10.1007/978-3-319-55477-8_8

I have this simulated code:

a<-matrix(,90,6)
for(i in 1:30){
a[i,1]<-sample(1:9,1,replace=T,prob=c(0,0,0,0,0,0,1,1,1))
}
for(i in 31:60){
a[i,1]<-sample(1:9,1,replace=T,prob=c(0,0,0,1,1,1,0,0,0))
}

for(i in 61:90){
a[i,1]<-sample(1:9,1,replace=T,prob=c(1,1,1,0,0,0,0,0,0))
}

for(i in 1:30){
a[i,2]<-sample(1:9,1,replace=T,prob=c(0,0,0,0,0,0,1,1,1))
}
for(i in 31:60){
a[i,2]<-sample(1:9,1,replace=T,prob=c(1,1,1,0,0,0,0,0,0))
}

for(i in 61:90){
a[i,2]<-sample(1:9,1,replace=T,prob=c(0,0,0,1,1,1,0,0,0))
}

for(i in 1:90){
a[i,3:6]<-sample(1:9,4,replace=T,prob=c(1,1,1,1,1,1,1,1,1))
}
image(t(a))


[![enter image description here][1]][1]

That's a dataset with 6 categorical variables (each of them has 9 levels), the last 4 are totally random, the first 2 not. The aim of this method is to cluster and dimnension reduction at the same time. I'm trying to figure it out and see how it works. I know there's a package in R

clustrd::clusmca


where I can find the implementation, but I'm interested to follow the articile and do it by myself the first time.

The article says: imagine we have a matrix $X$ of dimnensions $N\times J$ we want to find a $P\;(P\ll J)$ dimensionality and $K$ clusters. In my case $P=2$ and $K=3$.

The article follows the idea of Hwang as in his article https://link.springer.com/article/10.1007/s11336-004-1173-x merging MCA and K-means into:

$J^{1/2} \mathbf{JBL}^{1/2}=(\mathbf{U\hat{Y}}+\mathbf{E}_{KM})\mathbf{A'}+\mathbf{E}_{MCA}$

hence

$J^{1/2}\mathbf{JBL}^{1/2}=(\mathbf{U\hat{Y}A'+\mathbf{E}}_{MCKM})$

with $\mathbf{E}_{MCKM}=\mathbf{E}_{KM}\mathbf{A'}+\mathbf{E}_{MCA}$

where

$\mathbf{\hat{Y}}$ is a $K\times P$ centroid matrix in the P.dimensional Space

$A$ is a $J \times P$ column-wise orthonormal loadings matrix (i.e. $A'A=I_P)$

$J^{1/2}\mathbf{JBL}^{1/2}$ is the centred data matrix corresponding to the J qualitative variables with the binary block matrix $\mathbf{B=[B_1,B_2,...,B_j]}$ formed by J indicator matrices $B_j$ with elements $b_{ijm}=1$ if the ith has assumed category m for variable j,$b_{ijm}=0$ otherwise;

$\mathbf{L}$=diag($\mathbf{B'1_N})$

$\mathbf{J}=\mathbf{I}_N-N^{-1}\mathbf{1}_N\mathbf{1'}_N$ is the idempotent centring matrix with $mathbf{1}_N$ the N-dimensional vector of unitary elements

What I don't get is the dimensionality of $J^{1/2}\mathbf{JBL}^{1/2}$ and what it is the centered data matrix. Is it referring the the original data or the indicator matrix.

In my case $J^{1/2}$ should be 1/6 cause my variables are 6

$\mathbf{J}$ should be a $90\times90$

$\mathbf{B}$ a $90\times 54$ cause it's the indicator matrix

$\mathbf{L}$ is a $54\times 54$

So the final dimensionality is $90\times 54$. My question is: what is this? The indicator matrix centered. What I was expecting was the original data as I supposed from the article. If it's $90 \times 54$ I also would expect that the article when it's written J, it means 54 (in my case). In fact because of $J^{1/2}\mathbf{JBL}^{1/2}$ equals $(\mathbf{U\hat{Y}A'+\mathbf{E}}_{MCKM})$ it must have the same dimensionality of $\mathbf{U\hat{Y}A'}$ hence $\mathbf{A}$ has to be $54\times 2$ hence J=54.

I'm a little stuck here.