1

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)
4

1 回答 1

1

新坐标系的原点是数据集的重心(又名质心):

colMeans(data)
# X1 X2 
# 37 20 
于 2013-01-04T18:16:09.660 回答