[Robast-commits] r136 - in branches/robast-0.6/pkg: ROptEst/inst/scripts RobAStBase/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Aug 1 05:57:05 CEST 2008


Author: stamats
Date: 2008-08-01 05:57:04 +0200 (Fri, 01 Aug 2008)
New Revision: 136

Modified:
   branches/robast-0.6/pkg/ROptEst/inst/scripts/BinomialModel.R
   branches/robast-0.6/pkg/ROptEst/inst/scripts/PoissonModel.R
   branches/robast-0.6/pkg/RobAStBase/R/kStepEstimator.R
Log:
minor bug corrected, updates to new implementation

Modified: branches/robast-0.6/pkg/ROptEst/inst/scripts/BinomialModel.R
===================================================================
--- branches/robast-0.6/pkg/ROptEst/inst/scripts/BinomialModel.R	2008-07-31 18:33:22 UTC (rev 135)
+++ branches/robast-0.6/pkg/ROptEst/inst/scripts/BinomialModel.R	2008-08-01 03:57:04 UTC (rev 136)
@@ -125,24 +125,30 @@
 ## 3.2. k-step estimation: radius known
 IC9 <- optIC(model=RobB3, risk=asMSE())
 (est2c <- kStepEstimator(x, IC=IC9, start=est0, steps = 3L))
+checkIC(pIC(est2c))
 
 IC10 <- optIC(model=RobB4, risk=asMSE())
 (est2v <- kStepEstimator(x, IC=IC10, start=est0, steps = 3L))
+checkIC(pIC(est2v))
 
 ## 4.1. one-step estimation: radius interval
 IC11 <- radiusMinimaxIC(L2Fam=BinomFamily(size=25, prob=estimate(est0)),
                 neighbor=ContNeighborhood(), risk=asMSE(), loRad=0, upRad=Inf)
 (est3c <- oneStepEstimator(x, IC=IC11, start=est0))
+checkIC(pIC(est3c))
 
 IC12 <- radiusMinimaxIC(L2Fam=BinomFamily(size=25, prob=estimate(est0)),
                 neighbor=TotalVarNeighborhood(), risk=asMSE(), loRad=0, upRad=Inf)
 (est3v <- oneStepEstimator(x, IC=IC12, start=est0))
+checkIC(pIC(est3v))
 
 ## 4.2. k-step estimation: radius interval
 IC11 <- radiusMinimaxIC(L2Fam=BinomFamily(size=25, prob=estimate(est0)),
                 neighbor=ContNeighborhood(), risk=asMSE(), loRad=0, upRad=Inf)
 (est4c <- kStepEstimator(x, IC=IC11, start=est0, steps = 3L))
+checkIC(pIC(est4c))
 
 IC12 <- radiusMinimaxIC(L2Fam=BinomFamily(size=25, prob=estimate(est0)),
                 neighbor=TotalVarNeighborhood(), risk=asMSE(), loRad=0, upRad=Inf)
 (est4v <- kStepEstimator(x, IC=IC12, start=est0, steps = 3L))
+checkIC(pIC(est4v))

Modified: branches/robast-0.6/pkg/ROptEst/inst/scripts/PoissonModel.R
===================================================================
--- branches/robast-0.6/pkg/ROptEst/inst/scripts/PoissonModel.R	2008-07-31 18:33:22 UTC (rev 135)
+++ branches/robast-0.6/pkg/ROptEst/inst/scripts/PoissonModel.R	2008-08-01 03:57:04 UTC (rev 136)
@@ -123,20 +123,98 @@
        rep(5, 408), rep(6, 273), rep(7, 139), rep(8, 45), rep(9, 27), 
        rep(10, 10), rep(11, 4), rep(12, 0), rep(13, 1), rep(14, 1))
 
-## 0. mean (classical optimal)
+## 0. ML-estimator (mean)
 (est0 <- mean(x))
 
-## 1. Kolmogorov(-Smirnov) minimum distance estimator
-(est1 <- MDEstimator(x=x, PoisFamily(), interval = c(0, 10)))
+## with distrMod
+MLEstimator(x, PoisFamily(), interval = c(0, 10))
 
-## 2. one-step estimation: radius interval
+## with MASS
+library(MASS)
+fitdistr(x, densfun = "Poisson")
+
+## 1.1. Kolmogorov(-Smirnov) minimum distance estimator
+(est11 <- MDEstimator(x=x, PoisFamily(), interval = c(0, 10)))
+
+## 1.2. Cramer von Mises minimum distance estimator
+(est12 <- MDEstimator(x=x, PoisFamily(), distance = CvMDist, interval = c(0, 10)))
+
+## 2. k-step estimation: contamination neighborhood
 ## 2.1 small amount of contamination < 2%
-IC9 <- radiusMinimaxIC(L2Fam=PoisFamily(lambda=est1$estimate),
+IC9 <- radiusMinimaxIC(L2Fam=PoisFamily(lambda=estimate(est11)),
                 neighbor=ContNeighborhood(), risk=asMSE(), loRad=0, upRad=1)
-(est21 <- oneStepEstimator(x, IC=IC9, start=est1$estimate))
+IC10 <- radiusMinimaxIC(L2Fam=PoisFamily(lambda=estimate(est12)),
+                neighbor=ContNeighborhood(), risk=asMSE(), loRad=0, upRad=1)
+(est211 <- kStepEstimator(x, IC=IC9, start=est11, steps = 1L))
+## one could also use function oneStepEstimator
+oneStepEstimator(x, IC=IC9, start=est11)
+checkIC(pIC(est211))
+
+(est212 <- kStepEstimator(x, IC=IC9, start=est11, steps = 3L))
+checkIC(pIC(est212))
+
+(est213 <- kStepEstimator(x, IC=IC10, start=est12, steps = 1L))
+checkIC(pIC(est213))
+
+(est214 <- kStepEstimator(x, IC=IC10, start=est12, steps = 3L))
+checkIC(pIC(est214))
+
+
 ## 2.2 amount of contamination unknown
-IC10 <- radiusMinimaxIC(L2Fam=PoisFamily(lambda=est1$estimate),
+IC11 <- radiusMinimaxIC(L2Fam=PoisFamily(lambda=estimate(est11)),
                 neighbor=ContNeighborhood(), risk=asMSE(), loRad=0, upRad=Inf)
-(est22 <- oneStepEstimator(x, IC=IC10, start=est1$estimate))
+IC12 <- radiusMinimaxIC(L2Fam=PoisFamily(lambda=estimate(est12)),
+                neighbor=ContNeighborhood(), risk=asMSE(), loRad=0, upRad=Inf)
+(est221 <- oneStepEstimator(x, IC=IC11, start=est11))
+kStepEstimator(x, IC=IC11, start=est11)
+checkIC(pIC(est221))
 
+(est222 <- kStepEstimator(x, IC=IC11, start=est11, steps = 3L))
+checkIC(pIC(est222))
+
+(est223 <- kStepEstimator(x, IC=IC12, start=est12, steps = 1L))
+checkIC(pIC(est223))
+
+(est224 <- kStepEstimator(x, IC=IC12, start=est12, steps = 3L))
+checkIC(pIC(est224))
+
+## 3. k-step estimation: total variation neighborhood
+## 3.1 small amount of contamination < 2%
+IC13 <- radiusMinimaxIC(L2Fam=PoisFamily(lambda=estimate(est11)),
+                neighbor=TotalVarNeighborhood(), risk=asMSE(), loRad=0, upRad=1)
+IC14 <- radiusMinimaxIC(L2Fam=PoisFamily(lambda=estimate(est12)),
+                neighbor=TotalVarNeighborhood(), risk=asMSE(), loRad=0, upRad=1)
+(est311 <- kStepEstimator(x, IC=IC13, start=est11, steps = 1L))
+## one could also use function oneStepEstimator
+oneStepEstimator(x, IC=IC13, start=est11)
+checkIC(pIC(est311))
+
+(est312 <- kStepEstimator(x, IC=IC13, start=est11, steps = 3L))
+checkIC(pIC(est312))
+
+(est313 <- kStepEstimator(x, IC=IC14, start=est12, steps = 1L))
+checkIC(pIC(est313))
+
+(est314 <- kStepEstimator(x, IC=IC14, start=est12, steps = 3L))
+checkIC(pIC(est314))
+
+
+## 3.2 amount of contamination unknown
+IC15 <- radiusMinimaxIC(L2Fam=PoisFamily(lambda=estimate(est11)),
+                neighbor=TotalVarNeighborhood(), risk=asMSE(), loRad=0, upRad=Inf)
+IC16 <- radiusMinimaxIC(L2Fam=PoisFamily(lambda=estimate(est12)),
+                neighbor=TotalVarNeighborhood(), risk=asMSE(), loRad=0, upRad=Inf)
+(est321 <- oneStepEstimator(x, IC=IC15, start=est11))
+kStepEstimator(x, IC=IC15, start=est11)
+checkIC(pIC(est321))
+
+(est322 <- kStepEstimator(x, IC=IC15, start=est11, steps = 3L))
+checkIC(pIC(est322))
+
+(est323 <- kStepEstimator(x, IC=IC16, start=est12, steps = 1L))
+checkIC(pIC(est323))
+
+(est324 <- kStepEstimator(x, IC=IC16, start=est12, steps = 3L))
+checkIC(pIC(est324))
+
 distroptions("TruncQuantile", 1e-5) # default

Modified: branches/robast-0.6/pkg/RobAStBase/R/kStepEstimator.R
===================================================================
--- branches/robast-0.6/pkg/RobAStBase/R/kStepEstimator.R	2008-07-31 18:33:22 UTC (rev 135)
+++ branches/robast-0.6/pkg/RobAStBase/R/kStepEstimator.R	2008-08-01 03:57:04 UTC (rev 136)
@@ -63,7 +63,7 @@
                     asBias <- NULL
                 }
             }
-            return(new("kStepEstimator", 
+            return(new("kStepEstimate", 
                        name = paste(steps, "-step estimate", sep = ""),
                        estimate = res, samplesize = length(x), asvar = asVar,
                        asbias = asBias, pIC = IC, steps = 1L, Infos = Infos))
@@ -183,7 +183,7 @@
                     asBias <- NULL
                 }
             }
-            return(new("kStepEstimator", 
+            return(new("kStepEstimate", 
                        name = paste(steps, "-step estimate", sep = ""),
                        estimate = res, samplesize = ncol(x), asvar = asVar,
                        asbias = asBias, pIC = IC, steps = 1L, Infos = Infos))
@@ -301,7 +301,7 @@
                     asBias <- NULL
                 }
             }
-            return(new("kStepEstimator", 
+            return(new("kStepEstimate", 
                        name = paste(steps, "-step estimate", sep = ""),
                        estimate = res, samplesize = length(x), asvar = asVar,
                        asbias = asBias, pIC = IC, steps = 1L, Infos = Infos))
@@ -421,7 +421,7 @@
                     asBias <- NULL
                 }
             }
-            return(new("kStepEstimator", 
+            return(new("kStepEstimate", 
                        name = paste(steps, "-step estimate", sep = ""),
                        estimate = res, samplesize = ncol(x), asvar = asVar,
                        asbias = asBias, pIC = IC, steps = 1L, Infos = Infos))



More information about the Robast-commits mailing list