New to component analysis -- FAMD(df) in R -- "Error : arguments must have same length"

464 views
Skip to first unread message

Omkar Kulkarni

unread,
Aug 17, 2016, 12:01:16 PM8/17/16
to FactoMineR users
Hello, 

I am new to the component analysis and with my basic understanding I could gather, 

if we have both 'continuous' and 'categorical' variables we can use Factor analysis of Mixed Data. 

In my case, I have a dataset with 31 variables. 
14 -- continuous
17 -- categorical. 

My ultimate goal is to predict G3 -- a  continuous variable. 
But using FAMD in R, I wanted to have an exploratory analysis. 

1. Whats the mistake I am using in using FAMD() in R. Please see below for output. 
2. Is FAMD a good/easy method for exploratory analysis in the first place? If no, what is? 


Error
> FAMD(student.n, graph = TRUE)
Error in aggregate.data.frame(as.data.frame(x), ...) : 
  arguments must have same length
In addition: Warning messages:
1: In pca$var$coord[ind.quali, , drop = FALSE]/sqrt(prop) :
  longer object length is not a multiple of shorter object length
2: In coord.quali.var^2/dist2 :
  longer object length is not a multiple of shorter object length
3: In vtest/sqrt(nombre) :
  longer object length is not a multiple of shorter object length

Summary of dataframe
str(student.n)
'data.frame': 395 obs. of  31 variables:
 $ school    : Factor w/ 2 levels "GP","MS": 1 1 1 1 1 1 1 1 1 1 ...
 $ sex       : Factor w/ 2 levels "F","M": 1 1 1 1 1 2 2 1 2 2 ...
 $ age       : int  18 17 15 15 16 16 16 17 15 15 ...
 $ address   : Factor w/ 2 levels "R","U": 2 2 2 2 2 2 2 2 2 2 ...
 $ famsize   : Factor w/ 2 levels "GT3","LE3": 1 1 2 1 1 2 2 1 2 1 ...
 $ Pstatus   : Factor w/ 2 levels "A","T": 1 2 2 2 2 2 2 1 1 2 ...
 $ Medu      : int  4 1 1 4 3 4 2 4 3 3 ...
 $ Fedu      : int  4 1 1 2 3 3 2 4 2 4 ...
 $ Mjob      : Factor w/ 5 levels "at_home","health",..: 1 1 1 2 3 4 3 3 4 3 ...
 $ Fjob      : Factor w/ 5 levels "at_home","health",..: 5 3 3 4 3 3 3 5 3 3 ...
 $ reason    : Factor w/ 4 levels "course","home",..: 1 1 3 2 2 4 2 2 2 2 ...
 $ guardian  : Factor w/ 3 levels "father","mother",..: 2 1 2 2 1 2 2 2 2 2 ...
 $ traveltime: int  2 1 1 1 1 1 1 2 1 1 ...
 $ studytime : int  2 2 2 3 2 2 2 2 2 2 ...
 $ failures  : int  0 0 3 0 0 0 0 0 0 0 ...
 $ schoolsup : Factor w/ 2 levels "no","yes": 2 1 2 1 1 1 1 2 1 1 ...
 $ famsup    : Factor w/ 2 levels "no","yes": 1 2 1 2 2 2 1 2 2 2 ...
 $ paid      : Factor w/ 2 levels "no","yes": 1 1 2 2 2 2 1 1 2 2 ...
 $ activities: Factor w/ 2 levels "no","yes": 1 1 1 2 1 2 1 1 1 2 ...
 $ nursery   : Factor w/ 2 levels "no","yes": 2 1 2 2 2 2 2 2 2 2 ...
 $ higher    : Factor w/ 2 levels "no","yes": 2 2 2 2 2 2 2 2 2 2 ...
 $ internet  : Factor w/ 2 levels "no","yes": 1 2 2 2 1 2 2 1 2 2 ...
 $ romantic  : Factor w/ 2 levels "no","yes": 1 1 1 2 1 1 1 1 1 1 ...
 $ famrel    : int  4 5 4 3 4 5 4 4 4 5 ...
 $ freetime  : int  3 3 3 2 3 4 4 1 2 5 ...
 $ goout     : int  4 3 2 2 2 2 4 4 2 1 ...
 $ Dalc      : int  1 1 2 1 1 1 1 1 1 1 ...
 $ Walc      : int  1 1 3 1 2 2 1 1 1 1 ...
 $ health    : int  3 3 3 5 5 5 3 1 1 5 ...
 $ absences  : int  6 4 10 2 4 10 0 6 0 0 ...
 $ G3        : int  6 6 10 15 10 15 11 6 19 15 ...

Cheers,
Omkar 

François Husson

unread,
Aug 24, 2016, 3:30:02 AM8/24/16
to FactoMineR users
Hi
1) It is difficult to see your problem. Can you send me your dataset and the lines of code you use.
2) Yes FAMd is nice to explore a data set with both continuous and categorical variables.
FH
Reply all
Reply to author
Forward
0 new messages