depth.space.Mahalanobis: Calculate Depth Space using Mahalanobis Depth

Description Usage Arguments Details Value References See Also Examples

View source: R/mahalanobis.scaling.r

Description

Calculates the representation of the training classes in depth space using Mahalanobis depth.

Usage

1
depth.space.Mahalanobis(data, cardinalities, mah.estimate = "moment", mah.parMcd = 0.75)

Arguments

data

Matrix containing training sample where each row is a d-dimensional object, and objects of each class are kept together so that the matrix can be thought of as containing blocks of objects representing classes.

cardinalities

Numerical vector of cardinalities of each class in data, each entry corresponds to one class.

mah.estimate

is a character string specifying which estimates to use when calculating the Mahalanobis depth; can be "moment" or "MCD", determining whether traditional moment or Minimum Covariance Determinant (MCD) (see covMcd) estimates for mean and covariance are used. By default "moment" is used.

mah.parMcd

is the value of the argument alpha for the function covMcd; is used when mah.estimate = "MCD".

Details

The depth representation is calculated in the same way as in depth.Mahalanobis, see 'References' for more information and details.

Value

Matrix of objects, each object (row) is represented via its depths (columns) w.r.t. each of the classes of the training sample; order of the classes in columns corresponds to the one in the argument cardinalities.

References

Mahalanobis, P. (1936). On the generalized distance in statistics. Proceedings of the National Academy India 12 49–55.

Liu, R.Y. (1992). Data depth and multivariate rank tests. In: Dodge, Y. (ed.), L1-Statistics and Related Methods, North-Holland (Amsterdam), 279–294.

Lopuhaa, H.P. and Rousseeuw, P.J. (1991). Breakdown points of affine equivariant estimators of multivariate location and covariance matrices. The Annals of Statistics 19 229–248.

Rousseeuw, P.J. and Leroy, A.M. (1987). Robust Regression and Outlier Detection. John Wiley & Sons (New York).

Zuo, Y.J. and Serfling, R. (2000). General notions of statistical depth function. The Annals of Statistics 28 461–482.

See Also

ddalpha.train and ddalpha.classify for application, depth.Mahalanobis for calculation of Mahalanobis depth.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Generate a bivariate normal location-shift classification task
# containing 20 training objects
class1 <- mvrnorm(10, c(0,0), 
                  matrix(c(1,1,1,4), nrow = 2, ncol = 2, byrow = TRUE))
class2 <- mvrnorm(10, c(2,2), 
                  matrix(c(1,1,1,4), nrow = 2, ncol = 2, byrow = TRUE))
data <- rbind(class1, class2)
# Get depth space using Mahalanobis depth
depth.space.Mahalanobis(data, c(10, 10))
depth.space.Mahalanobis(data, c(10, 10), mah.estimate = "MCD", mah.parMcd = 0.75)

data <- getdata("hemophilia")
cardinalities = c(sum(data$gr == "normal"), sum(data$gr == "carrier"))
depth.space.Mahalanobis(data[,1:2], cardinalities)

Example output

Loading required package: MASS
Loading required package: class
Loading required package: robustbase
Loading required package: sfsmisc
Loading required package: geometry
            [,1]       [,2]
 [1,] 0.53953192 0.18988631
 [2,] 0.35608754 0.24880317
 [3,] 0.46904166 0.11294420
 [4,] 0.48142029 0.27743405
 [5,] 0.19524612 0.07949869
 [6,] 0.61209356 0.15459749
 [7,] 0.19005994 0.09231716
 [8,] 0.74433812 0.31179153
 [9,] 0.50105669 0.49193251
[10,] 0.26505401 0.53946344
[11,] 0.02644503 0.13999505
[12,] 0.14940403 0.64833941
[13,] 0.83554954 0.31867395
[14,] 0.10675904 0.17077831
[15,] 0.19046839 0.41382324
[16,] 0.20658458 0.78230204
[17,] 0.10725804 0.40504811
[18,] 0.12524476 0.73305226
[19,] 0.10115565 0.73025454
[20,] 0.29896808 0.70235412
            [,1]       [,2]
 [1,] 0.53953192 0.12808152
 [2,] 0.35608754 0.28667371
 [3,] 0.46904166 0.11089492
 [4,] 0.48142029 0.16504872
 [5,] 0.19524612 0.09442337
 [6,] 0.61209356 0.17202297
 [7,] 0.19005994 0.06763169
 [8,] 0.74433812 0.22266410
 [9,] 0.50105669 0.38974258
[10,] 0.26505401 0.35359081
[11,] 0.02644503 0.07862914
[12,] 0.14940403 0.61668185
[13,] 0.83554954 0.26853411
[14,] 0.10675904 0.15393390
[15,] 0.19046839 0.27496032
[16,] 0.20658458 0.63271199
[17,] 0.10725804 0.39032773
[18,] 0.12524476 0.73493517
[19,] 0.10115565 0.76139437
[20,] 0.29896808 0.54770736
            [,1]       [,2]
 [1,] 0.14127715 0.07249604
 [2,] 0.65531390 0.16802826
 [3,] 0.28555434 0.35631018
 [4,] 0.66786410 0.23883266
 [5,] 0.17347329 0.54433805
 [6,] 0.65681980 0.23327340
 [7,] 0.27792463 0.55096209
 [8,] 0.49785472 0.24783915
 [9,] 0.40153720 0.13882789
[10,] 0.62589154 0.14708655
[11,] 0.09815101 0.09317992
[12,] 0.56064618 0.24846463
[13,] 0.44731054 0.11910546
[14,] 0.42230889 0.16038615
[15,] 0.90130420 0.23877251
[16,] 0.17367167 0.11011520
[17,] 0.15562689 0.20337827
[18,] 0.91843651 0.25508123
[19,] 0.20600583 0.08497850
[20,] 0.46481989 0.42080541
[21,] 0.33449171 0.12766795
[22,] 0.19367545 0.07933811
[23,] 0.99331025 0.21474728
[24,] 0.85967130 0.18891962
[25,] 0.80036737 0.28349227
[26,] 0.43732983 0.12866795
[27,] 0.66444142 0.21737720
[28,] 0.88356859 0.17492607
[29,] 0.55111386 0.37770487
[30,] 0.87623334 0.17537191
[31,] 0.04460065 0.38506775
[32,] 0.26397273 0.34035574
[33,] 0.05541145 0.37579839
[34,] 0.12740188 0.21927680
[35,] 0.46463855 0.33674864
[36,] 0.05152949 0.13005940
[37,] 0.04040709 0.33085313
[38,] 0.10871487 0.45047253
[39,] 0.26247278 0.40596091
[40,] 0.05385409 0.52224316
[41,] 0.07138167 0.46917625
[42,] 0.09934043 0.89417109
[43,] 0.03883414 0.29663084
[44,] 0.07427574 0.59968190
[45,] 0.14477110 0.93105278
[46,] 0.02459776 0.14062930
[47,] 0.22043255 0.39677074
[48,] 0.04130225 0.29805313
[49,] 0.10415333 0.27729750
[50,] 0.06095623 0.33339991
[51,] 0.26466856 0.63545756
[52,] 0.09306951 0.63094439
[53,] 0.03127312 0.17940262
[54,] 0.21356743 0.67968185
[55,] 0.29383804 0.56589102
[56,] 0.08092117 0.85673151
[57,] 0.28285961 0.60629068
[58,] 0.26044234 0.21989426
[59,] 0.11658947 0.64334789
[60,] 0.15577621 0.28522282
[61,] 0.23946722 0.51518608
[62,] 0.20536734 0.21400831
[63,] 0.21667441 0.23271404
[64,] 0.82818344 0.28327249
[65,] 0.09490155 0.40951472
[66,] 0.13379247 0.48507213
[67,] 0.36917145 0.30214495
[68,] 0.08059388 0.72737662
[69,] 0.40240867 0.19686237
[70,] 0.05454910 0.52434387
[71,] 0.04482697 0.25718186
[72,] 0.06756829 0.38601645
[73,] 0.21193330 0.28431346
[74,] 0.05672511 0.43445916
[75,] 0.03701187 0.27021320

ddalpha documentation built on Jan. 9, 2020, 5:09 p.m.