# 다변량 분석 — 판별분석과 요인분석 — 공식 ability.cov 예제의 공통성과 고유성
# 적용 범위: ability.cov 공식문서의 1요인 예제를 실행했습니다. 공통성·고유성 표와 한국어 이름의 막대그림을 추가했습니다. 원문은 공분산·상관 행렬의 자료상 한계도 설명합니다.
# 출처: https://stat.ethz.ch/R-manual/R-patched/library/datasets/html/ability.cov.html
# 출처: https://stat.ethz.ch/R-manual/R-patched/library/stats/html/factanal.html
# 실행 확인 환경: R version 4.6.2 (2026-10-29)
# 아래 코드를 실행하면 출력과 그림을 확인할 수 있습니다.

# 재현 설정: 같은 난수 방식과 출력 자릿수를 사용합니다.
RNGkind("Mersenne-Twister", "Inversion", "Rejection")
set.seed(2026)
options(width = 90, digits = 7, scipen = 7)

# ability.cov 공식문서의 1요인 분석입니다.
fa <- factanal(factors = 1, covmat = ability.cov)
fa$loadings
round(cbind(공통성 = 1 - fa$uniquenesses, 고유성 = fa$uniquenesses), 3)
barplot(1 - fa$uniquenesses, names.arg = c("일반", "그림", "블록", "미로", "읽기", "어휘"),
        col = "#2563EB", ylim = c(0, 1), main = "1요인 모형의 변수별 공통성", ylab = "공통성")
