R Under development (unstable) (2024-01-29 r85841 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 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. > ## VT::15.09.2013 - this will render the output independent > ## from the version of the package > suppressPackageStartupMessages(library(rrcov)) > > ## VT::14.01.2020 > ## On some platforms minor differences are shown - use > ## IGNORE_RDIFF_BEGIN > ## IGNORE_RDIFF_END > > dodata <- function(nrep=1, time=FALSE, short=FALSE, full=TRUE, method = c("FASTMCD","MASS")){ + domcd <- function(x, xname, nrep=1){ + n <- dim(x)[1] + p <- dim(x)[2] + + mcd<-CovOgk(x) + + xres <- sprintf("%3d %3d\n", dim(x)[1], dim(x)[2]) + + lpad<-lname-nchar(xname) + cat(pad.right(xname,lpad), xres) + + dist <- getDistance(mcd) + quantiel <- qchisq(0.975, p) + ibad <- which(dist >= quantiel) + names(ibad) <- NULL + nbad <- length(ibad) + cat("Outliers: ",nbad,"\n") + if(nbad > 0) + print(ibad) + cat("-------------\n") + show(mcd) + cat("--------------------------------------------------------\n") + } + + lname <- 20 + + ## VT::15.09.2013 - this will render the output independent + ## from the version of the package + suppressPackageStartupMessages(library(rrcov)) + + method <- match.arg(method) + + data(heart) + data(starsCYG) + data(phosphor) + data(stackloss) + data(coleman) + data(salinity) + data(wood) + + data(hbk) + + data(Animals, package = "MASS") + brain <- Animals[c(1:24, 26:25, 27:28),] + data(milk) + data(bushfire) + + tmp <- sys.call() + cat("\nCall: ", deparse(substitute(tmp)),"\n") + + cat("Data Set n p Half LOG(obj) Time\n") + cat("========================================================\n") + domcd(heart[, 1:2], data(heart), nrep) + ## This will not work within the function, of course + ## - comment it out + ## IGNORE_RDIFF_BEGIN + ## domcd(starsCYG,data(starsCYG), nrep) + ## IGNORE_RDIFF_END + domcd(data.matrix(subset(phosphor, select = -plant)), data(phosphor), nrep) + domcd(stack.x,data(stackloss), nrep) + domcd(data.matrix(subset(coleman, select = -Y)), data(coleman), nrep) + domcd(data.matrix(subset(salinity, select = -Y)), data(salinity), nrep) + ## IGNORE_RDIFF_BEGIN + ## domcd(data.matrix(subset(wood, select = -y)), data(wood), nrep) + ## IGNORE_RDIFF_END + domcd(data.matrix(subset(hbk, select = -Y)), data(hbk), nrep) + + domcd(brain, "Animals", nrep) + domcd(milk, data(milk), nrep) + domcd(bushfire, data(bushfire), nrep) + cat("========================================================\n") + } > > pad.right <- function(z, pads) + { + ### Pads spaces to right of text + padding <- paste(rep(" ", pads), collapse = "") + paste(z, padding, sep = "") + } > > dodata() Call: dodata() Data Set n p Half LOG(obj) Time ======================================================== heart 12 2 Outliers: 5 [1] 2 6 8 10 12 ------------- Call: CovOgk(x = x) -> Method: Orthogonalized Gnanadesikan-Kettenring Estimator Robust Estimate of Location: height weight 39.76 35.71 Robust Estimate of Covariance: height weight height 15.88 32.07 weight 32.07 78.28 -------------------------------------------------------- phosphor 18 2 Outliers: 2 [1] 1 6 ------------- Call: CovOgk(x = x) -> Method: Orthogonalized Gnanadesikan-Kettenring Estimator Robust Estimate of Location: inorg organic 13.31 40.00 Robust Estimate of Covariance: inorg organic inorg 92.82 93.24 organic 93.24 152.62 -------------------------------------------------------- stackloss 21 3 Outliers: 2 [1] 1 2 ------------- Call: CovOgk(x = x) -> Method: Orthogonalized Gnanadesikan-Kettenring Estimator Robust Estimate of Location: Air.Flow Water.Temp Acid.Conc. 57.72 20.50 85.78 Robust Estimate of Covariance: Air.Flow Water.Temp Acid.Conc. Air.Flow 38.423 11.306 18.605 Water.Temp 11.306 6.806 5.889 Acid.Conc. 18.605 5.889 29.840 -------------------------------------------------------- coleman 20 5 Outliers: 3 [1] 1 6 10 ------------- Call: CovOgk(x = x) -> Method: Orthogonalized Gnanadesikan-Kettenring Estimator Robust Estimate of Location: salaryP fatherWc sstatus teacherSc motherLev 2.723 43.202 2.912 25.010 6.290 Robust Estimate of Covariance: salaryP fatherWc sstatus teacherSc motherLev salaryP 0.12867 2.80048 0.92026 0.15118 0.06413 fatherWc 2.80048 678.72549 227.36415 9.30826 16.15102 sstatus 0.92026 227.36415 101.39094 3.38013 5.63283 teacherSc 0.15118 9.30826 3.38013 0.57112 0.27701 motherLev 0.06413 16.15102 5.63283 0.27701 0.44801 -------------------------------------------------------- salinity 28 3 Outliers: 3 [1] 3 5 16 ------------- Call: CovOgk(x = x) -> Method: Orthogonalized Gnanadesikan-Kettenring Estimator Robust Estimate of Location: X1 X2 X3 10.74 2.68 22.99 Robust Estimate of Covariance: X1 X2 X3 X1 8.1047 -0.6365 -0.4720 X2 -0.6365 3.0976 -1.3520 X3 -0.4720 -1.3520 2.3648 -------------------------------------------------------- hbk 75 3 Outliers: 14 [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ------------- Call: CovOgk(x = x) -> Method: Orthogonalized Gnanadesikan-Kettenring Estimator Robust Estimate of Location: X1 X2 X3 1.538 1.780 1.687 Robust Estimate of Covariance: X1 X2 X3 X1 1.11350 0.04992 0.11541 X2 0.04992 1.13338 0.13843 X3 0.11541 0.13843 1.05261 -------------------------------------------------------- Animals 28 2 Outliers: 12 [1] 2 6 7 9 12 14 15 16 17 24 25 28 ------------- Call: CovOgk(x = x) -> Method: Orthogonalized Gnanadesikan-Kettenring Estimator Robust Estimate of Location: body brain 39.65 105.83 Robust Estimate of Covariance: body brain body 3981 7558 brain 7558 16594 -------------------------------------------------------- milk 86 8 Outliers: 22 [1] 1 2 3 11 12 13 14 15 16 17 18 20 27 41 44 47 50 70 74 75 77 85 ------------- Call: CovOgk(x = x) -> Method: Orthogonalized Gnanadesikan-Kettenring Estimator Robust Estimate of Location: X1 X2 X3 X4 X5 X6 X7 X8 1.03 35.80 33.10 26.15 25.13 25.06 123.06 14.39 Robust Estimate of Covariance: X1 X2 X3 X4 X5 X6 X7 X1 4.074e-07 5.255e-05 1.564e-04 1.506e-04 1.340e-04 1.234e-04 5.308e-04 X2 5.255e-05 1.464e+00 3.425e-01 2.465e-01 1.847e-01 2.484e-01 1.459e+00 X3 1.564e-04 3.425e-01 1.070e+00 7.834e-01 7.665e-01 7.808e-01 7.632e-01 X4 1.506e-04 2.465e-01 7.834e-01 6.178e-01 5.868e-01 5.959e-01 5.923e-01 X5 1.340e-04 1.847e-01 7.665e-01 5.868e-01 6.124e-01 5.967e-01 5.868e-01 X6 1.234e-04 2.484e-01 7.808e-01 5.959e-01 5.967e-01 6.253e-01 5.819e-01 X7 5.308e-04 1.459e+00 7.632e-01 5.923e-01 5.868e-01 5.819e-01 3.535e+00 X8 1.990e-07 1.851e-01 1.861e-01 1.210e-01 1.041e-01 1.116e-01 3.046e-01 X8 X1 1.990e-07 X2 1.851e-01 X3 1.861e-01 X4 1.210e-01 X5 1.041e-01 X6 1.116e-01 X7 3.046e-01 X8 1.292e-01 -------------------------------------------------------- bushfire 38 5 Outliers: 17 [1] 7 8 9 10 11 12 28 29 30 31 32 33 34 35 36 37 38 ------------- Call: CovOgk(x = x) -> Method: Orthogonalized Gnanadesikan-Kettenring Estimator Robust Estimate of Location: V1 V2 V3 V4 V5 104.5 146.0 275.6 217.8 279.3 Robust Estimate of Covariance: V1 V2 V3 V4 V5 V1 266.8 203.2 -1380.7 -311.1 -252.2 V2 203.2 178.4 -910.9 -185.9 -155.9 V3 -1380.7 -910.9 8279.7 2035.5 1615.4 V4 -311.1 -185.9 2035.5 536.5 418.6 V5 -252.2 -155.9 1615.4 418.6 329.2 -------------------------------------------------------- ======================================================== > > proc.time() user system elapsed 0.46 0.12 0.56