Transcription of 統計科学研究所 R 主成分分析 - statistics.co.jp
1 1 2 R 3 4 :BMI (Body Mass Index) 5 6 ABCDEABCDEA B C D E A B C D E 7 ABCDEABCDEA B C D E A B C D E 8 ABCDEABCDEA B C D E A B C D E 9 10 11 R 12 : 13 166.
2 =9 4year 5year 6year 14 [csv] 16 prcomp biplot seiseki< ( ", header=T)result <-prcomp(seiseki, scale=T)summary(result)biplot(result)17 scale prcomp scale=T prcomp scale=F result <-prcomp(seiseki, scale=T)18 summary Standard deviation ( ) Proportion of Variance ( ) Cumulative Proportion ( ) 19 20 prcomp result$rotation: result$x: round round(result$x,disits=3): 21 round(result$rotation, 3) PC:PrincipalComponent 22 = + + + + + + + + 23 = + + + + + + + + 24 = + + + + + 25 -1 26 result$rotation result$sdev sweep apply URL.
3 R-Tips 24 apply <-sweep(result$rotation, MARGIN=2,result$sdev, FUN="*")subject <-c(" ", " ", " ", " ", " ", " ", " ", " ", " ")plot( [,1],pch=subject,ylim=c(-1,1), main="PC1")plot( [,2],pch=subject,ylim=c(-1,1), main="PC2")27 28 29 plot( [,1], [,2],pch=subject,xlim=c(-1,1),ylim=c(-1, 1), main=title)30 31 = + + + + + + + + 8796788277100778795 result$x32 : 8796788277100778795 33 result$x: 34 biplot R biplot result <-prcomp(seiseki, scale=T)biplot(result)35biplot 36 37 biplot 4 130 8 38 PC1 : PC2 : 39 prcomp obj$x obj$rotation biplot 40 URL R-Tips JIN S ~mjin/R/