Proper use of MDS and PCA

Assume I have a 20*85 matrix. Here is my code

    M = fit(PCA, matrix; maxoutdim=2)
    Yte = predict(M, matrix)
M1 = fit(MDS, matrix; maxoutdim=2, distances=false)
    Yte1 = predict(M1)

My Yte and Yte1 are identically same. Did I use PCA and MDS properly?

From the documentation:

Compute an embedding of X points by classical multidimensional scaling (MDS). There are two calling options, specified via the required keyword argument distances:

mds = fit(MDS, X; distances=false, maxoutdim=size(X,1)-1)

where X is the data matrix. Distances between pairs of columns of X are computed using the Euclidean norm. This is equivalent to performing PCA on X.

So your code looks ok. :wink:

Do you mean when distance = false, MDS is equivalent to PCA?

I changed it to

M1 = fit(MDS, pairwise(Euclidean(), matrix); maxoutdim=2, distances=true)
  Yte1 = predict(M1)

as the documentation said, but Yte and Yte1 are still the same.

As I understand it, doing distance=false makes it use Euclidean distance, while distance=true makes it use a distance metric you provide. Here you provided Euclidean, so results are exactly the same.
And it seems that using Euclidean MDS is exactly equal to PCA (I have no experience with MDS, just following comments from the net, e.g. here)