R language Access Menu

Title Text Both  

Multidimensional Scaling

This is also a very useful technique which can be applied not only to numeric but also to mixed (numeric and categorical) data. It shows how close the individual cases (rows) are to each other and whether they are forming any clusters. Following function (adapted from https://www.statmethods.net/advstats/mds.html) can be used:


> mdsfn = function(mydf){
    d = daisy(mydf) 
    fit <- cmdscale(d,eig=TRUE, k=2)

    # plot solution
    plot(fit$points, xlab="Coordinate 1", ylab="Coordinate 2", main="Metric MDS", type="n")
    abline(h=0, v=0)
    text(fit$points, labels=row.names(mydf), cex=.7)

> mdsfn(bwdf)

Output graph:


The plot shows that all rows starting with '1-' (indicating low birth weight) are in upper part of the graph.

Maechler, M., Rousseeuw, P., Struyf, A., Hubert, M., Hornik, K.(2015).cluster: Cluster Analysis Basics and Extensions. R package version 2.0.2.

    Comments & Feedback