Reputation: 11
I want to compute factor analysis with mixed data (i.e., continous, categorical and binary) but I have a lot of warnings and it does not converge resulting in Nans ( objective num NaN, criteria NaN NA NA, STATISTIC : num NaN, PVAL : num NaN) with pchisq not converged in 1000000 iter and GPFoblq convergence not obtained in GPFoblq. 1000 iterations used)
mixedCor_results <-mixedCor(data,p=4:93,c=1:2,d=3,correct=FALSE,smooth=TRUE,global= FALSE)
ggcorrplot(mixedCor_results$rho)
#Compute the factors
parallel <- fa.parallel(mixedCor_results$rho,n.obs=nrow(data), fa="fa", main = "Scree
Plot",correct=FALSE ,n.iter = 50)
print(parallel$nfact) #number of factors
modelfa= fa(mixedCor$rho,n.obs=nrow(data), nfactors = 38,correct=FALSE ,n.iter = 50)
str(modelfa)
print(modelfa$loadings, cut = 0)
I wonder if there is a bug in mixedcor. I tried with mixedcor and it is not working but with fa parallel and polychor works if I remove continous and i leave only categorical and binary but if i add mixed with continous in fa parallel is not working again as it is using mixedcor internally and giving warnings again
#REMOVE CONTINOUS THEN IT WORKS
data <- data[ -c(1:4)]
#POLY used for binary and categorical
parallel <- fa.parallel(data,fa="fa",cor="poly",correct=0,n.iter = 50)
#Compute the factors
modelfa= fa(data, fm = "ml",cor="poly",nfactors = 23,fa="fa",
rotate = "varimax",
scores="Bartlett",correct=0)
Someone had the same issue?. Is it ok to use the polychoric including the binary and internally the lib uses the correct correlation (tetrachoric)? If this is the case I will transform the continous. But the mixedCor is not working propertly.
Upvotes: 0
Views: 51
Reputation: 101
You may want to try hetcor
from John Fox's polycor
package. Revelle (the creator and maintainer of psych
) notes that convergence problems can happen with mixedCor
. I have had better luck with hetcor
, and it detects data types automatically, BUT you should make sure that your binary and ordered categorical variables are converted to factors
(ordered factors for the ordinal categorical variables) with the correct ordering. Otherwise, neither function works.
Upvotes: 0