You are here: Symbol Reference > StatTools Namespace > Classes > TMtxMDScaling Class
Stats Master VCL
ContentsIndex
Example

The "beauty" of MDS is that we can analyze any kind of distance or similarity matrix. These similarities can represent people's ratings of similarities between objects, the percent agreement between judges, the number of times a subjects fails to discriminate between stimuli, etc. For example, MDS methods used to be very popular in psychological research on person perception where similarities between trait descriptors were analyzed to uncover the underlying dimensionality of people's perceptions of traits (see, for example Rosenberg, 1977). In this example 6x6 similarities (extracted directly from questionare correlation matrix) is used to perform classical MD scaling.

Uses StatTools, Statistics, MtxExpr;
procedure Example(mds: TMtxMDScaling);
begin
  // similarities matrix (symmetric with 1.0 on diagonal)ΕΎ
  mds.Data.SetIt(5,5,false,
      [ 1.00, 0.3, 0.2, 0.25, 0.33,
        0.30, 1.0, 0.11, 0.21, 0.8,
        0.20, 0.11, 1.0, 0.40, 0.5,
        0.25, 0.21, 1.0, 0.10, 0.05,
        0.33, 0.80, 0.5, 0.05, 1.00]);
  mds.DataFormat := mdFormatSimilarities;
  // use "standard" Euclidian metric
  mds.DistanceMethod := pwdistEuclidian;
  // define number of desired dimensions (1)
  mds.Dimensions := 1;
  // Do the math
  mds.Recalc;
  // check Stress, DHat, EigeValues to evaluate GOF if (1) dimension is used
end;
#include "Math387.hpp"
#include "StatTools.hpp"
#include "Statistics.hpp"
void __fastcall Example(TMtxMDScaling* mds)
{
    const int aDataLen = 25;
    double aData[aDataLen] = {1.00, 0.3, 0.2, 0.25, 0.33,
                0.30, 1.0, 0.11, 0.21, 0.8,
                0.20, 0.11, 1.0, 0.40, 0.5,
                0.25, 0.21, 1.0, 0.10, 0.05,
                0.33, 0.80, 0.5, 0.05, 1.00};

    // similarities matrix (symmetric with 1.0 on diagonal)
    mds->Data->SetIt(5,5,false, aData, aDataLen-1);

      mds->DataFormat = mdFormatSimilarities;
      // use "standard" Euclidian metric
      mds->DistanceMethod = pwdistEuclidian;
      // define number of desired dimensions (1)
      mds->Dimensions = 1;
      // Do the math
      mds->Recalc();
      // check Stress, DHat, EigeValues to evaluate GOF if (1) dimension is used
}
Copyright (c) 1999-2025 by Dew Research. All rights reserved.