husson / FactoMineR

Package FactoMineR
39 stars 8 forks source link

Error in aux1[[i]] : subscript out of bounds #14

Open Lynx-jr opened 1 year ago

Lynx-jr commented 1 year ago

This is the error msg I got while doing this: FAMD(hot, sup.var = 7, graph = FALSE, ncp = 25), it traces back to rbind(bary, aux1[[i]]). I wonder if it's because I have a huge df - it's 6000+ rows and 11k+ columns. Any help is appreciated, thanks!

husson commented 1 year ago

First, check that the first column is not a column with the names of the individuals. In that case, all the values are different and then such a categorical variable cannot be taken into account. Else, check that all the categories of all the categorical are taken at least by 1 individual. And then, it can be due to the number of variables which is important (chech with less variables and increase step by step to see which variable makes the problem).

FH

Le 20/10/2022 à 17:40, Lynx-jr a écrit :

This is the error msg I got while doing this: FAMD(hot, sup.var = 7, graph = FALSE, ncp = 25), it traces back to rbind(bary, aux1[[i]]). I wonder if it's because I have a huge df - it's 6000+ rows and 11k+ columns. Any help is appreciated, thanks!

— Reply to this email directly, view it on GitHub https://github.com/husson/FactoMineR/issues/14, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2XXYDZMNBQAMERGSOQ3BTWEFRYPANCNFSM6AAAAAARKJFYSQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Logo signature e-mail

François Husson Department Statistics & Computer science UMR 6625 IRMAR CNRS 65 rue de Saint-Brieuc, CS 84215, 35042 Rennes Cedex Tel: +33 2 23 48 58 86 https://husson.github.io https://www.institut-agro.fr/rennes-angers

En 2022, Agrocampus Ouest devient l'Institut Agro Rennes-Angers.

pbrendel-valo commented 1 year ago

I'm having the same problem. None of the suggestions from @husson seem to resolve it. I'm able to run the function with no problem on the built-in iris data. But, even when checking various small samples of my main data, I can't it to run without this error on my own dataframe.

I'm running on R version 4.2.0 and FactoMineR version 2.6.

pbrendel-valo commented 1 year ago

Ok, I think I figured out the problem. It seems that the FAMD function will output this error if the input dataframe doesn't have any factor variables. This explains why I was so confused why it was working on iris but not on other dataframes I tried. I'd suggest better documentation/error messages around this.

hopk8 commented 6 months ago

I'm also having an issue with the "out of bounds" error when trying to run FAMD. I've checked my data various ways and can find no issue that would be causing this so far. I am able to successfully run the FAMD on my full dataset, but not on the subset of selected variables from that full dataset. I've tried different combinations of these variables to see if one in particular is an issue, but all of them result in the same error.

In R, the part of my syntax specific to the selection of variables for analysis and the running of the FAMD and HCPC is as follows:

Specify the variables to include for analysis in subset dataframe

vars_to_include <- c("gsa_num", "division_num", "totalmortgages", "revenue", "foreclosures", "lastingaffordability")

Subset data only including variables of interest for analysis

vars_2_analyze <- data[vars_to_include]

Perform FAMD

res.famd <- FAMD(vars_2_analyze, ncp=5, graph=FALSE)

Perform HCPC on the FAMD results

res.hcpc <- HCPC(res.famd, graph=FALSE)

The error received after the line of code for the FAMD is: "Error in aux1[[i]] : subscript out of bounds"