# Studijny program: "Pravdepodobnost a matematicka statistika" # Vyucujuci: Radoslav Harman, KAMS FMFI UK Bratislava # # Faktorova analyza (Factor analysis, FA) # Priklad je zalozeny na knihe: Everitt, B: R and S+ Companion to MA # Nacitat korelacnu maticu druguse.cor (RSPCMA) # FA pomocou MMV druguse.cor <- as.matrix(read.table( "http://www.iam.fmph.uniba.sk/ospm/Harman/data/drugcor.txt", header=TRUE)) print(druguse.cor) library(corrplot) corrplot(druguse.cor) help(factanal) druguse.fa <- factanal(covmat = druguse.cor, factors = 2, rotation = "none", n.obs = 1634) print(druguse.fa) druguse.fa <- factanal(covmat = druguse.cor, factors = 6, rotation = "none", n.obs = 1634) print(druguse.fa) print(druguse.fa$loadings) print(druguse.fa$uniqueness) varimax(druguse.fa$loadings) V <- varimax(druguse.fa$loadings)$rotmat print(druguse.fa$loadings %*% V) druguse.fa <- factanal(covmat = druguse.cor, factors = 6, rotation="varimax", n.obs=1634) print(druguse.fa) druguse.fa <- factanal(covmat=druguse.cor, factors=6, method="mle", rotation="none", n.obs=1634, start=rep(0.5, 13)) print(druguse.fa) druguse.fa <- factanal(covmat=druguse.cor, factors=6, method="mle", rotation="varimax", n.obs=1634, start=rep(0.5,13)) print(druguse.fa) corrplot(t(druguse.fa$loadings[1:13,1:6])) # Nepovinna Du: Urobit FA pre data decathlon z cviceni o PCA. # Najst pocet faktorov, urobit varimaxnu rotaciu, interpretovat vysledky. # Vypocitat faktorove skore, porovnat s PCA skore.