[R] mahalanobis confusion

Clayton Springer csprin at brandybuck.ca.sandia.gov
Thu Jan 3 21:33:14 CET 2002


Dear r-help,

My understanding of Mahalanobois distance is that when calculating the distance
between a vector and the origin should be the same as the absolute value of that
vector and the origin.

Apparently they are different:

> mahalanobis(as.vector(featureset.all),as.vector(zero20),COVDtotal)
[1] 2.638582

> mahalanobis(as.vector(abs(featureset.all)),as.vector(zero20),COVDtotal)
[1] 7.458376


Can anyone give me some insight into what is going on?







There were the vectors used:

> featureset.all
 [1]  0.6152346 -0.6220563  0.6159433 -0.6865233  0.5832620  0.5379156
 [7]  0.6188826 -0.5838474  0.5558164 -0.6454835  0.6099608 -0.6083904
[13]  0.6768469  0.6761911 -0.5519884  0.6242095 -0.5272882 -0.6317221
[19]  0.5755202  0.6436219

> zero20
 [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

> COVDtotal
             X1          X2          X3          X4          X5          X6
X1   1.05967820 -0.10707972  0.07900894 -0.11026558  0.06998268  0.07632845
X2  -0.10707972  1.07949619 -0.12731106  0.08694136 -0.04438987 -0.06448543
X3   0.07900894 -0.12731106  1.10047417 -0.10260288  0.10462419  0.03106977
X4  -0.11026558  0.08694136 -0.10260288  1.09180220 -0.11520023 -0.05080485
X5   0.06998268 -0.04438987  0.10462419 -0.11520023  1.08372167  0.07315313
X6   0.07632845 -0.06448543  0.03106977 -0.05080485  0.07315313  1.09188363
X7   0.11063123 -0.08141751  0.13237254 -0.08852752  0.07388682  0.09528542
X8  -0.08381439  0.12026316 -0.08355477  0.06264001 -0.05734851 -0.11195461
X9   0.06296985 -0.07161381  0.12431183 -0.07784136  0.08356674  0.05189387
X10 -0.11204672  0.13975040 -0.11037433  0.08570182 -0.06277695 -0.03487686
X11  0.11903957 -0.10903915  0.08809574 -0.07815082  0.04762978  0.11193407
X12 -0.09370656  0.12271898 -0.09733936  0.08824304 -0.08304823 -0.09379661
X13  0.10933205 -0.09057703  0.12125739 -0.15732956  0.09481943  0.08323671
X14  0.10529610 -0.09744663  0.08032255 -0.10119252  0.06234175  0.06065037
X15 -0.08266871  0.07953344 -0.06585605  0.05625921 -0.08829623 -0.07704608
X16  0.07293699 -0.10314218  0.08811019 -0.11278371  0.06360624  0.08096588
X17 -0.07715753  0.07535229 -0.11229116  0.10637164 -0.03974483 -0.04946984
X18 -0.10696503  0.11797366 -0.15729346  0.08507554 -0.11331309 -0.09101065
X19  0.12832256 -0.06828018  0.08285553 -0.17515631  0.13462381  0.06286161
X20  0.10178729 -0.09395206  0.08629152 -0.12057459  0.08848807  0.02981165
             X7          X8          X9         X10         X11         X12
X1   0.11063123 -0.08381439  0.06296985 -0.11204672  0.11903957 -0.09370656
X2  -0.08141751  0.12026316 -0.07161381  0.13975040 -0.10903915  0.12271898
X3   0.13237254 -0.08355477  0.12431183 -0.11037433  0.08809574 -0.09733936
X4  -0.08852752  0.06264001 -0.07784136  0.08570182 -0.07815082  0.08824304
X5   0.07388682 -0.05734851  0.08356674 -0.06277695  0.04762978 -0.08304823
X6   0.09528542 -0.11195461  0.05189387 -0.03487686  0.11193407 -0.09379661
X7   1.08577268 -0.09797477  0.06781984 -0.11304299  0.09545183 -0.10580662
X8  -0.09797477  1.10198194 -0.07366283  0.06636062 -0.08480604  0.09904522
X9   0.06781984 -0.07366283  1.05239001 -0.11370459  0.08262987 -0.07737044
X10 -0.11304299  0.06636062 -0.11370459  1.10229003 -0.11033549  0.13175960
X11  0.09545183 -0.08480604  0.08262987 -0.11033549  1.10971715 -0.10008936
X12 -0.10580662  0.09904522 -0.07737044  0.13175960 -0.10008936  1.06434180
X13  0.10689546 -0.10163852  0.09954915 -0.09616881  0.11806829 -0.12041825
X14  0.11436260 -0.11530532  0.11007362 -0.08119362  0.12552855 -0.07775921
X15 -0.12945785  0.09931512 -0.07671993  0.14733664 -0.08053384  0.10103581
X16  0.11283056 -0.06778883  0.05151053 -0.08579178  0.05614164 -0.10019822
X17 -0.08553127  0.09685377 -0.09564487  0.10696805 -0.05081043  0.06812122
X18 -0.11385031  0.06771728 -0.13036095  0.11896321 -0.11624387  0.09183934
X19  0.08297921 -0.10961300  0.05993383 -0.10337781  0.09866079 -0.09255143
X20  0.04686709 -0.11134721  0.07076651 -0.09653739  0.10925212 -0.07555833
            X13         X14         X15         X16         X17         X18
X1   0.10933205  0.10529610 -0.08266871  0.07293699 -0.07715753 -0.10696503
X2  -0.09057703 -0.09744663  0.07953344 -0.10314218  0.07535229  0.11797366
X3   0.12125739  0.08032255 -0.06585605  0.08811019 -0.11229116 -0.15729346
X4  -0.15732956 -0.10119252  0.05625921 -0.11278371  0.10637164  0.08507554
X5   0.09481943  0.06234175 -0.08829623  0.06360624 -0.03974483 -0.11331309
X6   0.08323671  0.06065037 -0.07704608  0.08096588 -0.04946984 -0.09101065
X7   0.10689546  0.11436260 -0.12945785  0.11283056 -0.08553127 -0.11385031
X8  -0.10163852 -0.11530532  0.09931512 -0.06778883  0.09685377  0.06771728
X9   0.09954915  0.11007362 -0.07671993  0.05151053 -0.09564487 -0.13036095
X10 -0.09616881 -0.08119362  0.14733664 -0.08579178  0.10696805  0.11896321
X11  0.11806829  0.12552855 -0.08053384  0.05614164 -0.05081043 -0.11624387
X12 -0.12041825 -0.07775921  0.10103581 -0.10019822  0.06812122  0.09183934
X13  1.14484088  0.09993548 -0.08107109  0.11669608 -0.09978561 -0.11341623
X14  0.09993548  1.07022203 -0.12068641  0.12959327 -0.06042948 -0.09090972
X15 -0.08107109 -0.12068641  1.09079524 -0.08826068  0.07943239  0.09220653
X16  0.11669608  0.12959327 -0.08826068  1.11416921 -0.09210416 -0.09377126
X17 -0.09978561 -0.06042948  0.07943239 -0.09210416  1.03520003  0.12858473
X18 -0.11341623 -0.09090972  0.09220653 -0.09377126  0.12858473  1.11017146
X19  0.10733188  0.08778220 -0.06650838  0.05337207 -0.04552405 -0.10608081
X20  0.09451811  0.07541007 -0.05356769  0.07092049 -0.06626285 -0.10648554
            X19         X20
X1   0.12832256  0.10178729
X2  -0.06828018 -0.09395206
X3   0.08285553  0.08629152
X4  -0.17515631 -0.12057459
X5   0.13462381  0.08848807
X6   0.06286161  0.02981165
X7   0.08297921  0.04686709
X8  -0.10961300 -0.11134721
X9   0.05993383  0.07076651
X10 -0.10337781 -0.09653739
X11  0.09866079  0.10925212
X12 -0.09255143 -0.07555833
X13  0.10733188  0.09451811
X14  0.08778220  0.07541007
X15 -0.06650838 -0.05356769
X16  0.05337207  0.07092049
X17 -0.04552405 -0.06626285
X18 -0.10608081 -0.10648554
X19  1.08391161  0.09885423
X20  0.09885423  1.14504480

-- 
Clayton Springer, Ph. D.
Sandia National Laboratories                      csprin at ca.sandia.gov
Biosystems Research Department                    (925) 294-2143
P.O. Box 969, MS 9951                fax:         (925) 294-3020
Livermore, CA, 94551-0969

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list