我正在尝试将一个新点投影A(x, y, z)
到R
. 这是我到目前为止所拥有的:
set.seed(1)
x <- matrix(rnorm(3*10), ncol = 3)
DM <- dist(x)
MDS <- cmdscale(DM)
# New data point to be projected
A <- c(1, 2, 3)
我不A
直接包括x
然后拟合 MDS,因为它会影响空间坐标。有切实可行的解决方案吗?
编辑
我相信我通过估计 beta 来预测 MDS 轴找到了解决方案:
x1 <- cbind(1, x) # add intercept
B <- solve(t(x1) %*% x1) %*% t(x1) %*% MDS # Betas
> MDS
[,1] [,2]
[1,] -1.80789362 0.06801597
[2,] -0.64418055 -0.21163109
[3,] 0.04694820 -1.27040928
[4,] 3.39617277 -0.21657115
[5,] -0.96981358 0.46269025
[6,] -0.24716695 -0.79861234
[7,] 0.33620625 0.02618564
[8,] 0.62473570 1.35544267
[9,] 0.01895042 0.80023822
[10,] -0.75395865 -0.21534889
> x1 %*% B # same as MDS
[,1] [,2]
[1,] -1.80789362 0.06801597
[2,] -0.64418055 -0.21163109
[3,] 0.04694820 -1.27040928
[4,] 3.39617277 -0.21657115
[5,] -0.96981358 0.46269025
[6,] -0.24716695 -0.79861234
[7,] 0.33620625 0.02618564
[8,] 0.62473570 1.35544267
[9,] 0.01895042 0.80023822
[10,] -0.75395865 -0.21534889
A <- c(1, 2, 3)
A <- c(1, A) # add intercept
> A %*% B # coordinates of A in the MDS plane
[,1] [,2]
[1,] -2.759456 0.5927178
我的程序正确吗?