0

Does anyone know how to properly edit this MFA code

res.mfa <- MFA(DF1, group=c(3,4,5,6,7,8,9), type=c("n",rep("s",5)), ncp=5, name.group=c("RPE","RPC","Chla","CX","N","C","SGR"), num.group.sup=c(2), graph=FALSE)

Error in if ((type[i] == "n") && (!(i %in% num.group.sup))) nature.group <- c(nature.group, : missing value where TRUE/FALSE needed

fviz_mfa_var(res.mfa, "quanti.var", palette = "jco", col.var.sup = "violet", repel = TRUE)

dataframe the dataframe in the image below is what I am working on. the first column is id and I first eliminate that then make the second column a factor so that when I add the hull/ellipse on the graph later i can group them by this factor. the remaining 7 columns are the response variables of my experiment to be analyzed. I ran a PCA on the same data before but upon further review that was not the best idea. I am very green in this field, so any and all assistance/advice is greatly appreciated.

  • 1
    In the MFA() documentation it is written : "group : a vector with the number of variables in each group", you have only 9 variables and you are calling 3+4+5+6+7+8+9=42 variables, be careful with what you want to do in this analysis and the group of variables you want to test – Basti Apr 29 '21 at 13:07
  • @BastienDucreux group=c(3,4,5,6,7,8,9), type=c("n",rep("s",5)), ncp=5 – T_Thyme Apr 29 '21 at 19:39
  • @BastienDucreux wow okay I misunderstood that completely. I had taken it as group=c(3,4,5,6,7,8,9) meant calling that number column > and i have no idea what this section of code signifies or is used for , type=c("n",rep("s",5)), ncp=5 my aim is to put all the variable in the same plot with axes to show correlation (or there lack of) between them. – T_Thyme Apr 29 '21 at 19:46
  • 1
    I encourage you to read this tutorial : http://www.sthda.com/english/articles/31-principal-component-methods-in-r-practical-guide/116-mfa-multiple-factor-analysis-in-r-essentials – Basti Apr 30 '21 at 14:43
  • +1 @Basti's comment. But you can also always just use ?function (e.g. ?MFA) to get a quick insight into what each argument means for any function. "Type" denotes the type of variable for each group. Your current code denotes the first group as 'n' which stands for categorial variables, and the other 5 groups for 's' which stands for quantitative variables that should be scaled. This is also the reason for your error as you have 7 groups but only assign 6 types. As for ncp: It tells you the number of dimensions that should be kept in the end result. – R. Iersel Jul 20 '22 at 10:00

0 Answers0