R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), 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 a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("rrcov-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('rrcov') Scalable Robust Estimators with High Breakdown Point (version 0.2-7) > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "aircraft" > > ### * aircraft > > flush(stderr()); flush(stdout()) > > ### Name: aircraft > ### Title: Aircraft Data > ### Aliases: aircraft aircraft.x aircraft.y > ### Keywords: datasets > > ### ** Examples > > data(aircraft) > covMcd(aircraft.x) Call: covMcd(x = aircraft.x) Log(det): 30.28 Center: X1 X2 X3 X4 4.188 1.944 14404.688 11165.000 Covariance Matrix: X1 X2 X3 X4 X1 4.891e+00 -2.391e-01 -1.082e+04 -1.518e+04 X2 -2.391e-01 5.786e-01 2.946e+03 2.532e+03 X3 -1.082e+04 2.946e+03 5.064e+07 5.358e+07 X4 -1.518e+04 2.532e+03 5.358e+07 7.667e+07 > > summary(lm.aircraft <- lm(aircraft.y ~ aircraft.x)) Call: lm(formula = aircraft.y ~ aircraft.x) Residuals: Min 1Q Median 3Q Max -14.891 -3.955 -1.233 5.753 17.594 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -3.7913892 10.1157023 -0.375 0.71219 aircraft.xX1 -3.8529189 1.7630016 -2.185 0.04232 * aircraft.xX2 2.4882665 1.1867538 2.097 0.05042 . aircraft.xX3 0.0034988 0.0004790 7.305 8.72e-07 *** aircraft.xX4 -0.0019537 0.0004986 -3.918 0.00101 ** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 8.406 on 18 degrees of freedom Multiple R-Squared: 0.8836, Adjusted R-squared: 0.8578 F-statistic: 34.17 on 4 and 18 DF, p-value: 3.501e-08 > > > > > cleanEx(); ..nameEx <- "brain" > > ### * brain > > flush(stderr()); flush(stdout()) > > ### Name: brain > ### Title: Brain and Body Weights for 28 Species > ### Aliases: brain > ### Keywords: datasets > > ### ** Examples > > data(brain) > lbrain<-log(brain) > plot(mahalanobis(lbrain,mean(lbrain),var(lbrain))) > > mcd<-covMcd(lbrain) > plot(mahalanobis(lbrain,mcd$center,mcd$cov)) > > > > > cleanEx(); ..nameEx <- "bushfire" > > ### * bushfire > > flush(stderr()); flush(stdout()) > > ### Name: bushfire > ### Title: Campbell Bushfire Data > ### Aliases: bushfire > ### Keywords: datasets > > ### ** Examples > > data(bushfire) > plot(bushfire) > covMcd(bushfire) Call: covMcd(x = bushfire) Log(det): 18.14 Center: V1 V2 V3 V4 V5 105.5 146.9 274.4 217.5 279.0 Covariance Matrix: V1 V2 V3 V4 V5 V1 593.7 459.4 -2903.2 -653.2 -532.8 V2 459.4 405.4 -1930.2 -394.3 -333.3 V3 -2903.2 -1930.2 17146.7 4212.9 3347.9 V4 -653.2 -394.3 4212.9 1109.7 866.7 V5 -532.8 -333.3 3347.9 866.7 682.6 > > > > cleanEx(); ..nameEx <- "coleman" > > ### * coleman > > flush(stderr()); flush(stdout()) > > ### Name: coleman > ### Title: Coleman Data Set > ### Aliases: coleman coleman.x coleman.y > ### Keywords: datasets > > ### ** Examples > > data(coleman) > covMcd(coleman.x) Call: covMcd(x = coleman.x) Log(det): 1.287 Center: X1 X2 X3 X4 X5 2.757 48.379 6.118 25.005 6.398 Covariance Matrix: X1 X2 X3 X4 X5 X1 0.4125 2.9089 -0.4338 0.2466 0.1222 X2 2.9089 2122.7550 538.2630 20.5270 56.1936 X3 -0.4338 538.2630 195.2556 6.2423 16.4991 X4 0.2466 20.5270 6.2423 1.2787 0.9043 X5 0.1222 56.1936 16.4991 0.9043 1.6980 > summary(lm.coleman <- lm(coleman.y ~ coleman.x)) Call: lm(formula = coleman.y ~ coleman.x) Residuals: Min 1Q Median 3Q Max -3.94972 -0.61739 0.06235 0.73430 5.00176 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 19.94857 13.62755 1.464 0.1653 coleman.xX1 -1.79333 1.23340 -1.454 0.1680 coleman.xX2 0.04360 0.05326 0.819 0.4267 coleman.xX3 0.55576 0.09296 5.979 3.38e-05 *** coleman.xX4 1.11017 0.43377 2.559 0.0227 * coleman.xX5 -1.81092 2.02739 -0.893 0.3868 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2.074 on 14 degrees of freedom Multiple R-Squared: 0.9063, Adjusted R-squared: 0.8728 F-statistic: 27.08 on 5 and 14 DF, p-value: 9.927e-07 > > > > > cleanEx(); ..nameEx <- "covMcd" > > ### * covMcd > > flush(stderr()); flush(stdout()) > > ### Name: covMcd > ### Title: Robust location and scatter estimation with high breakdown point > ### Aliases: covMcd print.mcd > ### Keywords: robust multivariate > > ### ** Examples > > > data(hbk) > covMcd(hbk.x) Call: covMcd(x = hbk.x) Log(det): -1.048 Center: X1 X2 X3 1.538 1.780 1.687 Covariance Matrix: X1 X2 X3 X1 1.68030 0.07533 0.17416 X2 0.07533 1.71031 0.20890 X3 0.17416 0.20890 1.58843 > > > > > cleanEx(); ..nameEx <- "covPlot" > > ### * covPlot > > flush(stderr()); flush(stdout()) > > ### Name: plot.mcd > ### Title: Robust Distance Plots > ### Aliases: covPlot plot.mcd ddplot distplot chi2qqplot ellipse > ### Keywords: robust multivariate > > ### ** Examples > > > data(brain) > mcd <- covMcd(log(brain)) > plot(mcd) > > > > cleanEx(); ..nameEx <- "delivery" > > ### * delivery > > flush(stderr()); flush(stdout()) > > ### Name: delivery > ### Title: Delivery Time Data > ### Aliases: delivery delivery.x delivery.y > ### Keywords: datasets > > ### ** Examples > > data(delivery) > covMcd(delivery.x) Call: covMcd(x = delivery.x) Log(det): 10.81 Center: X1 X2 5.895 268.053 Covariance Matrix: X1 X2 X1 12.30 232.98 X2 232.98 56158.36 > > summary(lm.delivery <- lm(delivery.y ~ delivery.x)) Call: lm(formula = delivery.y ~ delivery.x) Residuals: Min 1Q Median 3Q Max -5.7880 -0.6629 0.4364 1.1566 7.4197 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.341231 1.096730 2.135 0.044170 * delivery.xX1 1.615907 0.170735 9.464 3.25e-09 *** delivery.xX2 0.014385 0.003613 3.981 0.000631 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 3.259 on 22 degrees of freedom Multiple R-Squared: 0.9596, Adjusted R-squared: 0.9559 F-statistic: 261.2 on 2 and 22 DF, p-value: 4.687e-16 > > > > > cleanEx(); ..nameEx <- "hbk" > > ### * hbk > > flush(stderr()); flush(stdout()) > > ### Name: hbk > ### Title: Hawkins, Bradu, Kass's Artificial Data > ### Aliases: hbk hbk.x hbk.y > ### Keywords: datasets > > ### ** Examples > > data(hbk) > plot(hbk.x) > covMcd(hbk.x) Call: covMcd(x = hbk.x) Log(det): -1.048 Center: X1 X2 X3 1.538 1.780 1.687 Covariance Matrix: X1 X2 X3 X1 1.68030 0.07533 0.17416 X2 0.07533 1.71031 0.20890 X3 0.17416 0.20890 1.58843 > summary(lm.hbk <- lm(hbk.y ~ hbk.x)) Call: lm(formula = hbk.y ~ hbk.x) Residuals: Min 1Q Median 3Q Max -9.37166 -0.71615 -0.02295 0.70830 4.51295 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.3875 0.4165 -0.930 0.35527 hbk.xX1 0.2392 0.2625 0.911 0.36521 hbk.xX2 -0.3345 0.1551 -2.158 0.03434 * hbk.xX3 0.3833 0.1288 2.976 0.00399 ** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 2.25 on 71 degrees of freedom Multiple R-Squared: 0.6018, Adjusted R-squared: 0.585 F-statistic: 35.77 on 3 and 71 DF, p-value: 3.382e-14 > > > > > cleanEx(); ..nameEx <- "heart" > > ### * heart > > flush(stderr()); flush(stdout()) > > ### Name: heart > ### Title: Heart Catherization Data > ### Aliases: heart heart.x heart.y > ### Keywords: datasets > > ### ** Examples > > data(heart) > plot(heart.x) > covMcd(heart.x) Call: covMcd(x = heart.x) Log(det): 5.679 Center: X1 X2 38.25 33.09 Covariance Matrix: X1 X2 X1 173.1 332.8 X2 332.8 726.1 > summary(lm.heart <- lm(heart.y ~ heart.x)) Call: lm(formula = heart.y ~ heart.x) Residuals: Min 1Q Median 3Q Max -6.7419 -1.2034 -0.2595 1.8892 6.6566 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 20.3758 8.3859 2.430 0.038 * heart.xX1 0.2107 0.3455 0.610 0.557 heart.xX2 0.1911 0.1583 1.207 0.258 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 3.778 on 9 degrees of freedom Multiple R-Squared: 0.8254, Adjusted R-squared: 0.7865 F-statistic: 21.27 on 2 and 9 DF, p-value: 0.0003888 > > > > cleanEx(); ..nameEx <- "ltsPlot" > > ### * ltsPlot > > flush(stderr()); flush(stdout()) > > ### Name: plot.lts > ### Title: Robust Regression Diagnostic Plots > ### Aliases: plot.lts ltsPlot > ### Keywords: robust multivariate > > ### ** Examples > > > data(hbk) > lts <- ltsReg(hbk.x,hbk.y) > plot(lts, which="rqq") > > > > > cleanEx(); ..nameEx <- "ltsReg" > > ### * ltsReg > > flush(stderr()); flush(stdout()) > > ### Name: ltsReg > ### Title: Robust regression with high breakdown point > ### Aliases: ltsReg print.lts > ### Keywords: robust > > ### ** Examples > > > data(heart) > ltsReg(heart.x, heart.y) Coefficients: Intercept X1 X2 63.3528 -1.2265 0.6884 Scale estimate 1.525 > > > > > cleanEx(); ..nameEx <- "milk" > > ### * milk > > flush(stderr()); flush(stdout()) > > ### Name: milk > ### Title: Daudin's Milk Composition Data > ### Aliases: milk > ### Keywords: datasets > > ### ** Examples > > data(milk) > covMcd(milk) Call: covMcd(x = milk) Log(det): -28.93 Center: X1 X2 X3 X4 X5 X6 X7 X8 1.030 35.757 33.054 26.121 25.100 25.037 122.940 14.356 Covariance Matrix: X1 X2 X3 X4 X5 X6 X7 X1 6.011e-07 1.147e-04 2.314e-04 2.214e-04 1.959e-04 1.839e-04 8.034e-04 X2 1.147e-04 2.004e+00 2.813e-01 2.075e-01 1.299e-01 2.536e-01 1.643e+00 X3 2.314e-04 2.813e-01 1.513e+00 1.116e+00 1.100e+00 1.111e+00 8.867e-01 X4 2.214e-04 2.075e-01 1.116e+00 8.848e-01 8.471e-01 8.492e-01 7.261e-01 X5 1.959e-04 1.299e-01 1.100e+00 8.471e-01 8.898e-01 8.583e-01 7.332e-01 X6 1.839e-04 2.536e-01 1.111e+00 8.492e-01 8.583e-01 8.918e-01 7.355e-01 X7 8.034e-04 1.643e+00 8.867e-01 7.261e-01 7.332e-01 7.355e-01 4.457e+00 X8 4.527e-06 1.482e-01 2.215e-01 1.474e-01 1.252e-01 1.387e-01 2.724e-01 X8 X1 4.527e-06 X2 1.482e-01 X3 2.215e-01 X4 1.474e-01 X5 1.252e-01 X6 1.387e-01 X7 2.724e-01 X8 1.485e-01 > > > > cleanEx(); ..nameEx <- "phosphor" > > ### * phosphor > > flush(stderr()); flush(stdout()) > > ### Name: phosphor > ### Title: Phosphorus Content Data > ### Aliases: phosphor phosphor.y phosphor.x > ### Keywords: datasets > > ### ** Examples > > data(phosphor) > plot(phosphor.x) > covMcd(phosphor.x) Call: covMcd(x = phosphor.x) Log(det): 6.879 Center: X1 X2 13.35 38.80 Covariance Matrix: X1 X2 X1 194.3 197.0 X2 197.0 274.4 > summary(lm.phosphor <- lm(phosphor.y ~ phosphor.x)) Call: lm(formula = phosphor.y ~ phosphor.x) Residuals: Min 1Q Median 3Q Max -32.828 -8.440 -1.118 6.694 58.757 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 56.25102 16.31074 3.449 0.00358 ** phosphor.xX1 1.78977 0.55674 3.215 0.00579 ** phosphor.xX2 0.08665 0.41494 0.209 0.83740 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 20.68 on 15 degrees of freedom Multiple R-Squared: 0.4823, Adjusted R-squared: 0.4133 F-statistic: 6.988 on 2 and 15 DF, p-value: 0.00717 > > > > cleanEx(); ..nameEx <- "salinity" > > ### * salinity > > flush(stderr()); flush(stdout()) > > ### Name: salinity > ### Title: Salinity Data > ### Aliases: salinity salinity.x salinity.y > ### Keywords: datasets > > ### ** Examples > > data(salinity) > covMcd(salinity.x) Call: covMcd(x = salinity.x) Log(det): 1.326 Center: X1 X2 X3 10.083 2.783 22.778 Covariance Matrix: X1 X2 X3 X1 14.503 1.400 -4.428 X2 1.400 5.329 -2.002 X3 -4.428 -2.002 3.319 > > summary(lm.salinity <- lm(salinity.y ~ salinity.x)) Call: lm(formula = salinity.y ~ salinity.x) Residuals: Min 1Q Median 3Q Max -2.6645 -0.7547 0.2267 0.6517 2.7202 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9.59026 3.12509 3.069 0.00527 ** salinity.xX1 0.77711 0.08622 9.013 3.59e-09 *** salinity.xX2 -0.02551 0.16108 -0.158 0.87548 salinity.xX3 -0.29504 0.10680 -2.762 0.01083 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.33 on 24 degrees of freedom Multiple R-Squared: 0.8264, Adjusted R-squared: 0.8047 F-statistic: 38.08 on 3 and 24 DF, p-value: 2.769e-09 > > > > > cleanEx(); ..nameEx <- "stars" > > ### * stars > > flush(stderr()); flush(stdout()) > > ### Name: stars > ### Title: Data for the Hertzsprung-Russell Diagram of the star cluster CYG > ### OB1 > ### Aliases: stars stars.x stars.y > ### Keywords: datasets > > ### ** Examples > > data(stars) > plot(stars) > covMcd(stars) Call: covMcd(x = stars) Log(det): -8.031 Center: X Y 4.409 4.949 Covariance Matrix: X Y X 0.01754 0.05234 Y 0.05234 0.36434 > lm.stars <- lm(stars.y ~ stars.x) > summary(lm.stars) Call: lm(formula = stars.y ~ stars.x) Residuals: Min 1Q Median 3Q Max -1.1052 -0.5067 0.1327 0.4423 0.9390 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 6.7935 1.2365 5.494 1.75e-06 *** stars.x -0.4133 0.2863 -1.444 0.156 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.5646 on 45 degrees of freedom Multiple R-Squared: 0.04427, Adjusted R-squared: 0.02304 F-statistic: 2.085 on 1 and 45 DF, p-value: 0.1557 > plot(lm.stars) > lts.stars<-ltsReg(stars.x, stars.y) > plot(lts.stars) > > > > > cleanEx(); ..nameEx <- "tolellipse" > > ### * tolellipse > > flush(stderr()); flush(stdout()) > > ### Name: tolellipse > ### Title: Tolerance Ellipse Plot > ### Aliases: tolellipse > ### Keywords: robust multivariate > > ### ** Examples > > > data(hbk) > mcd <- covMcd(hbk.x) # compute mcd in advance > tolellipse(hbk.x[,1:2]) # must be a 2-dimensional data set: take the first two columns > > > > cleanEx(); ..nameEx <- "wood" > > ### * wood > > flush(stderr()); flush(stdout()) > > ### Name: wood > ### Title: Modified Wood Gravity Dataset > ### Aliases: wood wood.x wood.y > ### Keywords: datasets > > ### ** Examples > > data(wood) > plot(wood.x) > covMcd(wood.x) Call: covMcd(x = wood.x) Log(det): -36.27 Center: V1 V2 V3 V4 V5 0.5869 0.1222 0.5309 0.5382 0.8918 Covariance Matrix: V1 V2 V3 V4 V5 V1 1.633e-02 3.063e-03 5.136e-03 -9.543e-04 -2.654e-03 V2 3.063e-03 7.894e-04 2.067e-03 -8.467e-05 3.851e-05 V3 5.136e-03 2.067e-03 1.080e-02 -1.419e-03 5.739e-04 V4 -9.543e-04 -8.467e-05 -1.419e-03 4.635e-03 2.977e-03 V5 -2.654e-03 3.851e-05 5.739e-04 2.977e-03 4.506e-03 > summary(lm.wood <- lm(wood.y ~ wood.x)) Call: lm(formula = wood.y ~ wood.x) Residuals: Min 1Q Median 3Q Max -0.030415 -0.012318 -0.003494 0.012760 0.047892 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.42178 0.16912 2.494 0.02576 * wood.xV1 0.44069 0.11688 3.770 0.00207 ** wood.xV2 -1.47501 0.48692 -3.029 0.00901 ** wood.xV3 -0.26118 0.11199 -2.332 0.03513 * wood.xV4 0.02079 0.16109 0.129 0.89915 wood.xV5 0.17082 0.20336 0.840 0.41505 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.02412 on 14 degrees of freedom Multiple R-Squared: 0.8084, Adjusted R-squared: 0.74 F-statistic: 11.81 on 5 and 14 DF, p-value: 0.0001282 > > > > ### *