polychoric matrix created, but "argument is of length zero" come when doing factor analysis

StackOverflow https://stackoverflow.com/questions/14575541

  •  05-03-2022
  •  | 
  •  

Question

I am running a factor analysis via psych package.

cormat <- polychoric(na.omit(mself1))
##Warning message:
In cor.smooth(mat) : Matrix was not positive definite, smoothing was done
fa(cormat,nfactors=3,n.obs = 183 ,n.iter=1, rotate="oblimin",fm="ml")
## Error in if (dim(r)[1] == dim(r)[2]) { : argument is of length zero

I just wondered why the argument is of length zero which means the file is empty, when I type cormat the Polychoric matrix came out.

How could I fix this problem, or it has anything with the "not positive definite"?

Thanks!

Was it helpful?

Solution

The psych package stores the actual matrix in $rho in your cormat object. In your case, fa(cormat$rho) will fix that problem. Bill also includes the fa.poly() function, which will compute the polychoric correlations from a raw data matrix before running a factor analysis on that.

Be a bit cautious with your results though. Your resulting matrix was non-Gamian (i.e., had a negative eigenvalue), which can happen when they're estimated pairwise or you have large sampling errors (see Garrido, Abad, & Ponsosa, 2013).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top