1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119
|
R version 2.9.0 Under development (unstable) (2009-01-20 r47658)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(robustbase)
>
> source(system.file("test_MCD.R", package = "robustbase"))
> ## ../inst/test_MCD.R
>
> ## -- now do it:
> options(digits = 5)
> set.seed(101) # <<-- sub-sampling algorithm now based on R's RNG and seed
> doMCDdata()
Call: doMCDdata()
Data Set n p Half LOG(obj) Time [ms]
========================================================
heart 12 2 7 5.678742
Best subsample:
[1] 1 3 4 5 7 9 11
Outliers: 0
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): 5.68
Robust Estimate of Location:
height weight
38.3 33.1
Robust Estimate of Covariance:
height weight
height 157 303
weight 303 660
--------------------------------------------------------
phosphor 18 2 10 6.878847
Best subsample:
[1] 3 5 8 9 11 12 13 14 15 17
Outliers: 2
[1] 1 6
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): 6.88
Robust Estimate of Location:
inorg organic
13.4 38.8
Robust Estimate of Covariance:
inorg organic
inorg 181 184
organic 184 256
--------------------------------------------------------
starsCYG 47 2 25 -8.031215
Best subsample:
[1] 1 2 4 6 8 10 12 13 16 24 25 26 28 32 33 37 38 39 40 41 42 43 44 45 46
Outliers: 6
[1] 7 11 14 20 30 34
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): -8.03
Robust Estimate of Location:
log.Te log.light
4.41 4.95
Robust Estimate of Covariance:
log.Te log.light
log.Te 0.0171 0.0511
log.light 0.0511 0.3555
--------------------------------------------------------
stackloss 21 3 12 5.472581
Best subsample:
[1] 4 5 6 7 8 9 10 11 12 13 14 20
Outliers: 9
[1] 1 2 3 15 16 17 18 19 21
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): 5.47
Robust Estimate of Location:
Air.Flow Water.Temp Acid.Conc.
59.5 20.8 87.3
Robust Estimate of Covariance:
Air.Flow Water.Temp Acid.Conc.
Air.Flow 12.6 11.7 11.5
Water.Temp 11.7 18.5 12.3
Acid.Conc. 11.5 12.3 46.6
--------------------------------------------------------
coleman 20 5 13 1.286808
Best subsample:
[1] 2 3 4 5 7 8 12 13 14 16 17 19 20
Outliers: 7
[1] 1 6 9 10 11 15 18
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): 1.29
Robust Estimate of Location:
salaryP fatherWc sstatus teacherSc motherLev
2.76 48.38 6.12 25.00 6.40
Robust Estimate of Covariance:
salaryP fatherWc sstatus teacherSc motherLev
salaryP 0.381 2.69 -0.400 0.228 0.113
fatherWc 2.685 1959.47 496.858 18.948 51.871
sstatus -0.400 496.86 180.236 5.762 15.230
teacherSc 0.228 18.95 5.762 1.180 0.835
motherLev 0.113 51.87 15.230 0.835 1.567
--------------------------------------------------------
salinity 28 3 16 1.326364
Best subsample:
[1] 1 2 6 7 8 12 13 14 18 20 21 22 25 26 27 28
Outliers: 4
[1] 5 16 23 24
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): 1.33
Robust Estimate of Location:
X1 X2 X3
10.08 2.78 22.78
Robust Estimate of Covariance:
X1 X2 X3
X1 13.87 1.34 -4.24
X2 1.34 5.10 -1.92
X3 -4.24 -1.92 3.17
--------------------------------------------------------
wood 20 5 13 -36.270094
Best subsample:
[1] 1 2 3 5 9 10 12 13 14 15 17 18 20
Outliers: 7
[1] 4 6 7 8 11 16 19
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): -36.3
Robust Estimate of Location:
x1 x2 x3 x4 x5
0.587 0.122 0.531 0.538 0.892
Robust Estimate of Covariance:
x1 x2 x3 x4 x5
x1 0.01507 2.83e-03 0.00474 -8.81e-04 -2.45e-03
x2 0.00283 7.29e-04 0.00191 -7.82e-05 3.55e-05
x3 0.00474 1.91e-03 0.00997 -1.31e-03 5.30e-04
x4 -0.00088 -7.82e-05 -0.00131 4.28e-03 2.75e-03
x5 -0.00245 3.55e-05 0.00053 2.75e-03 4.16e-03
--------------------------------------------------------
hbk 75 3 39 -1.047858
Best subsample:
[1] 15 16 17 18 19 20 21 22 23 24 26 27 31 32 33 35 36 37 38 40 43 49 50 51 54
[26] 55 56 58 59 61 63 64 66 67 70 71 72 73 74
Outliers: 14
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): -1.05
Robust Estimate of Location:
X1 X2 X3
1.54 1.78 1.69
Robust Estimate of Covariance:
X1 X2 X3
X1 1.6528 0.0741 0.171
X2 0.0741 1.6823 0.205
X3 0.1713 0.2055 1.562
--------------------------------------------------------
Animals 28 2 15 14.555543
Best subsample:
[1] 1 3 4 5 10 11 17 18 19 20 21 22 23 26 27
Outliers: 13
[1] 2 6 7 8 9 12 13 14 15 16 24 25 28
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): 14.6
Robust Estimate of Location:
body brain
18.7 64.9
Robust Estimate of Covariance:
body brain
body 2511 4258
brain 4258 15257
--------------------------------------------------------
milk 86 8 47 -28.848323
Best subsample:
[1] 5 7 8 9 10 21 22 24 26 30 31 32 33 34 35 36 39 45 46 51 53 54 55 56 57
[26] 58 59 60 61 62 63 64 65 66 67 68 69 71 72 76 78 79 81 82 83 84 86
Outliers: 20
[1] 1 2 3 11 12 13 14 15 16 17 18 20 27 41 44 47 70 74 75 77
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): -28.8
Robust Estimate of Location:
X1 X2 X3 X4 X5 X6 X7 X8
1.03 35.89 33.08 26.14 25.12 25.05 123.17 14.38
Robust Estimate of Covariance:
X1 X2 X3 X4 X5 X6 X7
X1 5.16e-07 0.000141 0.000179 0.000175 0.000156 0.000135 0.0007
X2 1.41e-04 2.274487 0.283407 0.224349 0.123111 0.286851 2.0115
X3 1.79e-04 0.283407 1.338103 0.991617 0.977699 0.968312 0.8373
X4 1.75e-04 0.224349 0.991617 0.795728 0.760376 0.746050 0.6976
X5 1.56e-04 0.123111 0.977699 0.760376 0.806266 0.761894 0.6790
X6 1.35e-04 0.286851 0.968312 0.746050 0.761894 0.773555 0.7223
X7 7.00e-04 2.011544 0.837316 0.697578 0.678976 0.722292 4.7856
X8 1.68e-05 0.261205 0.227169 0.155399 0.129194 0.147308 0.4377
X8
X1 1.68e-05
X2 2.61e-01
X3 2.27e-01
X4 1.55e-01
X5 1.29e-01
X6 1.47e-01
X7 4.38e-01
X8 1.86e-01
--------------------------------------------------------
bushfire 38 5 22 18.135810
Best subsample:
[1] 1 2 3 4 5 6 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
Outliers: 16
[1] 7 8 9 10 11 12 29 30 31 32 33 34 35 36 37 38
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): 18.1
Robust Estimate of Location:
V1 V2 V3 V4 V5
105 147 274 218 279
Robust Estimate of Covariance:
V1 V2 V3 V4 V5
V1 567 439 -2771 -624 -509
V2 439 387 -1843 -376 -318
V3 -2771 -1843 16367 4021 3196
V4 -624 -376 4021 1059 827
V5 -509 -318 3196 827 652
--------------------------------------------------------
========================================================
> ## vvvv no timing for 'R CMD Rdiff' outputs
> doMCDdata(nrep = 12, time=FALSE)
Call: doMCDdata(nrep = 12, time = FALSE)
Data Set n p Half LOG(obj) Time [ms]
========================================================
heart 12 2 7 5.678742
Best subsample:
[1] 1 3 4 5 7 9 11
Outliers: 0
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): 5.68
Robust Estimate of Location:
height weight
38.3 33.1
Robust Estimate of Covariance:
height weight
height 157 303
weight 303 660
--------------------------------------------------------
phosphor 18 2 10 6.878847
Best subsample:
[1] 3 5 8 9 11 12 13 14 15 17
Outliers: 2
[1] 1 6
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): 6.88
Robust Estimate of Location:
inorg organic
13.4 38.8
Robust Estimate of Covariance:
inorg organic
inorg 181 184
organic 184 256
--------------------------------------------------------
starsCYG 47 2 25 -8.031215
Best subsample:
[1] 1 2 4 6 8 10 12 13 16 24 25 26 28 32 33 37 38 39 40 41 42 43 44 45 46
Outliers: 6
[1] 7 11 14 20 30 34
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): -8.03
Robust Estimate of Location:
log.Te log.light
4.41 4.95
Robust Estimate of Covariance:
log.Te log.light
log.Te 0.0171 0.0511
log.light 0.0511 0.3555
--------------------------------------------------------
stackloss 21 3 12 5.472581
Best subsample:
[1] 4 5 6 7 8 9 10 11 12 13 14 20
Outliers: 9
[1] 1 2 3 15 16 17 18 19 21
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): 5.47
Robust Estimate of Location:
Air.Flow Water.Temp Acid.Conc.
59.5 20.8 87.3
Robust Estimate of Covariance:
Air.Flow Water.Temp Acid.Conc.
Air.Flow 12.6 11.7 11.5
Water.Temp 11.7 18.5 12.3
Acid.Conc. 11.5 12.3 46.6
--------------------------------------------------------
coleman 20 5 13 1.286808
Best subsample:
[1] 2 3 4 5 7 8 12 13 14 16 17 19 20
Outliers: 7
[1] 1 6 9 10 11 15 18
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): 1.29
Robust Estimate of Location:
salaryP fatherWc sstatus teacherSc motherLev
2.76 48.38 6.12 25.00 6.40
Robust Estimate of Covariance:
salaryP fatherWc sstatus teacherSc motherLev
salaryP 0.381 2.69 -0.400 0.228 0.113
fatherWc 2.685 1959.47 496.858 18.948 51.871
sstatus -0.400 496.86 180.236 5.762 15.230
teacherSc 0.228 18.95 5.762 1.180 0.835
motherLev 0.113 51.87 15.230 0.835 1.567
--------------------------------------------------------
salinity 28 3 16 1.326364
Best subsample:
[1] 1 2 6 7 8 12 13 14 18 20 21 22 25 26 27 28
Outliers: 4
[1] 5 16 23 24
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): 1.33
Robust Estimate of Location:
X1 X2 X3
10.08 2.78 22.78
Robust Estimate of Covariance:
X1 X2 X3
X1 13.87 1.34 -4.24
X2 1.34 5.10 -1.92
X3 -4.24 -1.92 3.17
--------------------------------------------------------
wood 20 5 13 -36.270094
Best subsample:
[1] 1 2 3 5 9 10 12 13 14 15 17 18 20
Outliers: 7
[1] 4 6 7 8 11 16 19
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): -36.3
Robust Estimate of Location:
x1 x2 x3 x4 x5
0.587 0.122 0.531 0.538 0.892
Robust Estimate of Covariance:
x1 x2 x3 x4 x5
x1 0.01507 2.83e-03 0.00474 -8.81e-04 -2.45e-03
x2 0.00283 7.29e-04 0.00191 -7.82e-05 3.55e-05
x3 0.00474 1.91e-03 0.00997 -1.31e-03 5.30e-04
x4 -0.00088 -7.82e-05 -0.00131 4.28e-03 2.75e-03
x5 -0.00245 3.55e-05 0.00053 2.75e-03 4.16e-03
--------------------------------------------------------
hbk 75 3 39 -1.047858
Best subsample:
[1] 15 16 17 18 19 20 21 22 23 24 26 27 31 32 33 35 36 37 38 40 43 49 50 51 54
[26] 55 56 58 59 61 63 64 66 67 70 71 72 73 74
Outliers: 14
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): -1.05
Robust Estimate of Location:
X1 X2 X3
1.54 1.78 1.69
Robust Estimate of Covariance:
X1 X2 X3
X1 1.6528 0.0741 0.171
X2 0.0741 1.6823 0.205
X3 0.1713 0.2055 1.562
--------------------------------------------------------
Animals 28 2 15 14.555543
Best subsample:
[1] 1 3 4 5 10 11 17 18 19 20 21 22 23 26 27
Outliers: 13
[1] 2 6 7 8 9 12 13 14 15 16 24 25 28
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): 14.6
Robust Estimate of Location:
body brain
18.7 64.9
Robust Estimate of Covariance:
body brain
body 2511 4258
brain 4258 15257
--------------------------------------------------------
milk 86 8 47 -28.902301
Best subsample:
[1] 6 7 8 9 10 19 21 22 23 24 25 26 30 33 34 35 36 37 38 39 45 46 53 54 55
[26] 56 57 58 59 60 61 62 63 64 65 66 67 69 71 72 76 78 79 80 81 82 83
Outliers: 19
[1] 1 2 3 11 12 13 14 15 16 17 18 27 41 44 47 70 74 75 77
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): -28.9
Robust Estimate of Location:
X1 X2 X3 X4 X5 X6 X7 X8
1.03 35.97 33.13 26.17 25.15 25.08 123.18 14.39
Robust Estimate of Covariance:
X1 X2 X3 X4 X5 X6 X7
X1 6.21e-07 6.11e-05 0.000222 0.000220 0.000195 0.000181 0.000813
X2 6.11e-05 1.91e+00 0.305315 0.234515 0.151617 0.261667 2.081023
X3 2.22e-04 3.05e-01 1.524243 1.122585 1.092155 1.120191 0.884748
X4 2.20e-04 2.35e-01 1.122585 0.891433 0.844566 0.861078 0.727338
X5 1.95e-04 1.52e-01 1.092155 0.844566 0.878407 0.860894 0.709359
X6 1.81e-04 2.62e-01 1.120191 0.861078 0.860894 0.905852 0.729376
X7 8.13e-04 2.08e+00 0.884748 0.727338 0.709359 0.729376 5.130073
X8 8.02e-06 3.42e-01 0.261602 0.167884 0.146623 0.160590 0.506099
X8
X1 8.02e-06
X2 3.42e-01
X3 2.62e-01
X4 1.68e-01
X5 1.47e-01
X6 1.61e-01
X7 5.06e-01
X8 2.04e-01
--------------------------------------------------------
bushfire 38 5 22 18.135810
Best subsample:
[1] 1 2 3 4 5 6 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
Outliers: 16
[1] 7 8 9 10 11 12 29 30 31 32 33 34 35 36 37 38
-------------
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = x)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): 18.1
Robust Estimate of Location:
V1 V2 V3 V4 V5
105 147 274 218 279
Robust Estimate of Covariance:
V1 V2 V3 V4 V5
V1 567 439 -2771 -624 -509
V2 439 387 -1843 -376 -318
V3 -2771 -1843 16367 4021 3196
V4 -624 -376 4021 1059 827
V5 -509 -318 3196 827 652
--------------------------------------------------------
========================================================
> doMCDdata(nrep = 12, time=FALSE, method = "MASS")
Call: doMCDdata(nrep = 12, time = FALSE, method = "MASS")
Data Set n p Half LOG(obj) Time [ms]
========================================================
heart 12 2 7 5.678742
Best subsample:
[1] 1 3 4 5 7 9 11
Outliers: 0
-------------
$center
height weight
40.358 38.125
$cov
height weight
height 142.46 298.91
weight 298.91 679.01
$msg
[1] "0 singular samples of size 3 out of 220"
$crit
[1] 5.6787
$best
[1] 1 3 4 5 7 9 11
$n.obs
[1] 12
--------------------------------------------------------
phosphor 18 2 10 6.878847
Best subsample:
[1] 3 5 8 9 11 12 13 14 15 17
Outliers: 0
-------------
$center
inorg organic
15.215 39.385
$cov
inorg organic
inorg 95.47 116.49
organic 116.49 171.76
$msg
[1] "1 singular samples of size 3 out of 816"
$crit
[1] 6.8788
$best
[1] 3 5 8 9 11 12 13 14 15 17
$n.obs
[1] 18
--------------------------------------------------------
starsCYG 47 2 25 -8.031215
Best subsample:
[1] 1 2 4 6 8 10 12 13 16 24 25 26 28 32 33 37 38 39 40 41 42 43 44 45 46
[26] 47
Outliers: 0
-------------
$center
log.Te log.light
4.4127 4.9335
$cov
log.Te log.light
log.Te 0.011508 0.038513
log.light 0.038513 0.241013
$msg
[1] "9 singular samples of size 3 out of 1500"
$crit
[1] -8.0312
$best
[1] 1 2 4 6 8 10 12 13 16 24 25 26 28 32 33 37 38 39 40 41 42 43 44 45 46
[26] 47
$n.obs
[1] 47
--------------------------------------------------------
stackloss 21 3 12 5.472581
Best subsample:
[1] 4 5 6 7 8 9 10 11 12 13 14 20
Outliers: 0
-------------
$center
Air.Flow Water.Temp Acid.Conc.
56.706 20.235 85.529
$cov
Air.Flow Water.Temp Acid.Conc.
Air.Flow 23.4706 7.5735 16.1029
Water.Temp 7.5735 6.3162 5.3676
Acid.Conc. 16.1029 5.3676 32.3897
$msg
[1] "90 singular samples of size 4 out of 2000"
$crit
[1] 5.4726
$best
[1] 4 5 6 7 8 9 10 11 12 13 14 20
$n.obs
[1] 21
--------------------------------------------------------
coleman 20 5 13 1.286808
Best subsample:
[1] 2 3 4 5 7 8 12 13 14 16 17 19 20
Outliers: 0
-------------
$center
salaryP fatherWc sstatus teacherSc motherLev
2.8253 44.6267 4.7133 25.1240 6.3320
$cov
salaryP fatherWc sstatus teacherSc motherLev
salaryP 0.18916 -0.30888 0.14262 0.17971 0.02461
fatherWc -0.30888 683.87325 196.89588 3.30523 17.29381
sstatus 0.14262 196.89588 85.94311 1.68507 5.58631
teacherSc 0.17971 3.30523 1.68507 0.51571 0.21891
motherLev 0.02461 17.29381 5.58631 0.21891 0.50172
$msg
[1] "0 singular samples of size 6 out of 3000"
$crit
[1] 1.2868
$best
[1] 2 3 4 5 7 8 12 13 14 16 17 19 20
$n.obs
[1] 20
--------------------------------------------------------
salinity 28 3 16 1.326364
Best subsample:
[1] 1 2 6 7 8 12 13 14 18 20 21 22 25 26 27 28
Outliers: 0
-------------
$center
X1 X2 X3
10.0826 2.7826 22.7777
$cov
X1 X2 X3
X1 9.14332 0.88241 -2.7916
X2 0.88241 3.35968 -1.2622
X3 -2.79160 -1.26222 2.0924
$msg
[1] "4 singular samples of size 4 out of 2000"
$crit
[1] 1.3264
$best
[1] 1 2 6 7 8 12 13 14 18 20 21 22 25 26 27 28
$n.obs
[1] 28
--------------------------------------------------------
wood 20 5 13 -36.270094
Best subsample:
[1] 1 2 3 5 9 10 12 13 14 15 17 18 20
Outliers: 0
-------------
$center
x1 x2 x3 x4 x5
0.57613 0.12294 0.53127 0.53760 0.88913
$cov
x1 x2 x3 x4 x5
x1 5.2757e-03 7.8749e-04 1.2965e-03 -2.0514e-05 -4.0002e-04
x2 7.8749e-04 2.2023e-04 5.4362e-04 2.3846e-05 2.7230e-05
x3 1.2965e-03 5.4362e-04 3.0435e-03 -7.0560e-04 -4.4395e-05
x4 -2.0514e-05 2.3846e-05 -7.0560e-04 2.1388e-03 1.3511e-03
x5 -4.0002e-04 2.7230e-05 -4.4395e-05 1.3511e-03 1.5946e-03
$msg
[1] "0 singular samples of size 6 out of 3000"
$crit
[1] -36.27
$best
[1] 1 2 3 5 9 10 12 13 14 15 17 18 20
$n.obs
[1] 20
--------------------------------------------------------
hbk 75 3 39 -1.047858
Best subsample:
[1] 15 16 17 18 19 20 21 22 23 24 26 27 31 32 33 35 36 37 38 40 43 49 50 51 54
[26] 55 56 58 59 61 63 64 66 67 70 71 72 73 74
Outliers: 0
-------------
$center
X1 X2 X3
1.5583 1.8033 1.6600
$cov
X1 X2 X3
X1 1.124845 0.022175 0.15373
X2 0.022175 1.138972 0.18149
X3 0.153729 0.181492 1.04346
$msg
[1] "1 singular samples of size 4 out of 2000"
$crit
[1] -1.0479
$best
[1] 15 16 17 18 19 20 21 22 23 24 26 27 31 32 33 35 36 37 38 40 43 49 50 51 54
[26] 55 56 58 59 61 63 64 66 67 70 71 72 73 74
$n.obs
[1] 75
--------------------------------------------------------
Animals 28 2 15 14.555543
Best subsample:
[1] 1 3 4 5 10 11 17 18 19 20 21 22 23 26 27
Outliers: 0
-------------
$center
body brain
48.331 127.321
$cov
body brain
body 4978.6 7801.4
brain 7801.4 21693.7
$msg
[1] "0 singular samples of size 3 out of 3276"
$crit
[1] 14.556
$best
[1] 1 3 4 5 10 11 17 18 19 20 21 22 23 26 27
$n.obs
[1] 28
--------------------------------------------------------
milk 86 8 47 -28.931843
Best subsample:
[1] 5 7 8 9 10 22 23 24 26 30 31 32 33 34 35 37 38 39 45 46 49 51 53 54 55
[26] 56 57 58 59 60 61 63 64 65 66 67 68 69 71 72 76 78 79 81 83 84 86
Outliers: 0
-------------
$center
X1 X2 X3 X4 X5 X6 X7 X8
1.0302 35.7571 33.0540 26.1206 25.1000 25.0365 122.9397 14.3559
$cov
X1 X2 X3 X4 X5 X6 X7
X1 4.2168e-07 8.0438e-05 0.00016232 0.00015533 0.00013742 0.00012898 0.00056354
X2 8.0438e-05 1.4057e+00 0.19735023 0.14557604 0.09112903 0.17788018 1.15253456
X3 1.6232e-04 1.9735e-01 1.06155658 0.78306196 0.77129032 0.77961086 0.62201741
X4 1.5533e-04 1.4558e-01 0.78306196 0.62069636 0.59419355 0.59568612 0.50932924
X5 1.3742e-04 9.1129e-02 0.77129032 0.59419355 0.62419355 0.60209677 0.51435484
X6 1.2898e-04 1.7788e-01 0.77961086 0.59568612 0.60209677 0.62558116 0.51594726
X7 5.6354e-04 1.1525e+00 0.62201741 0.50932924 0.51435484 0.51594726 3.12630312
X8 3.1754e-06 1.0393e-01 0.15537148 0.10339299 0.08783871 0.09729826 0.19106964
X8
X1 3.1754e-06
X2 1.0393e-01
X3 1.5537e-01
X4 1.0339e-01
X5 8.7839e-02
X6 9.7298e-02
X7 1.9107e-01
X8 1.0417e-01
$msg
[1] "40 singular samples of size 9 out of 3000"
$crit
[1] -28.932
$best
[1] 5 7 8 9 10 22 23 24 26 30 31 32 33 34 35 37 38 39 45 46 49 51 53 54 55
[26] 56 57 58 59 60 61 63 64 65 66 67 68 69 71 72 76 78 79 81 83 84 86
$n.obs
[1] 86
--------------------------------------------------------
bushfire 38 5 22 18.135810
Best subsample:
[1] 1 2 3 4 5 6 14 15 16 17 18 19 20 21 22 23 24 25 26 27
Outliers: 0
-------------
$center
V1 V2 V3 V4 V5
109.38 148.23 250.96 212.38 274.50
$cov
V1 V2 V3 V4 V5
V1 361.69 270.748 -1549.42 -324.394 -270.24
V2 270.75 272.905 -624.23 -86.732 -74.12
V3 -1549.42 -624.231 12072.60 2940.415 2419.98
V4 -324.39 -86.732 2940.42 760.886 619.08
V5 -270.24 -74.120 2419.98 619.080 507.46
$msg
[1] "0 singular samples of size 6 out of 3000"
$crit
[1] 18.136
$best
[1] 1 2 3 4 5 6 14 15 16 17 18 19 20 21 22 23 24 25 26 27
$n.obs
[1] 38
--------------------------------------------------------
========================================================
>
> ###--- now the "close to singular" mahalanobis case:
> (c3 <- covMcd(mort3))
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = mort3)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): 37.6
Robust Estimate of Location:
MO70 MAGE CI68 MDOC DENS NONW EDUC IN69
112.62 287.63 164.63 153.01 19.54 2.21 557.37 107.18
Robust Estimate of Covariance:
MO70 MAGE CI68 MDOC DENS NONW EDUC IN69
MO70 645.32 567.286 125.06 109.26 -5.63 13.150 -904 -133.69
MAGE 567.29 860.391 -2.96 284.95 -95.30 -0.193 -500 5.57
CI68 125.06 -2.955 799.93 -357.48 -46.46 7.476 -839 7.38
MDOC 109.26 284.954 -357.48 2126.21 -89.66 1.462 423 121.61
DENS -5.63 -95.297 -46.46 -89.66 181.24 10.686 -375 -62.28
NONW 13.15 -0.193 7.48 1.46 10.69 2.534 -98 -9.62
EDUC -903.51 -500.437 -838.81 423.16 -374.60 -98.010 6789 511.09
IN69 -133.69 5.571 7.38 121.61 -62.28 -9.615 511 133.70
> ## rescale variables:
> scaleV <- c(0.1, 0.1, 1, 1, .001, 0.1, 0.1, 100)
> mm <- data.matrix(mort3) * rep(scaleV, each = nrow(mort3))
> C3 <- covMcd(mm)
> stopifnot(C3$mcd.wt == c3$mcd.wt)
> try(## error: with "old default tolerance:
+ covMcd(mm, control= rrcov.control(tol = 1e-10))
+ )
Error in solve.default(cov, ...) :
system is computationally singular: reciprocal condition number = 4.85293e-11
>
> cat('Time elapsed: ', proc.time(),'\n') # for ``statistical reasons''
Time elapsed: 2.314 0.088 2.449 0 0
>
> ## "large" examples using different algo branches {seg.fault in version 0.4-4}:
> set.seed(1)
>
> n <- 600 ## - partitioning will be triggered
> X <- matrix(round(100*rnorm(n * 3)), n, 3)
> cX <- covMcd(X)
> cX
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = X)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): 25.1
Robust Estimate of Location:
[1] 0.141 -6.083 -0.703
Robust Estimate of Covariance:
[,1] [,2] [,3]
[1,] 9646 -114 389
[2,] -114 11221 250
[3,] 389 250 11726
> n <- 2000 ## - nesting will be triggered
> X <- matrix(round(100*rnorm(n * 3)), n, 3)
> cX <- covMcd(X)
> cX
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = X)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): 24.9
Robust Estimate of Location:
[1] 0.201 1.455 -2.296
Robust Estimate of Covariance:
[,1] [,2] [,3]
[1,] 10083.87 225 7.31
[2,] 224.92 9885 237.96
[3,] 7.31 238 9862.80
>
> cat('Time elapsed: ', proc.time(),'\n')
Time elapsed: 2.549 0.09 2.686 0 0
>
>
> ## Now, some small sample cases:
>
> ## maximal values:
> n. <- 10
> p. <- 8
> set.seed(44)
> (X. <- cbind(1:n., round(10*rt(n.,3)), round(10*rt(n.,2)),
+ matrix(round(10*rnorm(n. * (p.-3)), 1), nrow = n., ncol = p.-3)))
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,] 1 8 0 -3.6 4.7 3.0 -7.7 -3.3
[2,] 2 -24 3 5.7 -15.6 13.5 -8.9 -10.0
[3,] 3 -1 0 17.0 -1.9 19.0 17.4 -5.8
[4,] 4 -9 2 0.1 -6.0 -11.5 18.6 25.8
[5,] 5 -6 -31 2.4 10.0 9.6 5.4 -4.8
[6,] 6 6 -3 -12.3 -4.6 17.2 -4.6 15.2
[7,] 7 22 16 -2.8 -2.2 -5.2 -2.2 5.6
[8,] 8 23 5 -9.0 -10.4 -2.6 -5.7 2.0
[9,] 9 1 -9 2.1 -5.6 4.1 2.8 -3.0
[10,] 10 -17 -2 -8.8 -7.8 6.5 4.2 17.7
>
> ## 2 x 1 ---> Error
> r <- try(covMcd(X.[1:2, 2, drop=FALSE]), silent=TRUE)
> stopifnot(inherits(r, "try-error"),
+ grep("too small sample size", r) == 1)
>
> ## 3 x 2 --- ditto
> r <- try(covMcd(X.[1:3, 2:3]), silent=TRUE)
> stopifnot(inherits(r, "try-error"),
+ grep("too small sample size", r) == 1)
>
> ## 5 x 3 [ n < 2 p ! ] --- also works for MASS
> X <- X.[1:5, 1:3]
> set.seed(101)
> ## the finite-sample correction is definitely doubtful:
> (cc <- covMcd(X, use.correction = FALSE))
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = X, use.correction = FALSE)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): 4.30
Robust Estimate of Location:
[1] 2.50 -6.50 1.25
Robust Estimate of Covariance:
[,1] [,2] [,3]
[1,] 2.474 -6.93 0.742
[2,] -6.928 273.67 -28.456
[3,] 0.742 -28.46 3.341
Warning message:
In covMcd(X, use.correction = FALSE) :
n < 2 * p, i.e., possibly too small sample size
> str(cc) ## best = 2 3 4 5
List of 18
$ method : chr "Minimum Covariance Determinant Estimator."
$ call : language covMcd(x = X, use.correction = FALSE)
$ cov : num [1:3, 1:3] 2.474 -6.928 0.742 -6.928 273.675 ...
$ center : num [1:3] 2.5 -6.5 1.25
$ n.obs : int 5
$ best : int [1:4] 1 2 3 4
$ alpha : num 0.5
$ quan : num 4
$ raw.cov : num [1:3, 1:3] 2.474 -6.928 0.742 -6.928 273.675 ...
$ raw.center : num [1:3] 2.5 -6.5 1.25
$ raw.weights: num [1:5] 1 1 1 1 0
$ crit : num 73.3
$ raw.mah : num [1:5] 1.52 1.52 1.52 1.52 2724.44
$ mah : num [1:5] 1.52 1.52 1.52 1.52 2724.44
$ mcd.wt : num [1:5] 1 1 1 1 0
$ X : num [1:5, 1:3] 1 2 3 4 5 8 -24 -1 -9 -6 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : chr [1:5] "1" "2" "3" "4" ...
.. ..$ : NULL
$ raw.cnp2 : num [1:2] 1.48 1
$ cnp2 : num [1:2] 1.48 1
- attr(*, "class")= chr "mcd"
> mcc <- MASS::cov.mcd(X)
> stopifnot(cc$best == mcc$best,
+ all.equal(cc$center, mcc$center, tol = 1e-10),
+ all.equal(c(mcc$cov / cc$raw.cov), rep(0.673549282206, 3*3)))
>
> ## p = 4 -- 6 x 4 & 7 x 4 [ n < 2 p ! ]
> p <- 4
> n <- 7
> X <- X.[1:n, 1+(1:p)]
> stopifnot(dim(X) == c(n,p))
> (cc <- covMcd(X, use.correction = FALSE))
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = X, use.correction = FALSE)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): 15.6
Robust Estimate of Location:
[1] 0.333 3.000 0.683 -4.267
Robust Estimate of Covariance:
[,1] [,2] [,3] [,4]
[1,] 319.0 61.163 -82.304 102.906
[2,] 61.2 57.565 -0.745 -0.874
[3,] -82.3 -0.745 126.126 -15.035
[4,] 102.9 -0.874 -15.035 57.008
Warning message:
In covMcd(X, use.correction = FALSE) :
n < 2 * p, i.e., possibly too small sample size
> str(cc) ## best = 1 2 4 5 6 7
List of 18
$ method : chr "Minimum Covariance Determinant Estimator."
$ call : language covMcd(x = X, use.correction = FALSE)
$ cov : num [1:4, 1:4] 319 61.2 -82.3 102.9 61.2 ...
$ center : num [1:4] 0.333 3 0.683 -4.267
$ n.obs : int 7
$ best : int [1:6] 1 2 3 4 6 7
$ alpha : num 0.5
$ quan : num 6
$ raw.cov : num [1:4, 1:4] 319 61.2 -82.3 102.9 61.2 ...
$ raw.center : num [1:4] 0.333 3 0.683 -4.267
$ raw.weights: num [1:7] 1 1 1 1 0 1 1
$ crit : num 6011409
$ raw.mah : num [1:7] 2.546 2.477 3.224 0.835 24.765 ...
$ mah : num [1:7] 2.546 2.477 3.224 0.835 24.765 ...
$ mcd.wt : num [1:7] 1 1 1 1 0 1 1
$ X : num [1:7, 1:4] 8 -24 -1 -9 -6 6 22 0 3 0 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : chr [1:7] "1" "2" "3" "4" ...
.. ..$ : NULL
$ raw.cnp2 : num [1:2] 1.28 1
$ cnp2 : num [1:2] 1.28 1
- attr(*, "class")= chr "mcd"
> mcc <- MASS::cov.mcd(X)
> stopifnot(cc$best == mcc$best,
+ all.equal(cc$center, mcc$center, tol = 1e-10),
+ all.equal(c(mcc$cov / cc$raw.cov), rep(0.7782486992881, p*p)))
> n <- 6
> X <- X[1:n,]
> (cc <- covMcd(X, use.correction = FALSE))
Minimum Covariance Determinant (MCD) estimator.
Call:
covMcd(x = X, use.correction = FALSE)
-> Method: Minimum Covariance Determinant Estimator.
Log(Det.): 7.67
Robust Estimate of Location:
[1] -4.00 0.40 1.38 -4.68
Robust Estimate of Covariance:
[,1] [,2] [,3] [,4]
[1,] 225.1 -33.21 -76.3 115.1
[2,] -33.2 7.04 17.1 -11.8
[3,] -76.3 17.08 158.1 -16.6
[4,] 115.1 -11.83 -16.6 72.0
Warning message:
In covMcd(X, use.correction = FALSE) :
n < 2 * p, i.e., possibly too small sample size
> mcc <- MASS::cov.mcd(X)
> stopifnot(cc$best == mcc$best,
+ all.equal(cc$center, mcc$center, tol = 1e-10),
+ all.equal(c(mcc$cov / cc$raw.cov), rep(0.7528695976179, p*p)))
>
> cat('Time elapsed: ', proc.time(),'\n') # for ``statistical reasons''
Time elapsed: 2.611 0.098 2.755 0 0
>
> ## nsamp = "exact" -- here for p=7
> coleman.x <- data.matrix(coleman[, 1:6])
> system.time(CcX <- covMcd(coleman.x, nsamp="exact")) # ~ 3 sec.
Warning in .fastmcd(x, h, nsamp, trace = as.integer(trace)) :
Computing all 77520 subsets of size 7 out of 20
This may take a very long time!
user system elapsed
1.747 0.000 1.746
> stopifnot(all.equal(CcX$best,
+ c(2, 5:9, 11,13, 14:16, 19:20), tol=0))
>
|