Statistics::MDScaleStress Function

double MDScaleStress(TMtx *D, TMtx *DHat);

The stress factor for multidimensional scaling.

#NameTypeDescription
1DTMtx *Data distance matrix.
2DHatTMtx *Estimated distance matrix.

Returns: The stress factor.

Remarks:

Calculates the GOF statistics for multidimensional scaling. The stress factor is defined as:

stress=∑(di,j−d^i,j)2∑di,j2\text{stress} = \sqrt{\cfrac{\sum (d_{i,j}-\hat{d}_{i,j})^2}{\sum d_{i,j} ^2} }

where hat(d(i,j)) is the predicted distance based on the MDS model. In his original paper on multi dimensional scaling, Kruskal (1964) gave following advise about stress values based on his experience:

  • Stress | Goodness-of-fit
  • 0.2 — poor
  • 0.1 — fair
  • 0.05 — good
  • 0.025 — excellent
  • 0.000 — perfect

More recent articles caution against using a table like this since acceptable values of stress depends on the quality of the distance matrix and the number of objects in that matrix.

Examples
#include "MtxExpr.h"
#include "Units.Statistics.h"

using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Stats;
using namespace Dew::Stats::Units::Statistics;

void Example()
{
    Matrix D(2, 2);
    Matrix DHat(2, 2);

    D.SetIt(2, 2, false, DewArray<double>{ 0.3, 3, 2, 0.1 });
    DHat.SetIt(2, 2, false, DewArray<double>{ 0.1, 3.1, 2.2, 0.3 });

    // Calculate stress value - measure for GOF
    // Smaller stress value means better GOF.
    double stress = MDScaleStress(D, DHat);
}
See Also: Statistics::MDScaleMetric
Declared in Dew::Stats::Units::Statistics · Dew.Stats/Units.Statistics.h · Cross-compiler