USArrests(1973년 미국 50개주 십만명당 강력범죄수)
# 4개 변수간 산점도
> library(datasets)
> data("USArrests")
> pairs(USArrests, panel=panel.smooth, main="USArrests data")
# 주성분 분석실시
> US.prin <- princomp(USArrests, cor=TRUE)
# 주성분 분석결과 요약
> summary(US.prin)
Importance of components:
Comp.1 Comp.2 Comp.3 Comp.4
Standard deviation 1.5748783 0.9948694 0.5971291 0.41644938
Proportion of Variance 0.6200604 0.2474413 0.0891408 0.04335752
Cumulative Proportion 0.6200604 0.8675017 0.9566425 1.00000000
# Murder, Assault, UrbanPop, Rape 4개 변수의 주성분 Comp.1~Comp.4에 대한 기여도
> loadings(US.prin)
Loadings:
Comp.1 Comp.2 Comp.3 Comp.4
Murder -0.536 0.418 -0.341 0.649
Assault -0.583 0.188 -0.268 -0.743
UrbanPop -0.278 -0.873 -0.378 0.134
Rape -0.543 -0.167 0.818
Comp.1 Comp.2 Comp.3 Comp.4
SS loadings 1.00 1.00 1.00 1.00
Proportion Var 0.25 0.25 0.25 0.25
Cumulative Var 0.25 0.50 0.75 1.00
# 각 지역(record)의 주성분 Comp.1~Comp.4 선형결합
> head(US.prin$scores)
Comp.1 Comp.2 Comp.3 Comp.4
Alabama -0.9855659 1.1333924 -0.44426879 0.156267145
Alaska -1.9501378 1.0732133 2.04000333 -0.438583440
Arizona -1.7631635 -0.7459568 0.05478082 -0.834652924
Arkansas 0.1414203 1.1197968 0.11457369 -0.182810896
California -2.5239801 -1.5429340 0.59855680 -0.341996478
Colorado -1.5145629 -0.9875551 1.09500699 0.001464887