Compute (versions of) the (multivariate) “Comedian” covariance, i.e., multivariate location and scatter estimator

covComed(X, n.iter = 2, reweight = FALSE, tolSolve = control$tolSolve,
         trace = control$trace, wgtFUN = control$wgtFUN,
         control = rrcov.control())
<!-- % comedian(...) -->
<!-- % COM(...) -->

Arguments

X

data matrix of dimension, say \(n \times p\).

n.iter

number of comedian() iterations. Can be as low as zero.

reweight

logical indicating if the final distances and weights should be recomputed from the final cov and center. The default is currently FALSE because that was implicit in the first version of the R code.

tolSolve

a numerical tolerance passed to solve.

trace

logical (or integer) indicating if intermediate results should be printed; defaults to FALSE; values \(\ge 2\) also produce print from the internal (Fortran) code.

wgtFUN

a character string or function, specifying how the weights for the reweighting step should be computed. The default, wgtFUN = "01.original" corresponds to 0-1 weights as proposed originally. Other predefined string options are available, though experimental, see the experimental .wgtFUN.covComed object.

control

a list with estimation options - this includes those above provided in the function specification, see rrcov.control for the defaults. If control is supplied, the parameters from it will be used. If parameters are passed also in the invocation statement, they will override the corresponding elements of the control object.

Details

.. not yet ..

Value

an object of class "covComed" which is basically a list with components

comp1

Description of 'comp1'

comp2

Description of 'comp2'

... FIXME ...

References

Falk, M. (1997) On mad and comedians. Annals of the Institute of Statistical Mathematics 49, 615–644.

Falk, M. (1998). A note on the comedian for elliptical distributions. Journal of Multivariate Analysis 67, 306–317.

Author

Maria Anna di Palma (initial), Valentin Todorov and Martin Maechler

See also

covMcd, etc

Examples

data(hbk)
hbk.x <- data.matrix(hbk[, 1:3])
(cc1 <- covComed(hbk.x))
#> $Z
#>               [,1]         [,2]         [,3]
#>  [1,] -6.087809254 -13.09999354 14.705465671
#>  [2,] -5.777228968 -13.64634107 15.052212929
#>  [3,] -6.536101218 -13.56143334 16.162000384
#>  [4,] -6.111574526 -14.34825012 16.565974104
#>  [5,] -6.297788761 -14.10072524 16.218097351
#>  [6,] -6.468706561 -13.63735058 15.146601077
#>  [7,] -6.286768634 -13.93004059 15.095480588
#>  [8,] -6.015541425 -13.10704917 14.996115962
#>  [9,] -6.000161208 -13.83327590 16.207379832
#> [10,] -5.794443424 -13.18932959 15.865515487
#> [11,] -6.772255277 -16.00427044 18.279792818
#> [12,] -7.452170489 -15.48206281 19.363262321
#> [13,] -7.139581165 -17.23266496 17.612583607
#> [14,] -6.281552750 -22.08802267 17.466612096
#> [15,] -1.753276252  -1.94492066  0.900244788
#> [16,] -1.518745224  -1.45732603 -0.068937934
#> [17,]  0.056461929  -0.98333683  0.070787684
#> [18,] -1.237065583  -1.11058694  0.941557472
#> [19,] -0.385035223  -1.84343471  0.772375796
#> [20,] -1.583588589  -2.24313094  0.960733521
#> [21,] -1.359513613  -1.48462556  0.853003931
#> [22,] -0.184740103  -2.02156566  0.955390062
#> [23,] -0.979162178  -1.49514259  0.271483571
#> [24,] -0.600659567  -1.46325462  0.144765063
#> [25,] -0.538967978  -0.04476564  0.165082266
#> [26,] -0.474430108  -2.11610253  1.258598292
#> [27,] -1.768008612  -1.71917505  1.362700678
#> [28,] -1.014187954  -0.60481610  0.991036330
#> [29,] -0.627711388  -0.61257300  0.353711359
#> [30,] -0.795553846  -0.56210932  1.809733937
#> [31,] -1.595977246  -0.98773866  0.342105112
#> [32,] -0.172540831  -1.49186780  0.077113437
#> [33,] -0.730448282  -1.98650923  0.670773168
#> [34,] -0.248662904  -0.03281096  0.367377806
#> [35,] -1.675534766  -1.65407663  1.432683871
#> [36,] -0.636813495  -1.45611893  1.386645086
#> [37,] -0.081864817  -1.90854196  1.368565884
#> [38,] -0.732417294  -0.78947036 -0.006211199
#> [39,] -1.153883229  -0.10394431  0.547569358
#> [40,] -0.244845068  -1.27225483  0.589560320
#> [41,] -1.858105966  -1.17252575  1.379849175
#> [42,] -0.276773680  -0.69577641  1.463770182
#> [43,]  0.035145964  -2.04496035  0.412233459
#> [44,] -1.100573075  -0.45459706  1.668345700
#> [45,] -1.009944435  -0.14175204  0.221817581
#> [46,] -1.088322811  -0.44907680  1.556736479
#> [47,] -1.588108893  -0.18436993  0.269477008
#> [48,] -1.709890863  -1.16516834  1.453094640
#> [49,] -1.603863802  -1.68482873  0.816281804
#> [50,] -1.137764137  -1.86204552  1.424810053
#> [51,] -1.143357981  -1.00531132  0.051235042
#> [52,] -1.745477096  -0.51109567  0.462497867
#> [53,] -0.339291545  -0.34565598  1.813905925
#> [54,] -0.455454229  -1.87878408  0.026923653
#> [55,] -0.209291624  -1.50842858  0.411941103
#> [56,] -0.843743212  -2.04117952  0.315953302
#> [57,] -0.938855749  -0.50782087  0.268127733
#> [58,] -1.180585450  -2.20020244  0.610796569
#> [59,] -0.916717128  -1.42014834  1.527542176
#> [60,] -0.292051912  -1.01790487  1.785841117
#> [61,] -0.243527532  -2.17415416  1.564138090
#> [62,] -0.477101589  -0.09974653  0.112539927
#> [63,] -0.462212633  -1.69268334 -0.021226919
#> [64,] -1.489302327  -2.00788017  1.379012036
#> [65,] -1.164251881  -0.56976851  1.372592718
#> [66,] -0.074593329  -1.12886970  0.388885422
#> [67,] -0.810759263  -1.30935246  0.525610524
#> [68,] -0.118823198  -0.03373395  0.608037103
#> [69,] -1.021543223  -0.44241184  0.035833400
#> [70,] -0.597617014  -1.45826668  1.504067926
#> [71,] -1.165343625  -1.66551664  1.091822808
#> [72,] -0.314667210  -1.28390773  0.751160536
#> [73,] -0.216086436  -1.10977051  1.166887704
#> [74,] -0.003522848  -1.38865986  0.836744161
#> [75,] -0.296415621  -0.32633507  1.423273648
#> 
#> $raw.cov
#>              [,1]         [,2]       [,3]
#> [1,]  3.562613961 -0.007646157 0.06862357
#> [2,] -0.007646157  2.491357097 0.01816029
#> [3,]  0.068623567  0.018160292 2.47944913
#> 
#> $raw.center
#> [1] 1.914091 2.197396 2.021472
#> 
#> $raw.mah
#>  [1] 413.26701462 436.34206667 483.89439421 516.12597478 497.64308013
#>  [6] 446.87547230 450.68952609 423.02595844 486.90613102 455.05264601
#> [11] 644.33160094 686.60550680 659.58619698 831.83678287   0.82050583
#> [16]   1.62268762   2.45249023   0.18489708   0.61144075   0.98643384
#> [21]   0.13938812   1.04835988   0.61078870   1.03058170   3.19340659
#> [26]   0.87160194   0.86790315   0.78776229   1.39971095   1.83966446
#> [31]   1.08355679   1.73764914   0.48366919   3.24454426   0.77906968
#> [36]   0.38050679   1.32878511   1.76461960   2.21118811   0.83103368
#> [41]   1.05597753   1.51841502   1.89180190   1.73500319   2.56336692
#> [46]   1.55853769   2.70036798   0.90874897   0.44080452   0.46146299
#> [51]   1.30059971   1.84189093   2.73922588   1.62580983   1.06176328
#> [56]   0.91917658   1.59465079   0.76532920   0.42332582   1.62603885
#> [61]   1.62350879   3.20590011   1.60802546   0.77547640   1.09279519
#> [66]   1.45643795   0.31080873   3.17444293   2.20799901   0.55860928
#> [71]   0.08944104   0.59955665   0.85033951   1.08807727   2.18959018
#> 
#> $wgtFUN
#> function (d) 
#> as.numeric(d < median(d) * cMah)
#> <bytecode: 0x5654ffd4ccc0>
#> <environment: 0x5654ff632e08>
#> 
#> $cov
#>           X1        X2        X3
#> X1 1.1320546 0.0507541 0.1173361
#> X2 0.0507541 1.1522732 0.1407377
#> X3 0.1173361 0.1407377 1.0701585
#> 
#> $center
#>       X1       X2       X3 
#> 1.537705 1.780328 1.686885 
#> 
#> $n.obs
#> [1] 75
#> 
#> $weights
#>  [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> [39] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 
#> attr(,"class")
#> [1] "comed"
(ccW <- covComed(hbk.x, reweight=TRUE))
#> $Z
#>               [,1]         [,2]         [,3]
#>  [1,] -6.087809254 -13.09999354 14.705465671
#>  [2,] -5.777228968 -13.64634107 15.052212929
#>  [3,] -6.536101218 -13.56143334 16.162000384
#>  [4,] -6.111574526 -14.34825012 16.565974104
#>  [5,] -6.297788761 -14.10072524 16.218097351
#>  [6,] -6.468706561 -13.63735058 15.146601077
#>  [7,] -6.286768634 -13.93004059 15.095480588
#>  [8,] -6.015541425 -13.10704917 14.996115962
#>  [9,] -6.000161208 -13.83327590 16.207379832
#> [10,] -5.794443424 -13.18932959 15.865515487
#> [11,] -6.772255277 -16.00427044 18.279792818
#> [12,] -7.452170489 -15.48206281 19.363262321
#> [13,] -7.139581165 -17.23266496 17.612583607
#> [14,] -6.281552750 -22.08802267 17.466612096
#> [15,] -1.753276252  -1.94492066  0.900244788
#> [16,] -1.518745224  -1.45732603 -0.068937934
#> [17,]  0.056461929  -0.98333683  0.070787684
#> [18,] -1.237065583  -1.11058694  0.941557472
#> [19,] -0.385035223  -1.84343471  0.772375796
#> [20,] -1.583588589  -2.24313094  0.960733521
#> [21,] -1.359513613  -1.48462556  0.853003931
#> [22,] -0.184740103  -2.02156566  0.955390062
#> [23,] -0.979162178  -1.49514259  0.271483571
#> [24,] -0.600659567  -1.46325462  0.144765063
#> [25,] -0.538967978  -0.04476564  0.165082266
#> [26,] -0.474430108  -2.11610253  1.258598292
#> [27,] -1.768008612  -1.71917505  1.362700678
#> [28,] -1.014187954  -0.60481610  0.991036330
#> [29,] -0.627711388  -0.61257300  0.353711359
#> [30,] -0.795553846  -0.56210932  1.809733937
#> [31,] -1.595977246  -0.98773866  0.342105112
#> [32,] -0.172540831  -1.49186780  0.077113437
#> [33,] -0.730448282  -1.98650923  0.670773168
#> [34,] -0.248662904  -0.03281096  0.367377806
#> [35,] -1.675534766  -1.65407663  1.432683871
#> [36,] -0.636813495  -1.45611893  1.386645086
#> [37,] -0.081864817  -1.90854196  1.368565884
#> [38,] -0.732417294  -0.78947036 -0.006211199
#> [39,] -1.153883229  -0.10394431  0.547569358
#> [40,] -0.244845068  -1.27225483  0.589560320
#> [41,] -1.858105966  -1.17252575  1.379849175
#> [42,] -0.276773680  -0.69577641  1.463770182
#> [43,]  0.035145964  -2.04496035  0.412233459
#> [44,] -1.100573075  -0.45459706  1.668345700
#> [45,] -1.009944435  -0.14175204  0.221817581
#> [46,] -1.088322811  -0.44907680  1.556736479
#> [47,] -1.588108893  -0.18436993  0.269477008
#> [48,] -1.709890863  -1.16516834  1.453094640
#> [49,] -1.603863802  -1.68482873  0.816281804
#> [50,] -1.137764137  -1.86204552  1.424810053
#> [51,] -1.143357981  -1.00531132  0.051235042
#> [52,] -1.745477096  -0.51109567  0.462497867
#> [53,] -0.339291545  -0.34565598  1.813905925
#> [54,] -0.455454229  -1.87878408  0.026923653
#> [55,] -0.209291624  -1.50842858  0.411941103
#> [56,] -0.843743212  -2.04117952  0.315953302
#> [57,] -0.938855749  -0.50782087  0.268127733
#> [58,] -1.180585450  -2.20020244  0.610796569
#> [59,] -0.916717128  -1.42014834  1.527542176
#> [60,] -0.292051912  -1.01790487  1.785841117
#> [61,] -0.243527532  -2.17415416  1.564138090
#> [62,] -0.477101589  -0.09974653  0.112539927
#> [63,] -0.462212633  -1.69268334 -0.021226919
#> [64,] -1.489302327  -2.00788017  1.379012036
#> [65,] -1.164251881  -0.56976851  1.372592718
#> [66,] -0.074593329  -1.12886970  0.388885422
#> [67,] -0.810759263  -1.30935246  0.525610524
#> [68,] -0.118823198  -0.03373395  0.608037103
#> [69,] -1.021543223  -0.44241184  0.035833400
#> [70,] -0.597617014  -1.45826668  1.504067926
#> [71,] -1.165343625  -1.66551664  1.091822808
#> [72,] -0.314667210  -1.28390773  0.751160536
#> [73,] -0.216086436  -1.10977051  1.166887704
#> [74,] -0.003522848  -1.38865986  0.836744161
#> [75,] -0.296415621  -0.32633507  1.423273648
#> 
#> $raw.cov
#>              [,1]         [,2]       [,3]
#> [1,]  3.562613961 -0.007646157 0.06862357
#> [2,] -0.007646157  2.491357097 0.01816029
#> [3,]  0.068623567  0.018160292 2.47944913
#> 
#> $raw.center
#> [1] 1.914091 2.197396 2.021472
#> 
#> $raw.mah
#>  [1] 413.26701462 436.34206667 483.89439421 516.12597478 497.64308013
#>  [6] 446.87547230 450.68952609 423.02595844 486.90613102 455.05264601
#> [11] 644.33160094 686.60550680 659.58619698 831.83678287   0.82050583
#> [16]   1.62268762   2.45249023   0.18489708   0.61144075   0.98643384
#> [21]   0.13938812   1.04835988   0.61078870   1.03058170   3.19340659
#> [26]   0.87160194   0.86790315   0.78776229   1.39971095   1.83966446
#> [31]   1.08355679   1.73764914   0.48366919   3.24454426   0.77906968
#> [36]   0.38050679   1.32878511   1.76461960   2.21118811   0.83103368
#> [41]   1.05597753   1.51841502   1.89180190   1.73500319   2.56336692
#> [46]   1.55853769   2.70036798   0.90874897   0.44080452   0.46146299
#> [51]   1.30059971   1.84189093   2.73922588   1.62580983   1.06176328
#> [56]   0.91917658   1.59465079   0.76532920   0.42332582   1.62603885
#> [61]   1.62350879   3.20590011   1.60802546   0.77547640   1.09279519
#> [66]   1.45643795   0.31080873   3.17444293   2.20799901   0.55860928
#> [71]   0.08944104   0.59955665   0.85033951   1.08807727   2.18959018
#> 
#> $wgtFUN
#> function (d) 
#> as.numeric(d < median(d) * cMah)
#> <bytecode: 0x5654ffd4ccc0>
#> <environment: 0x5654fea84260>
#> 
#> $cov
#>           X1        X2        X3
#> X1 1.1320546 0.0507541 0.1173361
#> X2 0.0507541 1.1522732 0.1407377
#> X3 0.1173361 0.1407377 1.0701585
#> 
#> $center
#>       X1       X2       X3 
#> 1.537705 1.780328 1.686885 
#> 
#> $n.obs
#> [1] 75
#> 
#> $raw.weights
#>  [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> [39] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 
#> $mah
#>  [1]  866.8549007  912.3681940 1017.0299206 1079.9186877 1041.8580415
#>  [6]  935.6980871  941.3078111  888.0064615 1021.0376511  957.4611322
#> [11] 1342.3698119 1440.5949347 1362.9053822 1688.5026579    4.0064280
#> [16]    4.6884713    3.7574080    0.6178804    1.6567463    4.2714721
#> [21]    1.1205589    3.0480588    1.3526403    1.7339162    3.9441987
#> [26]    2.9096498    3.9755147    1.0723383    1.2914025    4.4561502
#> [31]    2.9401141    3.1064228    1.6295712    4.1685558    3.5514637
#> [36]    1.3096674    4.0559690    2.2133428    3.2201247    1.1746971
#> [41]    4.1844894    3.2543802    4.6603888    4.0877683    3.4392115
#> [46]    3.4973306    5.2049556    3.5483292    2.5236386    2.1725973
#> [51]    2.2939158    4.3831564    6.3346432    3.6282032    1.8882576
#> [56]    2.7059747    1.8502041    3.0356765    1.6369388    4.3965207
#> [61]    5.0323398    3.9487802    3.2484854    3.4413018    2.3934458
#> [66]    2.1370579    0.3027165    4.4393944    3.0483378    1.8469822
#> [71]    1.0073289    0.8502209    1.7521614    2.2965290    4.2555744
#> 
#> $weights
#>  [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> [39] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
#> 
#> attr(,"class")
#> [1] "comed"
cc0  <- covComed(hbk.x, n.iter=0)
cc0W <- covComed(hbk.x, n.iter=0, reweight=TRUE)

stopifnot(all.equal(unclass(cc0), # here, the 0-1 weights don't change:
                    cc0W[names(cc0)], tol=1e-12, check.environment = FALSE),
          which(cc1$weights == 0) == 1:14,
          which(ccW$weights == 0) == 1:14,
          which(cc0$weights == 0) == 1:14)


## Martin's smooth reweighting:

## List of experimental pre-specified wgtFUN() creators:
## Cutoffs may depend on  (n, p, control$beta) :
str(.wgtFUN.covComed)
#> List of 6
#>  $ 01.original :function (p, ...)  
#>  $ 01.flex     :function (p, n, control)  
#>  $ 01.adaptive :function (p, n, ...)  
#>  $ sm1.flex    :function (p, n, control)  
#>  $ sm1.adaptive:function (p, n, ...)  
#>  $ sm2.adaptive:function (p, n, ...)