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 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152
|
R Under development (unstable) (2021-10-11 r81035) -- "Unsuffered Consequences"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
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.
Natural language support but running in an English locale
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.
> pkgname <- "robust"
> source(file.path(R.home("share"), "R", "examples-header.R"))
> options(warn = 1)
> options(pager = "console")
> library('robust')
Loading required package: fit.models
>
> base::assign(".oldSearch", base::search(), pos = 'CheckExEnv')
> base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv')
> cleanEx()
> nameEx("OverlaidDenPlot.fdfm")
> ### * OverlaidDenPlot.fdfm
>
> flush(stderr()); flush(stdout())
>
> ### Name: overlaidDenPlot.fdfm
> ### Title: Overlaid Density Plot
> ### Aliases: overlaidDenPlot.fdfm
> ### Keywords: hplot
>
> ### ** Examples
>
> data(los, package="robustbase")
>
> ## Not run:
> ##D
> ##D los.fm <- fit.models(c(Robust = "fitdstnRob", MLE = "fitdstn"),
> ##D x = los, densfun = "gamma")
> ##D
> ##D
> ##D los.fm <- fit.models(c(Robust = "fitdstnRob", MLE = "fitdstn"),
> ##D x = los, densfun = "weibull")
> ##D
> ##D overlaidDenPlot.fdfm(los.fm, xlab = "x-axis label", ylab = "y-axis label",
> ##D main = "Plot Title")
> ##D
> ## End(Not run)
>
>
>
> cleanEx()
> nameEx("anova.glmRob")
> ### * anova.glmRob
>
> flush(stderr()); flush(stdout())
>
> ### Name: anova.glmRob
> ### Title: ANOVA for Robust Generalized Linear Model Fits
> ### Aliases: anova.glmRob anova.glmRoblist
> ### Keywords: robust regression methods
>
> ### ** Examples
>
> data(breslow.dat)
>
> bres.int <- glmRob(sumY ~ Age10 + Base4*Trt, family = poisson(), data = breslow.dat)
> anova(bres.int)
Analysis of Deviance Table
poisson model
Response: sumY
Terms added sequentially (first to last)
Df Deviance Resid. Df Resid. Dev
NULL 58 11983.1
Age10 1 9125.7 57 2857.5
Base4 1 803.0 56 2054.5
Trt 1 -884.6 55 2939.1
Base4:Trt 1 -949.1 54 3888.2
>
> bres.main <- glmRob(sumY ~ Age10 + Base4 + Trt, family = poisson(), data = breslow.dat)
> anova(bres.main, bres.int)
Terms Resid. Df Resid. Dev Test Df Deviance
1 Age10 + Base4 + Trt 55 2939.072 NA NA
2 Age10 + Base4 * Trt 54 3888.204 +Base4:Trt 1 -949.1315
>
>
>
> cleanEx()
> nameEx("anova.lmRob")
> ### * anova.lmRob
>
> flush(stderr()); flush(stdout())
>
> ### Name: anova.lmRob
> ### Title: ANOVA for Robust Linear Model Fits
> ### Aliases: anova.lmRob anova.lmRoblist
> ### Keywords: robust regression methods
>
> ### ** Examples
>
> data(stack.dat)
> stack.small <- lmRob(Loss ~ Water.Temp + Acid.Conc., data = stack.dat)
> stack.full <- lmRob(Loss ~ ., data = stack.dat)
> anova(stack.full)
Terms added sequentially (first to last)
Chisq Df RobustF Pr(F)
(Intercept) 1
Air.Flow 1 41.228 6.026e-11 ***
Water.Temp 1 6.522 0.009257 **
Acid.Conc. 1 0.551 0.449386
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
> anova(stack.full, stack.small)
Response: Loss
Terms Df RobustF Pr(F)
[1,] 1 1
[2,] 2 1 1 27.354 9.839e-08 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
>
>
>
> cleanEx()
> nameEx("breslow.dat")
> ### * breslow.dat
>
> flush(stderr()); flush(stdout())
>
> ### Name: breslow.dat
> ### Title: Breslow Data
> ### Aliases: breslow.dat
> ### Keywords: datasets
>
> ### ** Examples
>
> data(breslow.dat)
>
>
>
> cleanEx()
> nameEx("covClassic")
> ### * covClassic
>
> flush(stderr()); flush(stdout())
>
> ### Name: covClassic
> ### Title: Classical Covariance Estimation
> ### Aliases: covClassic
> ### Keywords: robust multivariate
>
> ### ** Examples
>
> data(stack.dat)
> covClassic(stack.dat)
Call:
covClassic(data = stack.dat)
Classical Estimate of Covariance:
Loss Air.Flow Water.Temp Acid.Conc.
Loss 103.46 85.76 28.148 21.793
Air.Flow 85.76 84.06 22.657 24.571
Water.Temp 28.15 22.66 9.990 6.621
Acid.Conc. 21.79 24.57 6.621 28.714
Classical Estimate of Location:
Loss Air.Flow Water.Temp Acid.Conc.
17.52 60.43 21.10 86.29
>
>
>
> cleanEx()
> nameEx("covRob")
> ### * covRob
>
> flush(stderr()); flush(stdout())
>
> ### Name: covRob
> ### Title: Robust Covariance/Correlation Matrix Estimation
> ### Aliases: covRob
> ### Keywords: multivariate robust
>
> ### ** Examples
>
> data(stackloss)
> covRob(stackloss)
Call:
covRob(data = stackloss)
Robust Estimate of Covariance:
Air.Flow Water.Temp Acid.Conc. stack.loss
Air.Flow 33.93 11.203 22.135 29.41
Water.Temp 11.20 8.298 8.794 12.03
Acid.Conc. 22.14 8.794 37.887 17.60
stack.loss 29.41 12.030 17.605 28.17
Robust Estimate of Location:
Air.Flow Water.Temp Acid.Conc. stack.loss
56.92 20.43 86.29 13.73
>
>
>
> cleanEx()
> nameEx("covRob.control")
> ### * covRob.control
>
> flush(stderr()); flush(stdout())
>
> ### Name: covRob.control
> ### Title: Control Parameters for Robust Covariance Estimation
> ### Aliases: covRob.control
> ### Keywords: utilities
>
> ### ** Examples
>
> mcd.control <- covRob.control("mcd", quan = 0.75, ntrial = 1000)
>
> ds.control <- covRob.control("donostah", prob = 0.95)
>
> qc.control <- covRob.control("pairwiseqc")
>
>
>
> cleanEx()
> nameEx("ddPlot.covfm")
> ### * ddPlot.covfm
>
> flush(stderr()); flush(stdout())
>
> ### Name: ddPlot.covfm
> ### Title: Distance - Distance Plot
> ### Aliases: ddPlot.covfm
> ### Keywords: hplot
>
> ### ** Examples
>
> data(woodmod.dat)
> woodm.fm <- fit.models(list(Robust = "covRob", Classical = "covClassic"),
+ data = woodmod.dat)
> ddPlot.covfm(woodm.fm, main = "Plot Title", xlab = "x-axis label",
+ ylab = "y-axis label", pch = 4, col = "purple")
>
>
>
> cleanEx()
> nameEx("distancePlot.covfm")
> ### * distancePlot.covfm
>
> flush(stderr()); flush(stdout())
>
> ### Name: distancePlot.covfm
> ### Title: Side-by-Side Mahalanobis Distance Plot
> ### Aliases: distancePlot.covfm
> ### Keywords: hplot
>
> ### ** Examples
>
> data(woodmod.dat)
> woodm.fm <- fit.models(list(Robust = "covRob", Classical = "covClassic"),
+ data = woodmod.dat)
> distancePlot.covfm(woodm.fm, main = "Plot Title", xlab = "x-axis label",
+ ylab = "y-axis label", pch = 4, col = "purple")
>
>
>
> cleanEx()
> nameEx("drop1.lmRob")
> ### * drop1.lmRob
>
> flush(stderr()); flush(stdout())
>
> ### Name: drop1.lmRob
> ### Title: Compute an Anova Object by Dropping Terms
> ### Aliases: drop1.lmRob
> ### Keywords: robust regression methods
>
> ### ** Examples
>
> data(stack.dat)
> stack.rob <- lmRob(Loss ~ ., data = stack.dat)
> drop1(stack.rob)
Single term deletions
Model:
Loss ~ Air.Flow + Water.Temp + Acid.Conc.
scale: 1.837073
Df RFPE
<none> 16.032
Air.Flow 1 36.213
Water.Temp 1 20.829
Acid.Conc. 1 16.049
>
>
>
> cleanEx()
> nameEx("ellipsesPlot.covfm")
> ### * ellipsesPlot.covfm
>
> flush(stderr()); flush(stdout())
>
> ### Name: ellipsesPlot.covfm
> ### Title: Ellipses Plot - Visual Correlation Matrix Comparison
> ### Aliases: ellipsesPlot.covfm
> ### Keywords: hplot
>
> ### ** Examples
>
> data(woodmod.dat)
> woodm.fm <- fit.models(list(Robust = "covRob", Classical = "covClassic"),
+ data = woodmod.dat)
> ellipsesPlot.covfm(woodm.fm)
>
>
>
> cleanEx()
> nameEx("glmRob")
> ### * glmRob
>
> flush(stderr()); flush(stdout())
>
> ### Name: glmRob
> ### Title: Fit a Robust Generalized Linear Model
> ### Aliases: glmRob
> ### Keywords: robust regression models
>
> ### ** Examples
>
> data(breslow.dat)
>
> glmRob(sumY ~ Age10 + Base4*Trt, family = poisson(),
+ data = breslow.dat, method = "cubif")
Call:
glmRob(formula = sumY ~ Age10 + Base4 * Trt, family = poisson(),
data = breslow.dat, method = "cubif")
Coefficients:
(Intercept) Age10 Base4 Trtprogabide
1.83516 0.12081 0.13915 -0.39279
Base4:Trtprogabide
0.02182
Degrees of Freedom: 59 Total; 54 Residual
Residual Deviance: 3888
>
>
>
> cleanEx()
> nameEx("glmRob.mallows")
> ### * glmRob.mallows
>
> flush(stderr()); flush(stdout())
>
> ### Name: glmRob.mallows
> ### Title: Mallows Type Estimator
> ### Aliases: glmRob.mallows
> ### Keywords: robust regression
>
> ### ** Examples
>
> data(mallows.dat)
>
> glmRob(y ~ a + b + c, data = mallows.dat, family = binomial(), method = 'mallows')
Call:
glmRob(formula = y ~ a + b + c, family = binomial(), data = mallows.dat,
method = "mallows")
Coefficients:
(Intercept) a b c
-1.3214 -0.9052 -0.7435 -1.0201
Degrees of Freedom: 70 Total; 58 Residual
Residual Deviance: 27.04
>
>
>
> cleanEx()
> nameEx("glmRob.misclass")
> ### * glmRob.misclass
>
> flush(stderr()); flush(stdout())
>
> ### Name: glmRob.misclass
> ### Title: Consistent Misclassification Estimator
> ### Aliases: glmRob.misclass
> ### Keywords: robust regression
>
> ### ** Examples
>
> data(leuk.dat)
>
> glmRob(y ~ ag + wbc, data = leuk.dat, family = binomial(), method = 'misclass')
Call:
glmRob(formula = y ~ ag + wbc, family = binomial(), data = leuk.dat,
method = "misclass")
Coefficients:
(Intercept) ag wbc
-1.265e+00 2.219e+00 -3.276e-05
Degrees of Freedom: 33 Total; 30 Residual
Residual Deviance: 29.59
>
>
>
> cleanEx()
> nameEx("leuk.dat")
> ### * leuk.dat
>
> flush(stderr()); flush(stdout())
>
> ### Name: leuk.dat
> ### Title: Leuk Data
> ### Aliases: leuk.dat
> ### Keywords: datasets
>
> ### ** Examples
>
> data(leuk.dat)
>
>
>
> cleanEx()
> nameEx("lmRob")
> ### * lmRob
>
> flush(stderr()); flush(stdout())
>
> ### Name: lmRob
> ### Title: High Breakdown and High Efficiency Robust Linear Regression
> ### Aliases: lmRob
> ### Keywords: robust regression models
>
> ### ** Examples
>
> data(stack.dat)
> stack.rob <- lmRob(Loss ~ ., data = stack.dat)
>
>
>
> cleanEx()
> nameEx("lmRob.RFPE")
> ### * lmRob.RFPE
>
> flush(stderr()); flush(stdout())
>
> ### Name: lmRob.RFPE
> ### Title: Robust Final Prediction Errors
> ### Aliases: lmRob.RFPE
> ### Keywords: robust regression
>
> ### ** Examples
>
> data(stack.dat)
> stack.rob <- lmRob(Loss ~ ., data = stack.dat)
> lmRob.RFPE(stack.rob)
[1] 16.03201
>
>
>
> cleanEx()
> nameEx("lmRob.control")
> ### * lmRob.control
>
> flush(stderr()); flush(stdout())
>
> ### Name: lmRob.control
> ### Title: Control Parameters for Robust Linear Regression
> ### Aliases: lmRob.control
> ### Keywords: robust regression
>
> ### ** Examples
>
> data(stack.dat)
> my.control <- lmRob.control(weight=c("Bisquare","Optimal"))
> stack.bo <- lmRob(Loss ~ ., data = stack.dat, control = my.control)
>
>
>
> cleanEx()
> nameEx("lsRobTest")
> ### * lsRobTest
>
> flush(stderr()); flush(stdout())
>
> ### Name: lsRobTest
> ### Title: Bias Test for Least-Squares Regression Estimates
> ### Aliases: lsRobTest
> ### Keywords: robust regression
>
> ### ** Examples
>
> rob.fit <- lmRob(stack.loss ~ ., data = stackloss)
> lsRobTest(rob.fit)
Test for least squares bias
H0: composite normal/non-normal regression error distribution
Individual coefficient tests:
LS Robust Delta Std. Error Stat p-value
Air.Flow 0.7156 0.79769 -0.08205 0.1353 -0.6064 0.54427
Water.Temp 1.2953 0.57734 0.71795 0.3366 2.1332 0.03291
Acid.Conc. -0.1521 -0.06706 -0.08506 0.1200 -0.7091 0.47824
Joint test for bias:
Test statistic: 6.61 on 3 DF, p-value: 0.08541
> lsRobTest(rob.fit, test = "T1")
Test for least squares bias
H0: normal regression error distribution
Individual coefficient tests:
LS Robust Delta Std. Error Stat p-value
Air.Flow 0.7156 0.79769 -0.08205 0.02101 -3.906 9.388e-05
Water.Temp 1.2953 0.57734 0.71795 0.05225 13.741 5.764e-43
Acid.Conc. -0.1521 -0.06706 -0.08506 0.01862 -4.568 4.928e-06
Joint test for bias:
Test statistic: 274.3 on 3 DF, p-value: 0
>
>
>
> cleanEx()
> nameEx("mallows.dat")
> ### * mallows.dat
>
> flush(stderr()); flush(stdout())
>
> ### Name: mallows.dat
> ### Title: Mallows Data
> ### Aliases: mallows.dat
> ### Keywords: datasets
>
> ### ** Examples
>
> data(mallows.dat)
>
>
>
> cleanEx()
> nameEx("plot.covfm")
> ### * plot.covfm
>
> flush(stderr()); flush(stdout())
>
> ### Name: plot.covfm
> ### Title: Plot Method
> ### Aliases: plot.covfm plot.covRob plot.covClassic
> ### Keywords: methods hplot
>
> ### ** Examples
>
> data(woodmod.dat)
>
> woodm.cov <- covClassic(woodmod.dat)
> woodm.covRob <- covRob(woodmod.dat)
>
> plot(woodm.cov)
> plot(woodm.covRob)
>
> woodm.fm <- fit.models(list(Robust = "covRob", Classical = "covClassic"),
+ data = woodmod.dat)
> plot(woodm.fm)
>
>
>
> cleanEx()
> nameEx("plot.fdfm")
> ### * plot.fdfm
>
> flush(stderr()); flush(stdout())
>
> ### Name: plot.fdfm
> ### Title: fdfm Plot Method
> ### Aliases: plot.fdfm
> ### Keywords: hplot
>
> ### ** Examples
>
> data(los, package = "robustbase")
> los.fm <- fit.models(c(Robust = "fitdstnRob", MLE = "fitdstn"),
+ x = los, densfun = "gamma")
> plot(los.fm)
>
>
>
> cleanEx()
> nameEx("plot.lmRob")
> ### * plot.lmRob
>
> flush(stderr()); flush(stdout())
>
> ### Name: plot.lmRob
> ### Title: Diagnostic Regression Plots
> ### Aliases: plot.lmRob
> ### Keywords: methods hplot
>
> ### ** Examples
>
> data(stack.dat)
> stack.rob <- lmRob(Loss ~ ., data = stack.dat)
> plot(stack.rob, which.plots = 6)
>
>
>
> cleanEx()
> nameEx("predict.glmRob")
> ### * predict.glmRob
>
> flush(stderr()); flush(stdout())
>
> ### Name: predict.glmRob
> ### Title: Predict Method for Robust Generalized Linear Model Fits
> ### Aliases: predict.glmRob
> ### Keywords: robust regression methods
>
> ### ** Examples
>
> data(breslow.dat)
> bres.rob <- glmRob(sumY ~ Age10 + Base4 * Trt, family = poisson(), data = breslow.dat)
> predict(bres.rob)
1 2 3 4 5 6 7 8
2.592342 2.580261 2.345916 2.548386 4.396928 3.124781 2.627130 4.151528
9 10 11 12 13 14 15 16
3.082281 2.521311 4.079040 3.273100 2.739205 3.731164 5.175793 3.888652
17 18 19 20 21 22 23 24
2.799611 6.071102 2.847937 2.784617 2.602967 2.401954 2.813149 3.111243
25 26 27 28 29 30 31 32
4.110915 2.631499 2.412579 3.735964 4.718229 3.358170 2.448596 2.207231
33 34 35 36 37 38 39 40
2.424433 2.698131 3.052314 2.428606 2.211229 4.380213 3.358083 2.062342
41 42 43 44 45 46 47 48
2.605566 2.448770 3.692188 3.144792 3.394414 2.026098 3.205198 2.187066
49 50 51 52 53 54 55 56
7.784706 2.714298 3.394327 3.152962 3.949632 2.903514 2.472846 2.641810
57 58 59
2.702129 2.400445 2.372284
>
>
>
> cleanEx()
> nameEx("predict.lmRob")
> ### * predict.lmRob
>
> flush(stderr()); flush(stdout())
>
> ### Name: predict.lmRob
> ### Title: Use predict() on an lmRob Object
> ### Aliases: predict.lmRob
> ### Keywords: robust regression methods
>
> ### ** Examples
>
> data(stack.dat)
> stack.rob <- lmRob(Loss ~ ., data = stack.dat)
> predict(stack.rob)
1 2 3 4 5 6 7 8
35.782223 35.849283 30.572054 19.825981 18.671300 19.248641 19.423620 19.423620
9 10 11 12 13 14 15 16
16.057899 13.640618 13.037076 12.526796 13.506497 13.346176 6.655592 6.856772
17 18 19 20 21
8.372955 7.903534 8.413814 13.065807 23.629863
> predict(stack.rob, newdata = stack.dat[c(1,2,4,21), ], se.fit = TRUE)
$fit
1 2 4 21
35.78222 35.84928 19.82598 23.62986
$se.fit
1 2 4 21
1.0869527 1.1059685 0.5557136 0.9526912
$residual.scale
[1] 1.837073
$df
[1] 17
>
>
>
> cleanEx()
> nameEx("qqPlot.fdfm")
> ### * qqPlot.fdfm
>
> flush(stderr()); flush(stdout())
>
> ### Name: qqPlot.fdfm
> ### Title: Comparison Quantile-Quantile Plot
> ### Aliases: qqPlot.fdfm
> ### Keywords: hplot
>
> ### ** Examples
>
> data(los, package = "robustbase")
> los.fm <- fit.models(c(Robust = "fitdstnRob", MLE = "fitdstn"),
+ x = los, densfun = "gamma")
> qqPlot.fdfm(los.fm, xlab = "x-axis label", ylab = "y-axis label",
+ main = "Plot Title", pch = 4, col = "purple")
>
>
>
> cleanEx()
> nameEx("screePlot.covfm")
> ### * screePlot.covfm
>
> flush(stderr()); flush(stdout())
>
> ### Name: screePlot.covfm
> ### Title: Comparison Screeplot
> ### Aliases: screePlot.covfm
> ### Keywords: hplot
>
> ### ** Examples
>
> data(woodmod.dat)
> woodm.fm <- fit.models(list(Robust = "covRob", Classical = "covClassic"),
+ data = woodmod.dat)
> screePlot.covfm(woodm.fm, main = "Plot Title", xlab = "x-axis label",
+ ylab = "y-axis label", pch = 4:5)
>
>
>
> cleanEx()
> nameEx("stack.dat")
> ### * stack.dat
>
> flush(stderr()); flush(stdout())
>
> ### Name: stack.dat
> ### Title: Brownlee's Stack-Loss Data
> ### Aliases: stack.dat
> ### Keywords: datasets
>
> ### ** Examples
>
> data(stack.dat)
> stack.dat
Loss Air.Flow Water.Temp Acid.Conc.
1 42 80 27 89
2 37 80 27 88
3 37 75 25 90
4 28 62 24 87
5 18 62 22 87
6 18 62 23 87
7 19 62 24 93
8 20 62 24 93
9 15 58 23 87
10 14 58 18 80
11 14 58 18 89
12 13 58 17 88
13 11 58 18 82
14 12 58 19 93
15 8 50 18 89
16 7 50 18 86
17 8 50 19 72
18 8 50 19 79
19 9 50 20 80
20 15 56 20 82
21 15 70 20 91
>
>
>
> cleanEx()
> nameEx("step.lmRob")
> ### * step.lmRob
>
> flush(stderr()); flush(stdout())
>
> ### Name: step.lmRob
> ### Title: Build a Model in a Stepwise Fashion
> ### Aliases: step.lmRob
> ### Keywords: robust regression methods
>
> ### ** Examples
>
> data(stack.dat)
> stack.rob <- lmRob(Loss ~ ., data = stack.dat)
>
> ## The default behavior is to try dropping all terms ##
> step.lmRob(stack.rob)
Start: RFPE= 16.032
Loss ~ Air.Flow + Water.Temp + Acid.Conc.
Single term deletions
Model:
Loss ~ Air.Flow + Water.Temp + Acid.Conc.
scale: 1.837073
Df RFPE
<none> 16.032
Air.Flow 1 36.213
Water.Temp 1 20.829
Acid.Conc. 1 16.049
Call:
lmRob(formula = Loss ~ ., data = stack.dat)
Coefficients:
(Intercept) Air.Flow Water.Temp Acid.Conc.
-37.65246 0.79769 0.57734 -0.06706
>
> ## Keep Water.Temp in the model ##
> my.scope <- list(lower = . ~ Water.Temp, upper = . ~ .)
> step.lmRob(stack.rob, scope = my.scope)
Start: RFPE= 16.032
Loss ~ Air.Flow + Water.Temp + Acid.Conc.
Single term deletions
Model:
Loss ~ Air.Flow + Water.Temp + Acid.Conc.
scale: 1.837073
Df RFPE
<none> 16.032
Air.Flow 1 36.213
Acid.Conc. 1 16.049
Call:
lmRob(formula = Loss ~ ., data = stack.dat)
Coefficients:
(Intercept) Air.Flow Water.Temp Acid.Conc.
-37.65246 0.79769 0.57734 -0.06706
>
>
>
> cleanEx()
> nameEx("summary.covfm")
> ### * summary.covfm
>
> flush(stderr()); flush(stdout())
>
> ### Name: summary.covfm
> ### Title: Summary Method
> ### Aliases: summary.covClassic summary.covRob summary.covfm
> ### Keywords: methods
>
> ### ** Examples
>
> data(woodmod.dat)
> woodm.cov <- covClassic(woodmod.dat)
> ## IGNORE_RDIFF_BEGIN
> summary(woodm.cov)
Call:
covClassic(data = woodmod.dat)
Classical Estimate of Covariance:
V1 V2 V3 V4 V5
V1 0.0082920 -0.0002912 0.003602 0.0026908 -0.0028684
V2 -0.0002912 0.0004888 -0.000352 -0.0008388 0.0006124
V3 0.0036022 -0.0003520 0.004185 0.0015788 -0.0016916
V4 0.0026908 -0.0008388 0.001579 0.0039462 -0.0007920
V5 -0.0028684 0.0006124 -0.001692 -0.0007920 0.0027570
Classical Estimate of Location:
V1 V2 V3 V4 V5
0.5508 0.1330 0.5087 0.5112 0.9070
Eigenvalues:
Eval. 1 Eval. 2 Eval. 3 Eval. 4 Eval. 5
0.0128527 0.0029621 0.0021125 0.0016344 0.0001075
Squared Mahalanobis Distances:
1 2 3 4 5 6 7 8 9 10 11 12 13
4.327 1.552 3.224 3.959 3.277 3.974 9.124 4.536 5.665 7.588 5.075 6.833 4.506
14 15 16 17 18 19 20
1.500 1.945 9.049 4.548 4.637 4.599 5.084
> ## IGNORE_RDIFF_END
>
> woodm.covRob <- covRob(woodmod.dat)
> summary(woodm.covRob)
Call:
covRob(data = woodmod.dat)
Robust Estimate of Covariance:
V1 V2 V3 V4 V5
V1 0.038232 0.0066282 -0.0021650 -0.0015136 -0.0048570
V2 0.006628 0.0016512 0.0001382 -0.0010400 -0.0003837
V3 -0.002165 0.0001382 0.0036709 0.0001514 0.0015113
V4 -0.001514 -0.0010400 0.0001514 0.0048313 -0.0014409
V5 -0.004857 -0.0003837 0.0015113 -0.0014409 0.0044166
Robust Estimate of Location:
V1 V2 V3 V4 V5
0.5693 0.1189 0.5093 0.5399 0.8964
Eigenvalues:
Eval. 1 Eval. 2 Eval. 3 Eval. 4 Eval. 5
0.0402612 0.0063495 0.0039998 0.0019171 0.0002747
Squared Robust Distances:
[1] 1.2996 0.3348 0.4099 15.8192 0.4578 18.0052 8.5876 24.2857 8.1617
[10] 5.1665 2.0412 5.3157 5.7099 0.2672 0.3173 5.5845 3.4097 0.4362
[19] 25.9520 3.5364
>
> woodm.fm <- fit.models(list(Robust = "covRob", Classical = "covClassic"),
+ data = woodmod.dat)
> summary(woodm.fm)
Calls:
Robust: covRob(data = woodmod.dat)
Classical: covClassic(data = woodmod.dat)
Comparison of Covariance/Correlation Estimates:
(unique correlation terms)
[1,1] [2,1] [3,1] [4,1] [5,1] [2,2]
Robust 0.038232 0.0066282 -0.002165 -0.001514 -0.004857 0.0016512
Classical 0.008292 -0.0002912 0.003602 0.002691 -0.002868 0.0004888
[3,2] [4,2] [5,2] [3,3] [4,3] [5,3]
Robust 0.0001382 -0.0010400 -0.0003837 0.003671 0.0001514 0.001511
Classical -0.0003520 -0.0008388 0.0006124 0.004185 0.0015788 -0.001692
[4,4] [5,4] [5,5]
Robust 0.004831 -0.001441 0.004417
Classical 0.003946 -0.000792 0.002757
Comparison of center Estimates:
V1 V2 V3 V4 V5
Robust 0.5693 0.1189 0.5093 0.5399 0.8964
Classical 0.5508 0.1330 0.5087 0.5112 0.9070
Comparison of Eigenvalues:
Eval. 1 Eval. 2 Eval. 3 Eval. 4 Eval. 5
Robust 0.04026 0.006349 0.004000 0.001917 0.0002747
Classical 0.01285 0.002962 0.002112 0.001634 0.0001075
>
>
>
> cleanEx()
> nameEx("summary.glmRob")
> ### * summary.glmRob
>
> flush(stderr()); flush(stdout())
>
> ### Name: summary.glmRob
> ### Title: Summarizing Robust Generalized Linear Model Fits
> ### Aliases: summary.glmRob
> ### Keywords: methods robust regression
>
> ### ** Examples
>
> data(breslow.dat)
> bres.rob <- glmRob(sumY ~ Age10 + Base4*Trt, family = poisson(), data = breslow.dat)
> bres.sum <- summary(bres.rob)
> bres.sum
Call: glmRob(formula = sumY ~ Age10 + Base4 * Trt, family = poisson(),
data = breslow.dat)
Deviance Residuals:
Min 1Q Median 3Q Max
-54.31624 -1.48734 0.04103 0.87948 8.92507
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.83516 0.28542 6.4296 1.279e-10
Age10 0.12081 0.07495 1.6118 1.070e-01
Base4 0.13915 0.03541 3.9298 8.501e-05
Trtprogabide -0.39279 0.22101 -1.7772 7.554e-02
Base4:Trtprogabide 0.02182 0.04003 0.5451 5.857e-01
(Dispersion Parameter for poisson family taken to be 1 )
Null Deviance: 11983 on 58 degrees of freedom
Residual Deviance: 3888.204 on 54 degrees of freedom
Number of Iterations: 9
Correlation of Coefficients:
(Intercept) Age10 Base4 Trtprogabide
Age10 -0.80956
Base4 -0.62030 0.10855
Trtprogabide -0.46447 0.02404 0.69012
Base4:Trtprogabide 0.52264 -0.06402 -0.88082 -0.89436
>
>
>
> cleanEx()
> nameEx("summary.lmRob")
> ### * summary.lmRob
>
> flush(stderr()); flush(stdout())
>
> ### Name: summary.lmRob
> ### Title: Summarizing Robust Linear Model Fits
> ### Aliases: summary.lmRob
> ### Keywords: methods robust regression
>
> ### ** Examples
>
> data(stack.dat)
> stack.rob <- lmRob(Loss ~ ., data = stack.dat)
> stack.sum <- summary(stack.rob)
> stack.sum
Call:
lmRob(formula = Loss ~ ., data = stack.dat)
Residuals:
Min 1Q Median 3Q Max
-8.6299 -0.6713 0.3594 1.1507 8.1740
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -37.65246 5.00256 -7.527 8.29e-07 ***
Air.Flow 0.79769 0.07129 11.189 2.91e-09 ***
Water.Temp 0.57734 0.17546 3.291 0.00432 **
Acid.Conc. -0.06706 0.06512 -1.030 0.31757
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.837 on 17 degrees of freedom
Multiple R-Squared: 0.6205
Test for Bias:
statistic p-value
M-estimate 2.751 0.6004
LS-estimate 2.640 0.6197
> stack.bse <- summary(stack.rob, bootstrap.se = TRUE)
> stack.bse
Call:
lmRob(formula = Loss ~ ., data = stack.dat)
Residuals:
Min 1Q Median 3Q Max
-8.6299 -0.6713 0.3594 1.1507 8.1740
Coefficients:
Estimate Std. Error Bootstrap SE t value Pr(>|t|)
(Intercept) -37.65246 5.00256 4.43790 -7.527 8.29e-07 ***
Air.Flow 0.79769 0.07129 0.05086 11.189 2.91e-09 ***
Water.Temp 0.57734 0.17546 0.13551 3.291 0.00432 **
Acid.Conc. -0.06706 0.06512 0.05842 -1.030 0.31757
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.837 on 17 degrees of freedom
Multiple R-Squared: 0.6205
Test for Bias:
statistic p-value
M-estimate 2.751 0.6004
LS-estimate 2.640 0.6197
>
>
>
> cleanEx()
> nameEx("weight.funs")
> ### * weight.funs
>
> flush(stderr()); flush(stdout())
>
> ### Name: weight.funs
> ### Title: Weight Functions Psi, Rho, Chi
> ### Aliases: psi.weight rho.weight psp.weight chi.weight
> ### Keywords: robust
>
> ### ** Examples
>
> x <- seq(-4,4, length=401)
> f.x <- cbind(psi = psi.weight(x), psp = psp.weight(x),
+ chi = chi.weight(x), rho = rho.weight(x))
> es <- expression(psi(x), {psi*minute}(x), chi(x), rho(x))
> leg <- as.expression(lapply(seq_along(es), function(i)
+ substitute(C == E, list(C=colnames(f.x)[i], E=es[[i]]))))
> matplot(x, f.x, type = "l", lwd = 1.5,
+ main = "psi.weight(.) etc -- 'optimal'")
> abline(h = 0, v = 0, lwd = 2, col = "#D3D3D380") # opaque gray
> legend("bottom", leg, inset = .01,
+ lty = 1:4, col = 1:4, lwd = 1.5, bg = "#FFFFFFC0")
>
>
>
> cleanEx()
> nameEx("woodmod.dat")
> ### * woodmod.dat
>
> flush(stderr()); flush(stdout())
>
> ### Name: woodmod.dat
> ### Title: Modified Wood Data
> ### Aliases: woodmod.dat
> ### Keywords: datasets
>
> ### ** Examples
>
> data(woodmod.dat)
> woodmod.dat
V1 V2 V3 V4 V5
1 0.573 0.1059 0.465 0.538 0.841
2 0.651 0.1356 0.527 0.545 0.887
3 0.606 0.1273 0.494 0.521 0.920
4 0.437 0.1591 0.446 0.423 0.992
5 0.547 0.1135 0.531 0.519 0.915
6 0.444 0.1628 0.429 0.411 0.984
7 0.489 0.1231 0.562 0.455 0.824
8 0.413 0.1673 0.418 0.430 0.978
9 0.536 0.1182 0.592 0.464 0.854
10 0.685 0.1564 0.631 0.564 0.914
11 0.664 0.1588 0.506 0.481 0.867
12 0.703 0.1335 0.519 0.484 0.812
13 0.653 0.1395 0.625 0.519 0.892
14 0.586 0.1114 0.505 0.565 0.889
15 0.534 0.1143 0.521 0.570 0.889
16 0.523 0.1320 0.505 0.612 0.919
17 0.580 0.1249 0.546 0.608 0.954
18 0.448 0.1028 0.522 0.534 0.918
19 0.417 0.1687 0.405 0.415 0.981
20 0.528 0.1057 0.424 0.566 0.909
>
> data(wood, package = "robustbase")
> stopifnot(data.matrix(woodmod.dat) ==
+ data.matrix(wood [,1:5]))
>
>
>
> ### * <FOOTER>
> ###
> cleanEx()
> options(digits = 7L)
> base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n")
Time elapsed: 2.35 0.14 2.5 NA NA
> grDevices::dev.off()
null device
1
> ###
> ### Local variables: ***
> ### mode: outline-minor ***
> ### outline-regexp: "\\(> \\)?### [*]+" ***
> ### End: ***
> quit('no')
|