공통 부분 만들기
common = rnorm(100)
noise 만들기
noise1 = rnorm(100)
noise2 = rnorm(100)
common과 noise의 패턴 확인하기
plot(common, noise1)
plot(common, noise2)
noise간의 패턴 확인하기
plot(noise1, noise2)
x와 y 만들기
x = common + noise1
y = common + noise2
x와 y의 그래프 그리기
plot(x, y)
common
을 많이 포함하고 있음데이터 합치기
m = cbind(x, y)
주성분분석
p = prcomp(m)
summary(p)
Importance of components: PC1 PC2 Standard deviation 1.7914 0.9493 Proportion of Variance 0.7807 0.2193 Cumulative Proportion 0.7807 1.0000
그래프 그리기
biplot(p)
PC1의 값 확인하기
p$x[,1]
[1] -0.98795277 0.64335003 1.79455844 -3.08241993 0.33687463 1.45945812 [7] -0.03360677 0.22413590 -0.44536893 -2.01221627 -0.42939889 -2.06908565 [13] -0.71763627 -0.38779143 1.15619474 0.80791016 -1.61639416 -1.52345988 [19] -0.85129985 3.93143491 0.78038418 -0.68307818 2.52389724 2.09659495 [25] 0.57851410 -2.38327648 2.54868494 -1.93400420 -0.87344195 -0.95000285 [31] 2.11439498 -0.61141088 -2.40733316 -0.07701473 -3.14243213 -2.59687419 [37] -5.54003670 -3.35452793 0.32813805 -0.58451049 1.94138764 -0.16045600 [43] -1.47129678 0.11978255 -0.45039470 -0.82879317 0.64841647 -1.20599416 [49] -0.11630308 -0.18610813 -2.42125387 0.08737658 -0.01980997 -1.48757516 [55] -0.87774181 1.56158830 3.30808958 -2.62339687 1.93196082 -1.53650729 [61] 1.12001123 3.25462527 -0.14209389 -2.25716986 0.59778361 2.55206557 [67] -0.52986506 1.11640406 2.01468372 2.06092748 1.06083214 0.77716220 [73] -0.18705590 0.40950268 5.46288187 -1.18552092 -2.08750620 1.88734045 [79] 0.60656955 -0.16062552 -2.79888693 0.10936862 -1.68120219 0.70831084 [85] 1.33798209 2.67982564 1.06718298 -1.01821006 -0.81207231 -1.65322951 [91] 0.33879661 -1.41549015 0.67728237 1.39304290 2.07974775 2.23183102 [97] -1.93305777 0.38782348 1.82479118 1.86228934
common과 PC1 그래프 그리기
plot(common, p$x[,1])
위와 비슷하지만 noise의 비중을 줄임
x = common + 0.5 * noise1
y = common + 0.5 * noise2
x와 y의 그래프 그리기
plot(x, y)
데이터 합치기
m = cbind(x, y)
주성분분석
p = prcomp(m)
summary(p)
Importance of components: PC1 PC2 Standard deviation 1.5304 0.47418 Proportion of Variance 0.9124 0.08759 Cumulative Proportion 0.9124 1.00000
그래프 그리기
biplot(p)
common과 PC1 그래프 그리기
plot(common, p$x[,1])
보기 쉽게 common과 PC1 그래프 그리기
plot(common, -p$x[,1])
위와 비슷하지만 noise의 비중을 늘림
x = common + 2 * noise1
y = common + 2 * noise2
x와 y의 그래프 그리기
plot(x, y)
데이터 합치기
m = cbind(x, y)
주성분분석
p = prcomp(m)
summary(p)
Importance of components: PC1 PC2 Standard deviation 2.5637 1.8986 Proportion of Variance 0.6458 0.3542 Cumulative Proportion 0.6458 1.0000
그래프 그리기
biplot(p)
common과 PC1 그래프 그리기
plot(common, -p$x[,1])