简体   繁体   中英

How to apply a factor analysis applying spearman correlation to the principal() in R?

To test it can be used the mtcars which have non-parametric distribution. I am developing a factor analysis. My data is non-parametric in nature. Therefore, according to the literature, it is recommended to apply the Spearman test. I'm using fuction:

root.fa2 <- principal(dt, 
                  nfactors = 3, 
                  rotate = 'varimax',
                  scores=T, 
                  residuals =T,
                  oblique.scores=T,
                  method="regression",
                  spearman="cor",
                  use = "all.obs")

By default, she uses the option cor = "cor" applying the Person test. However, this is indicated for parametric data. The spearman = "cor" option is valid for the function. However, this error is returning -> Error in stats::varimax(loadings, ...): unused argument (spearman = "cor"). This only happens when I define a nfactors > 1.

The documentation is not a clear as it might be here, but looking at the documentation for MixedCor the following works and gives you your scores:

root.fa2 <- principal(mtcars, nfactors = 3, 
        rotate = 'varimax', scores=TRUE, residuals=TRUE, oblique.scores=TRUE,
        method="regression", use = "all.obs", cor="spearman")

Note. It is good practice to spell out TRUE and FALSE since they are reserved words. T and F will usually work, but they are not reserved so that you can accidentally assign T or F to a value in some other part of your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM