다차원 척도법(Multi Demensional Scaling, MDS)



# 데이터준비 
autoparts <- read.csv("autoparts.csv", header = T)
autoparts4 <- autoparts[autoparts$prod_no=="45231-P3B750", -c(1:7)]
autoparts4$flag <- 1
autoparts4$flag[autoparts4$c_thickness > 32] <- 2
autoparts4$flag[autoparts4$c_thickness < 20] <- 3
table(autoparts4$flag)
## 
##  1  2  3 
## 50 17  2
head(autoparts4)
##       fix_time a_speed b_speed separation s_separation rate_terms  mpa
## 28155     82.7   0.657   1.857      221.8        673.5         88 73.7
## 28156     82.7   0.659   1.840      223.9        672.7         88 73.8
## 28157     82.8   0.670   1.839      220.7        673.8         88 73.8
## 28158     82.8   0.653   1.824      221.2        674.4         87 73.7
## 28159     82.8   0.675   1.826      222.9        674.6         87 73.8
## 28160     82.6   0.653   1.846      222.7        674.5         87 73.8
##       load_time highpressure_time c_thickness flag
## 28155      19.6                70        28.5    1
## 28156      19.6                82        27.2    1
## 28157      19.7                73        29.3    1
## 28158      19.7                74        28.2    1
## 28159      19.7                81        26.3    1
## 28160      19.6                69        26.6    1
# MDS 분석
d <- dist(autoparts4[,1:9])
fit <- cmdscale(d)
head(fit)
##            [,1]      [,2]
## 28155 -16.39510 -2.178715
## 28156 -17.76661 -3.919369
## 28157 -15.66237 -3.554004
## 28158 -15.48761 -3.793146
## 28159 -16.20712 -4.972811
## 28160 -16.38329 -2.121006
x <- fit[,1]
y <- fit[,2]

# type="n" 옵션은 실제 그리지는 않고 자리만 잡음
plot(x,, xlab="Coordinate 1", ylab="Coordinate 2", main="MDS-autopart4", type="n")
text(x,y, labels=autoparts4$flag, cex=.7)