testscores <- matrix(scan(), ncol=5, byrow=T) 36 58 43 36 37 62 54 50 46 52 31 42 41 40 29 76 78 69 66 81 46 56 52 56 40 12 42 38 38 28 39 46 51 54 41 30 51 54 52 32 22 32 43 28 22 9 40 47 30 24 32 49 54 37 52 40 62 51 40 49 64 75 70 66 63 36 38 58 62 62 24 46 44 55 49 50 50 54 52 51 42 42 52 38 50 2 35 32 22 16 56 53 42 40 32 59 72 70 66 62 28 50 50 42 63 19 46 49 40 30 36 56 56 54 52 54 57 59 62 58 14 35 38 29 20 dimnames(testscores) <- list(1:25, c("diffgeom","complex", "algebra", "reals", "statistics")) testscores testscores.prc <- princomp(testscores) testscores.prc summary(testscores.prc) summary(testscores.prc, loadings=T) loadings(testscores.prc) plot(loadings(testscores.prc)) testscores_cor.prc <- princomp(testscores,cor=T) summary(testscores_cor.prc, loadings=T) plot(loadings(testscores_cor.prc)) exam81 <- matrix(scan(), ncol=3, byrow=T) 1 -2 0 -2 5 0 0 0 2 covmatrix_exam81 cov.obj <- list(cov = covmatrix, center = c(0,0,0)) cov.obj princov <- princomp(covlist = cov.obj) princov summary(princov) summary(princov,loadings=T,correlations=T) plot(testscores.prc, style="lines") plot(testscores.prc) testscores.eigen <- testscores.prc$sdev^2 testscores.eigen mean(testscores.eigen) testscores.prc$scores predict(testscores.prc) newscores <- matrix(scan(), ncol=5, byrow=T) 22 50 70 54 30 22 46 38 52 62 22 42 50 40 62 dimnames(newscores) <- list(1:3, c("diffgeom","complex", "algebra", "reals", "statistics")) newscores predict(testscores.prc, newdata=newscores) testscores <- matrix(scan(), ncol=5, byrow=T) 36 58 43 36 37 62 54 50 46 52 31 42 41 40 29 76 78 69 66 81 46 56 52 56 40 12 42 38 38 28 39 46 51 54 41 30 51 54 52 32 22 32 43 28 22 9 40 47 30 24 32 49 54 37 52 40 62 51 40 49 64 75 70 66 63 36 38 58 62 62 24 46 44 55 49 50 50 54 52 51 42 42 52 38 50 2 35 32 22 16 56 53 42 40 32 59 72 70 66 62 28 50 50 42 63 19 46 49 40 30 36 56 56 54 52 54 57 59 62 58 14 35 38 29 20 testscores.fa <- factanal(testscores, factors=2) testscores.fa summary(testscores.fa) loadings(testscores.fa) 1 - testscores.fa$uniquenesses testscores.fa2 <- factanal(testscores, factors=2, method="mle") testscores.fa2 factcov <- factanal(covlist = cov.obj) factcov plot(loadings(testscores.fa)) biplot(testscores.fa) newscores <- matrix(scan(), ncol=5, byrow=T) 22 50 70 54 30 22 46 38 52 62 22 42 50 40 62 predict(testscores.fa) predict(testscores.fa, newdata=newscores)