R language 3.14 multidimensional scaling method MDS

  • Definition
    Multidimensional scaling is a statistical analysis method that uses similarity data between objects to reveal the spatial relationship between them.
  • Type
    1. Quantitative model
    If the similarity data required by the model is measured using a distance scale or a ratio scale
    2. Non-metric model
    If the model requires similar data at the ordinal scale level, it is called a non-metric model

The usage of the classical function cmdscale for multi-dimensional scaling analysis:
cmdscale (D, k=2,...)
D represents the distance matrix for multi-dimensional scaling analysis, k represents the dimension, and the default is 2 dimensions

D=matrix(c(0,1,sqrt(3),2,sqrt(3),1,1,1,0,1,sqrt(3),2,sqrt(3),1,sqrt(3),1,0,1,sqrt(3),2,1,2,sqrt(3),1,0,1,sqrt(3),1,sqrt(3),2,sqrt(3),1,0,1,1,1,sqrt(3),2,sqrt(3),1,0,1,1,1,1,1,1,1,0),nrow=7,ncol=7)
round(cmdscale(D),3) 

Insert picture description here
The classical solution of D,
eg, mark the city on a two-dimensional plane according to the distance matrix of the city
Insert picture description here

MSD1=cmdscale(X)
MSD1

Insert picture description here
Calculate ten coordinate points of two-dimensional coordinates,
draw icon points

plot(MSD1[,1],MSD1[,2],type = 'n',asp = 1)
text(MSD1[,1],MSD1[,2],labels = rownames(X))

Insert picture description here
2.
The usage of non-metric multi-dimensional scaling analysis function isOMDS
needs to call the package MASS
isoMDS (D, k=2,...)
D stands for distance matrix, k stands for dimension.
Note that D must be a matrix. Use the function as.matri to convert the data frame, etc. Convert other forms into matrix form.

D=as.matrix(X)
MDS2=isoMDS(D,k=2)
MSD2

Insert picture description here
The pressure index is 0.04, less than 0.05 is very good

plot(MDS2$points[,1],MDS2$points[,2],type = 'n')
text(MDS2$points[,1],MDS2$points[,2],labels = rownames(D))

Insert picture description here

The calculation process of the multidimensional scaling method is basically the same as the classical solution :
1. Confirm the research purpose
2. Select samples and variables
3. Calculate the distance matrix
between samples 4. Analyze the distance matrix between samples
5. Calculate the classical solution of the distance matrix
6. Test the fitting effect of the model
Insert picture description here

Guess you like

Origin blog.csdn.net/m0_46445293/article/details/104855674