data("HW")
# load first HW data set
RHW <- cor(x = HW$HW6)
# Compute principal axis factor analysis
fapaOut <- faMain(R = RHW,
numFactors = 3,
facMethod = "fapa",
rotate = "oblimin",
faControl = list(treatHeywood = FALSE))
fapaOut$faFit$Heywood
round(fapaOut$h2, 2)
# Conduct a regularized factor analysis
regOut <- fareg(R = RHW,
numFactors = 3,
facMethod = "rls")
regOut$L
regOut$Heywood
# rotate regularized loadings and align with
# population structure
regOutRot <- faMain(urLoadings = regOut$loadings,
rotate = "oblimin")
# ALign
FHW <- faAlign(HW$popLoadings, fapaOut$loadings)$F2
Freg <- faAlign(HW$popLoadings, regOutRot$loadings)$F2
AllSolutions <- round(cbind(HW$popLoadings, Freg, FHW),2)
colnames(AllSolutions) <- c("F1", "F2", "F3", "Fr1", "Fr2", "Fr3",
"Fhw1", "Fhw2", "Fhw3")
AllSolutions
rmsdHW <- rmsd(HW$popLoadings, FHW,
IncludeDiag = FALSE,
Symmetric = FALSE)
rmsdReg <- rmsd(HW$popLoadings, Freg,
IncludeDiag = FALSE,
Symmetric = FALSE)
cat("\nrmsd HW = ", round(rmsdHW,3),
"\nrmsd reg = ", round(rmsdReg,3))
Run the code above in your browser using DataLab