Error with factor analysis command

Asked

Viewed 119 times

2

The command factanal() factor analysis shows a meaningless error message.

I have to perform the factor analysis, I want to compare the scores obtained when using the solutions by the variance matrix and the correlation matrix.

X matrix lack error appears, but it is inside the command.

Follows basis of the R:

iris <- data.frame(rbind(iris3[,,1], iris3[,,2], iris3[,,3]),Sp = rep(c("s","c","v"), rep(50,3)))

iris = cbind(iris[,(1:4)])

Follow executed command and Techo error:

mvscov <- factanal(iris, factors=1, covmat=var(iris), n.obs=150, rotation="none", scores="regression")

Error in factanal(iris, factors = 1, covmat = var(iris), n.obs = 150,  : 
  scores requeridos sem uma matriz 'x'

mvscor <- factanal(iris, factors=1, covmat=cor(iris), n.obs=150, rotation="none", scores="regression")

Error in factanal(iris, factors = 1, covmat = cor(iris), n.obs = 150,  : 
  scores requeridos sem uma matriz 'x'
  • 1

    I have no experience in using this function, but analyzing help and the source code you can see that you can only use scores = "regression" (or "Bartlett") if you do not pass a par value tocovmat. The following alternatives work: factanal(iris2, factors=1, n.obs=150, rotation="none", scores="regression") and factanal(iris2, factors=1, covmat=var(iris), n.obs=150, rotation="none", scores="none"). Are you sure that neither of the two is correct for your case? For this example, both return the same result.

1 answer

1


Apparently, you’re trying to simultaneously use function options that don’t allow this...

See, all the commands below produce the same results. They are modifications of the codes posted by you:

# Uso a mesma base de dados. Mas bastava escrever isso, 
# sem utilizar o iris3
iris <- iris[, c(1:4)] 

If you only report a database with quantitative variables, this is enough to produce factor analysis. However, at first it basically means the matrix of loadings (k-dimension x k). The option score allows factorial colors to be saved (with dimension n x k).

factanal(iris, 
     factors=1, 
     rotation="none", 
     scores="regression")

Another option is to enter a formula and at the same time a dataset in the_data_argument. The expression ~. means I’ll use all the columns in the database.

factanal(x = ~ ., 
     data = iris,
     factors=1, 
     rotation="none", 
     scores="regression")

Finally, instead of using a database, you can only pass a variance-covariance or correlation matrix. In the case of the var-cov matrix, it is necessary to enter the number of observations. However, by running this way, you cannot use the option score (here is the source of your mistake), since the scores are linear combinations produced from the observations of each row of the database. As there is no database passed to the function, calculating the value of the individual score(s) will not be possible.

factanal(x = ~., 
     covmat = var(iris),
     n.obs = 150,
     factors=1, 
     rotation="none")

Browser other questions tagged

You are not signed in. Login or sign up in order to post.