MCA error in CA(Ztot, ncp = min(ncp, ncol(Z) - length(act)), row.sup = ind.sup, : length of vector row.w should be the number of active rows

130 views
Skip to first unread message

Hugo Fernández Mena

unread,
Jun 6, 2024, 5:04:49 AM6/6/24
to FactoMineR users

Francois HUSSON

unread,
Jun 7, 2024, 7:13:07 AM6/7/24
to factominer-users
Hi,

It seems that you have no active variables. So there in no data to perform MCA. If you want to perfrom MCA on the 3 categorical variables, do:
res.mca <- MCA(data_simplified, quanti.sup = c(1, 2))

FH

De: "Hugo Fernández Mena" <hugob...@gmail.com>
À: "FactoMineR users" <factomin...@googlegroups.com>
Envoyé: Jeudi 6 Juin 2024 11:04:49
Objet: [SOCIAL]MCA error in CA(Ztot, ncp = min(ncp, ncol(Z) - length(act)), row.sup = ind.sup, : length of vector row.w should be the number of active rows

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "FactoMineR users".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse factominer-use...@googlegroups.com.
Cette discussion peut être lue sur le Web à l'adresse https://groups.google.com/d/msgid/factominer-users/fafe56be-b93f-40fb-af14-dc0e32f22c6cn%40googlegroups.com.
Message has been deleted

Hugo Fernández Mena

unread,
Jun 7, 2024, 9:15:04 AM6/7/24
to FactoMineR users
Hi François, 

Thanks! It works for your example, but if I want to perform the MCA on Yield (2nd quantitative variable) I still get an error:
#MCA Yield as active
> res.mca <- MCA(data_simplified,
+ quanti.sup = 2, # Plantation_density
+ quali.sup = c(3,4,5)) # Label, Organic, Irrigation
Error in CA(Ztot, ncp = min(ncp, ncol(Z) - length(act)), row.sup = ind.sup, : length of vector row.w should be the number of active rows In addition: Warning message: In CA(Ztot, ncp = min(ncp, ncol(Z) - length(act)), row.sup = ind.sup, : The rows 3502, 3503, 3504, 3505, 3506, 3507 sum at 0. They were suppressed from the analysis

El viernes, 7 de junio de 2024 a las 15:13:29 UTC+2, Hugo Fernández Mena escribió:
Hi François, 

Thanks! It works for your example, but if I want to perform the MCA on Yield (2nd quantitative variable) I still get an error:
#MCA Yield as active > res.mca <- MCA(data_simplified, + quanti.sup = 2, # Plantation_density + quali.sup = c(3,4,5)) # Label, Organic, Irrigation Error in CA(Ztot, ncp = min(ncp, ncol(Z) - length(act)), row.sup = ind.sup, : length of vector row.w should be the number of active rows In addition: Warning message: In CA(Ztot, ncp = min(ncp, ncol(Z) - length(act)), row.sup = ind.sup, : The rows 3502, 3503, 3504, 3505, 3506, 3507 sum at 0. They were suppressed from the analysis

Hugo Fernández Mena

unread,
Jun 12, 2024, 12:10:14 PM6/12/24
to FactoMineR users

any ideas why ?

Emmanuel Detrinidad

unread,
Jun 12, 2024, 2:20:02 PM6/12/24
to factomin...@googlegroups.com
In my humble opinion, It is an error of syntax, 

Try this one:
res.mca <- MCA(data_simplified, quanti.sup = 2, quali.sup = 3,4,5) # Label, Organic, Irrigation

The "
c (3,4,5)" is not required, only the number of columns (= 3,4,5) 
 
good luck, 

Emmanuel



Virus-free.www.avast.com

François Husson

unread,
Jun 13, 2024, 5:37:41 AM6/13/24
to factomin...@googlegroups.com
You only have 1 active variable!
Cette discussion peut être lue sur le Web à l'adresse https://groups.google.com/d/msgid/factominer-users/110e08dd-1325-4173-81f3-4d5f0144ac4fn%40googlegroups.com.

--
François Husson
Department Statistics & Computer Science
L'Institut Agro
65 rue de St-Brieuc - 35042 Rennes
Tel: +33 2 23 48 58 86
https://husson.github.io/
https://www.youtube.com/@HussonFrancois/videos
Message has been deleted

Hugo Fernández Mena

unread,
Jun 13, 2024, 6:36:43 AM6/13/24
to FactoMineR users
Ok, rigth with only one active variable it was a very bad exemple to try with, but other active / supplementary variables I tried did not work either. 
For instance, in this case I used all the following variables as active, except Yield and Label, and still get an error. Any ideas why ?

> str(data_simplified)
'data.frame': 3507 obs. of 8 variables:
$ Variety : Factor w/ 59 levels "ALICANTE BOUSCHET NOIR",..: 1 1 1 1 1 1 1 1 1 1 ...
$ Yield : num 133 30 100 83 30 ...
$ Vine_age : int 33 21 38 37 31 36 27 4 29 45 ...
$ Plantation_density: num 4167 5000 3704 3333 3333 ...
$ Label : Factor w/ 3 levels "PDO","PGI","Unlabeled_wine": 3 3 2 2 3 3 3 2 3 2 ...
$ Organic : Factor w/ 2 levels "NO","YES": 1 1 1 1 1 1 1 1 1 1 ... $ Irrigation : Factor w/ 3 levels "NO","Unknown",..: 1 1 3 1 1 2 2 2 1 2 ...
$ Rootstock : Factor w/ 14 levels "1103P","110R",..: 9 14 9 9 6 9 9 9 9 8 ...

> res.mca <- MCA(data_simplified,
+ quanti.sup = 2, # Yield
+ quali.sup = 5) # Label
Error in aggregate.data.frame(as.data.frame(x), ...) :
arguments must have same length
In addition: Warning message:
In sqrt(Nj * ((N - 1)/(N - Nj))) : NaNs produced


El jueves, 13 de junio de 2024 a las 12:35:10 UTC+2, Hugo Fernández Mena escribió:
Ok, rigth with only one active variable it was a very bad exemple to try with, but other active / supplementary variables I tried did not work either. 
For instance, in this case I used all the following variables as active, except Yield and Label, and still get an error. Any ideas why ?

> str(data_simplified) 'data.frame': 3507 obs. of 8 variables: $ Variety : Factor w/ 59 levels "ALICANTE BOUSCHET NOIR",..: 1 1 1 1 1 1 1 1 1 1 ... $ Yield : num 133 30 100 83 30 ... $ Vine_age : int 33 21 38 37 31 36 27 4 29 45 ... $ Plantation_density: num 4167 5000 3704 3333 3333 ... $ Label : Factor w/ 3 levels "PDO","PGI","Unlabeled_wine": 3 3 2 2 3 3 3 2 3 2 ... $ Organic : Factor w/ 2 levels "NO","YES": 1 1 1 1 1 1 1 1 1 1 ... $ Irrigation : Factor w/ 3 levels "NO","Unknown",..: 1 1 3 1 1 2 2 2 1 2 ... $ Rootstock : Factor w/ 14 levels "1103P","110R",..: 9 14 9 9 6 9 9 9 9 8 ... > #MCA Yield as active > res.mca <- MCA(data_simplified, + quanti.sup = 2, # Yield + quali.sup = 5) # Label Error in aggregate.data.frame(as.data.frame(x), ...) : arguments must have same length In addition: Warning message: In sqrt(Nj * ((N - 1)/(N - Nj))) : NaNs produced

Hugo Fernández Mena

unread,
Jun 13, 2024, 9:22:27 AM6/13/24
to FactoMineR users
The problem might be that I have 59 levels for my variable called "Variety", too many levels...

François Husson

unread,
Jun 13, 2024, 9:24:02 AM6/13/24
to factomin...@googlegroups.com
There is a quantitaive variable as active, which is not possible in MCA.
FH

Hugo Fernández Mena

unread,
Jun 13, 2024, 9:33:47 AM6/13/24
to FactoMineR users
ah OK now I understand, this might be the most important thing I should know about it..
Then, if I want to have both categorical and quantitative variables I have to swith to something else, like a MFA ?

francois.husson

unread,
Jun 13, 2024, 10:21:46 AM6/13/24
to factomin...@googlegroups.com
You can use FAMD for mixed data

-------- Message d'origine --------
De : Hugo Fernández Mena <hugob...@gmail.com>
Date : 13/06/2024 15:33 (GMT+01:00)
À : FactoMineR users <factomin...@googlegroups.com>
Objet : [SOCIAL]Re: [SOCIAL]Re: [SOCIAL]Re: [SOCIAL]MCA error in CA(Ztot, ncp = min(ncp, ncol(Z) - length(act)), row.sup = ind.sup, : length of vector row.w should be the number of active rows

Reply all
Reply to author
Forward
0 new messages