PCA将原始数据点投影到新的坐标系中,我想确定将旧坐标系的原点与R中新坐标系的原点相连的向量。
这是我到目前为止所编码的内容:
data <- data.frame(cbind(c(5,15,21,29,31,43,49,51,61,65),
c(33,35,24,21,27,16,18,10,4,12)))
# Subtract columns by their mean and
# divide with their standard deviation
scaled_data <- scale(data, center=TRUE, scale=TRUE)
scaled_data
plot(scaled_data)
# Correlation Matrix
corrmat <- cor(scaled_data)
corrmat
# Compute Eigenvalues and Eigenvectors
eigen <- eigen(corrmat)
eigenvectors <- eigen$vectors
eigenvectors
eigenvalues <- eigen$values
eigenvalues
# Transform data
transformed_data <- (data.matrix(scaled_data) %*% eigenvectors)*sqrt(2)
transformed_data
plot(transformed_data)
答案 0 :(得分:1)
新坐标系的起源是数据集的重心(a.k.a.质心):
colMeans(data)
# X1 X2
# 37 20