reflect_fa {lazy.tools} | R Documentation |
Reflect the signs of the columns of the factor pattern matrix so that the number of positive loadings is larger than the negative ones.
reflect_fa(A, sortcols = 0, unclass = 0)
A |
Factor Pattern matrix or an object with $loadings. |
sortcols |
= 1 to sort factors (columns of A) according to factor contributions. |
unclass |
= 1 to unclass the result |
print |
= 1 to print the result |
First, if sortcols == 1, the columns of A
are reordered
according to the magnitude of diag(t(A)%*%A)
.
Then, for each column of A
,
the sign will be reflected if the number of negative loadings is
greater than the positive ones.
A list of
loadings = reordered loadings matrix
col_order = sort order of the cols
sign = a vector indicating if the signs were preserved or not
set.seed(1701)
n <- 20; ndim <- 4
A0 <- matrix(runif(n*ndim),n,ndim)
dimnames(A0)=list( paste("v",1:n,sep=""),paste("f",1:ndim,sep=""))
A0v <- varimax(A0)$loadings
A0v <- A0v*matrix(sample(c(-1,1,1),n*ndim,replace=TRUE),n,ndim)
A0v[,3:4] <- -A0v[,3:4]
A0vs <- reflect_fa(A0v)$loadings
Print(A0v,A0vs, fmt="6.3")
A0vsc <- reflect_fa(A0v, sortcol=1)$loadings
Print(A0v,A0vsc, fmt="6.3")
# attributes
print(reflect_fa(A0v)$loadings)
print(reflect_fa(A0v, unclass=1)$loadings)