Error with the factor analysis command

2

The factanal() factorial command shows a meaningless error message.

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

Array error X appears, but it is inside the command.

Follows the basis of 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 command executed and techo with 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'
    
asked by anonymous 15.09.2015 / 01:31

1 answer

1

It seems like you're trying to use function options that do not allow this at the same time ...

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

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

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

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 that I will 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 an array of variance-covariance or correlation. In the case of the var-cov matrix, the number of observations must be reported. However, by doing so, you can not use the score option ( here is the source of your error ), since the scores are linear combinations produced from observations of each row in 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")
    
15.09.2015 / 03:30