[Robast-commits] r111 - in branches/robast-0.6/pkg/RobLox: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jul 21 16:11:37 CEST 2008


Author: stamats
Date: 2008-07-21 16:11:37 +0200 (Mon, 21 Jul 2008)
New Revision: 111

Modified:
   branches/robast-0.6/pkg/RobLox/DESCRIPTION
   branches/robast-0.6/pkg/RobLox/R/roblox.R
   branches/robast-0.6/pkg/RobLox/R/rowRoblox.R
   branches/robast-0.6/pkg/RobLox/man/rowRoblox.Rd
Log:
some minor changes; in particular, RobLox now has Biobase in its "Suggests" field which via "rowMedians" clearly increases computations in case of "rowRoblox" and "colRoblox".

Modified: branches/robast-0.6/pkg/RobLox/DESCRIPTION
===================================================================
--- branches/robast-0.6/pkg/RobLox/DESCRIPTION	2008-07-21 12:57:16 UTC (rev 110)
+++ branches/robast-0.6/pkg/RobLox/DESCRIPTION	2008-07-21 14:11:37 UTC (rev 111)
@@ -6,6 +6,7 @@
     robust influence curves in case of normal
     location with unknown scale
 Depends: R(>= 2.6.0), stats, distrMod(>= 2.0.0), RobAStBase(>= 0.1.0)
+Suggests: Biobase
 Author: Matthias Kohl <Matthias.Kohl at stamats.de>
 Maintainer: Matthias Kohl <Matthias.Kohl at stamats.de>
 LazyLoad: yes

Modified: branches/robast-0.6/pkg/RobLox/R/roblox.R
===================================================================
--- branches/robast-0.6/pkg/RobLox/R/roblox.R	2008-07-21 12:57:16 UTC (rev 110)
+++ branches/robast-0.6/pkg/RobLox/R/roblox.R	2008-07-21 14:11:37 UTC (rev 111)
@@ -331,6 +331,8 @@
         }
     }else{
         if(missing(mean)){
+            if(length(sd) != 1)
+                stop("'sd' has length != 1")
             if(sd <= 0)
                 stop("'sd' has to be positive")
             if(missing(initial.est)){
@@ -438,6 +440,8 @@
             }
         }
         if(missing(sd)){
+            if(length(mean) != 1)
+                stop("mean has length != 1")
             if(missing(initial.est)){ 
                 sd <- mad(x, na.rm = TRUE)
                 if(sd == 0)

Modified: branches/robast-0.6/pkg/RobLox/R/rowRoblox.R
===================================================================
--- branches/robast-0.6/pkg/RobLox/R/rowRoblox.R	2008-07-21 12:57:16 UTC (rev 110)
+++ branches/robast-0.6/pkg/RobLox/R/rowRoblox.R	2008-07-21 14:11:37 UTC (rev 111)
@@ -111,8 +111,13 @@
 
     if(missing(mean) && missing(sd)){
         if(missing(initial.est)){
-            mean <- apply(x, 1, median, na.rm = TRUE)
-            sd <- apply(x, 1, mad, na.rm = TRUE)
+            if(require(Biobase)){
+                mean <- rowMedians(x, na.rm = TRUE)
+                sd <- rowMedians(abs(x-mean), na.rm = TRUE)/qnorm(0.75)
+            }else{
+                mean <- apply(x, 1, median, na.rm = TRUE)
+                sd <- apply(abs(x-mean), 1, median, na.rm = TRUE)/qnorm(0.75)
+            }
             if(any(sd == 0))
                 stop("'mad(x, na.rm = TRUE) == 0' => cannot compute a valid initial estimate, 
                       please specify one via 'initial.est'")
@@ -192,7 +197,7 @@
                                   paste("radius-minimax estimates for contamination interval [", 
                                     round(eps.lower, 3), ", ", round(eps.upper, 3), "]", sep = ""),
                                   paste("least favorable contamination: ", round(r/sqrtn, 3), sep = ""),
-                                  paste("maximum MSE-inefficiency: ", round(ineff, 3), sep = "")), 
+                                  paste("maximum MSE-inefficiency: ", round(ineff[1], 3), sep = "")), 
                                   ncol = 2, dimnames = list(NULL, c("method", "message")))
             return(structure(list("estimate" = robEst, "steps" = k, "Infos" = Info.matrix), 
                              class = c("ALEstimate", "Estimate")))
@@ -201,11 +206,15 @@
         if(missing(mean)){
             if(any(sd <= 0))
                 stop("'sd' has to be positive")
+            if(!is.numeric(sd) || (length(sd) != 1 && length(sd) != nrow(x)))
+                stop("'sd' has wrong dimension")
             if(missing(initial.est)){
-                mean <- apply(x, 1, median, na.rm = TRUE)
+                if(require(Biobase)){
+                    mean <- rowMedians(x, na.rm = TRUE)
+                }else{
+                    mean <- apply(x, 1, median, na.rm = TRUE)
+                }
             }else{
-                if(!is.numeric(sd) || (length(sd) != 1 && length(sd) != nrow(x)))
-                    stop("'sd' has wrong dimension")
                 if(!is.numeric(initial.est) || length(initial.est) != nrow(x))
                     stop("'initial.est' has wrong dimension")
                 mean <- initial.est
@@ -220,8 +229,8 @@
                     A <- sd^2*.getA.loc(r)
                     b <- sd*.getb.loc(r)
                 }
-                robEst <- .kstep.loc.matrix(x = x, initial.est = mean, A = A, b = b, sd = sd, k = k)
-                names(robEst) <- c("mean")
+                robEst <- as.matrix(.kstep.loc.matrix(x = x, initial.est = mean, A = A, b = b, sd = sd, k = k))
+                colnames(robEst) <- "mean"
                 Info.matrix <- matrix(c("roblox", 
                                         paste("optimally robust estimates for contamination 'eps' =", round(eps, 3),
                                               "and 'asMSE'")),
@@ -255,27 +264,32 @@
                         ineff <- (A - b^2*(r^2 - rlo^2))/Alo
                     }
                 }
-                robEst <- .kstep.loc.matrix(x = x, initial.est = mean, A = A, b = b, sd = sd, k = k)
-                names(robEst) <- c("mean")
+                robEst <- as.matrix(.kstep.loc.matrix(x = x, initial.est = mean, A = A, b = b, sd = sd, k = k))
+                colnames(robEst) <- "mean"
                 Info.matrix <- matrix(c(rep("roblox", 3), 
                                       paste("radius-minimax estimates for contamination interval [", 
                                         round(eps.lower, 3), ", ", round(eps.upper, 3), "]", sep = ""),
                                       paste("least favorable contamination: ", round(r/sqrtn, 3), sep = ""),
-                                      paste("maximum MSE-inefficiency: ", round(ineff, 3), sep = "")), 
+                                      paste("maximum MSE-inefficiency: ", round(ineff[1], 3), sep = "")), 
                                       ncol = 2, dimnames = list(NULL, c("method", "message")))
                 return(structure(list("estimate" = robEst, "steps" = k, "Infos" = Info.matrix), 
                                  class = c("ALEstimate", "Estimate")))
             }
         }
         if(missing(sd)){
-            if(missing(initial.est)){ 
-                sd <- apply(x, 1, mad, na.rm = TRUE)
+            if(!is.numeric(mean) || (length(mean) != 1 && length(mean) != nrow(x)))
+                stop("'mean' has wrong dimension")
+            if(missing(initial.est)){
+                if(require(Biobase)){
+                    M <- rowMedians(x, na.rm = TRUE)
+                    sd <- rowMedians(abs(x-M), na.rm = TRUE)/qnorm(0.75)
+                }else{
+                    sd <- apply(x, 1, mad, na.rm = TRUE)
+                }
                 if(any(sd == 0))
                   stop("'mad(x, na.rm = TRUE) == 0' => cannot compute a valid initial estimate, 
                        please specify one via 'initial.est'")
             }else{
-                if(!is.numeric(mean) || (length(mean) != 1 && length(mean) != nrow(x)))
-                    stop("'mean' has wrong dimension")
                 if(!is.numeric(initial.est) || length(initial.est) != nrow(x))
                     stop("'initial.est' has wrong dimension")
                 sd <- initial.est
@@ -294,8 +308,8 @@
                     a <- sd*.geta.sc(r)
                     b <- sd*.getb.sc(r)
                 }
-                robEst <- .kstep.sc.matrix(x = x, initial.est = sd, A = A, a = a, b = b, mean = mean, k = k)
-                names(robEst) <- c("sd")
+                robEst <- as.matrix(.kstep.sc.matrix(x = x, initial.est = sd, A = A, a = a, b = b, mean = mean, k = k))
+                colnames(robEst) <- "sd"
                 Info.matrix <- matrix(c("roblox", 
                                         paste("optimally robust estimates for contamination 'eps' =", round(eps, 3),
                                               "and 'asMSE'")),
@@ -331,13 +345,13 @@
                         ineff <- (A - b^2*(r^2 - rlo^2))/Alo
                     }
                 }
-                robEst <- .kstep.sc.matrix(x = x, initial.est = sd, A = A, a = a, b = b, mean = mean, k = k)
-                names(robEst) <- c("sd")
+                robEst <- as.matrix(.kstep.sc.matrix(x = x, initial.est = sd, A = A, a = a, b = b, mean = mean, k = k))
+                colnames(robEst) <- "sd"
                 Info.matrix <- matrix(c(rep("roblox", 3), 
                                       paste("radius-minimax estimates for contamination interval [", 
                                         round(eps.lower, 3), ", ", round(eps.upper, 3), "]", sep = ""),
                                       paste("least favorable contamination: ", round(r/sqrtn, 3), sep = ""),
-                                      paste("maximum MSE-inefficiency: ", round(ineff, 3), sep = "")), 
+                                      paste("maximum MSE-inefficiency: ", round(ineff[1], 3), sep = "")), 
                                       ncol = 2, dimnames = list(NULL, c("method", "message")))
                 return(structure(list("estimate" = robEst, "steps" = k, "Infos" = Info.matrix), 
                                  class = c("ALEstimate", "Estimate")))

Modified: branches/robast-0.6/pkg/RobLox/man/rowRoblox.Rd
===================================================================
--- branches/robast-0.6/pkg/RobLox/man/rowRoblox.Rd	2008-07-21 12:57:16 UTC (rev 110)
+++ branches/robast-0.6/pkg/RobLox/man/rowRoblox.Rd	2008-07-21 14:11:37 UTC (rev 111)
@@ -33,8 +33,10 @@
   scale with location specified, or both if neither is specified. The computation
   uses a k-step construction with an appropriate initial estimate for location
   or scale or location and scale, respectively. Valid candidates are e.g. 
-  median and/or MAD (default) as well as Kolmogorov(-Smirnov) or von Mises minimum 
-  distance estimators; cf. Rieder (1994) and Kohl (2005).
+  median and/or MAD (default) as well as Kolmogorov(-Smirnov) or Cram\'er von 
+  Mises minimum distance estimators; cf. Rieder (1994) and Kohl (2005). In case 
+  package Biobase from Bioconductor is installed as is suggested, 
+  median and/or MAD are computed using function \code{rowMedians}.
 
   These functions are optimized for the situation where one has a matrix 
   and wants to compute the optimally robust estimator for every row, 
@@ -44,7 +46,7 @@
   If the amount of gross errors (contamination) is known, it can be 
   specified by \code{eps}. The radius of the corresponding infinitesimal 
   contamination neighborhood is obtained by multiplying \code{eps} 
-  by the square root of the sample size. 
+  by the square root of the sample size.
 
   If the amount of gross errors (contamination) is unknown, try to find a 
   rough estimate for the amount of gross errors, such that it lies 
@@ -64,7 +66,8 @@
   In case of location, respectively scale one additionally has to specify
   \code{sd}, respectively \code{mean} where \code{sd} and \code{mean} can
   be a single number, i.e., identical for all rows, respectively columns,
-  or a vector, i.e., different for all rows, respectively columns.
+  or a vector with length identical to the number of rows, respectively 
+  columns.
 }
 \value{
   An object of S3-class \code{"ALEstimate"} which inherits from 



More information about the Robast-commits mailing list