[Robast-commits] r152 - in branches/robast-0.6/pkg/ROptEst: R inst/scripts
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Aug 7 15:32:17 CEST 2008
Author: stamats
Date: 2008-08-07 15:32:17 +0200 (Thu, 07 Aug 2008)
New Revision: 152
Modified:
branches/robast-0.6/pkg/ROptEst/R/radiusMinimaxIC.R
branches/robast-0.6/pkg/ROptEst/R/roptest.R
branches/robast-0.6/pkg/ROptEst/inst/scripts/BinomialModel.R
Log:
adapted to new implementation
Modified: branches/robast-0.6/pkg/ROptEst/R/radiusMinimaxIC.R
===================================================================
--- branches/robast-0.6/pkg/ROptEst/R/radiusMinimaxIC.R 2008-08-07 08:28:07 UTC (rev 151)
+++ branches/robast-0.6/pkg/ROptEst/R/radiusMinimaxIC.R 2008-08-07 13:32:17 UTC (rev 152)
@@ -83,11 +83,9 @@
res$info <- rbind(res$info, c("radiusMinimaxIC",
paste("maximum ", sQuote(class(risk)[1]), "-inefficiency: ",
round(ineff, 3), sep="")))
- modIC <- function(L2Fam, IC){
- infMod <- InfRobModel(L2Fam, neighbor)
- optIC(infMod, risk)
- }
- res <- c(res, modifyIC = modIC)
+ res <- c(res, modifyIC = getModifyIC(L2FamIC = L2Fam,
+ neighbor = neighbor,
+ risk = risk))
return(generateIC(neighbor, L2Fam, res))
}else{
if(is(L2Fam at distribution, "UnivariateDistribution")){
@@ -201,11 +199,9 @@
res$info <- rbind(res$info, c("radiusMinimaxIC",
paste("maximum ", sQuote(class(risk)[1]), "-inefficiency: ",
round(ineff, 3), sep="")))
- modIC <- function(L2Fam, IC){
- infMod <- InfRobModel(L2Fam, neighbor)
- optIC(infMod, risk)
- }
- res <- c(res, modifyIC = modIC)
+ res <- c(res, modifyIC = getModifyIC(L2FamIC = L2Fam,
+ neighbor = neighbor,
+ risk = risk))
return(generateIC(neighbor, L2Fam, res))
}else{
stop("not yet implemented")
Modified: branches/robast-0.6/pkg/ROptEst/R/roptest.R
===================================================================
--- branches/robast-0.6/pkg/ROptEst/R/roptest.R 2008-08-07 08:28:07 UTC (rev 151)
+++ branches/robast-0.6/pkg/ROptEst/R/roptest.R 2008-08-07 13:32:17 UTC (rev 152)
@@ -50,10 +50,10 @@
stop("'steps' has to be of length 1")
}
- if(missing(initial.est)){
+ if(missing(initial.est))
initial.est <- estimate(MDEstimator(x = x, ParamFamily = L2Fam, distance = distance,
startPar = startPar, ...))
- }
+ if(is(initial.est, "Estimate")) initial.est <- estimate(initial.est)
newParam <- param(L2Fam)
main(newParam) <- initial.est
L2FamStart <- modifyModel(L2Fam, newParam)
Modified: branches/robast-0.6/pkg/ROptEst/inst/scripts/BinomialModel.R
===================================================================
--- branches/robast-0.6/pkg/ROptEst/inst/scripts/BinomialModel.R 2008-08-07 08:28:07 UTC (rev 151)
+++ branches/robast-0.6/pkg/ROptEst/inst/scripts/BinomialModel.R 2008-08-07 13:32:17 UTC (rev 152)
@@ -109,24 +109,86 @@
x <- rbinom(100, size=25, prob=(1-ind)*0.25 + ind*0.75)
## 2. Kolmogorov(-Smirnov) minimum distance estimator
-(est0 <- MDEstimator(x=x, BinomFamily(size=25), interval = c(0, 1)))
+(est0 <- MDEstimator(x=x, BinomFamily(size=25)))
## 3.1. one-step estimation: radius known
+## ac) Define infinitesimal robust model
RobB3 <- InfRobModel(center=BinomFamily(size=25, prob=estimate(est0)),
- neighbor=ContNeighborhood(radius=0.5))
+ neighbor=ContNeighborhood(radius=0.5))
+## bc) Compute optimally robust IC
IC9 <- optIC(model=RobB3, risk=asMSE())
+checkIC(IC9)
+## cc) Determine 1-step estimate
(est1c <- oneStepEstimator(x, IC=IC9, start=est0))
+## instead of ac)-cc) you can also use function roptest
+est1c1 <- roptest(x, BinomFamily(size = 25), eps = 0.05, initial.est = est0)
+checkIC(pIC(est1c1))
+## you can also omit step 2
+est1c2 <- roptest(x, BinomFamily(size = 25), eps = 0.05, distance = KolmogorovDist)
+checkIC(pIC(est1c2))
+
+## Using Cramer-von-Mises MD estimator (default)
+est1c3 <- roptest(x, BinomFamily(size = 25), eps = 0.025)
+checkIC(pIC(est1c3))
+
+## comparison of estimates
+estimate(est1c)
+estimate(est1c1)
+estimate(est1c2)
+estimate(est1c3)
+
+
+## av) Define infinitesimal robust model
RobB4 <- InfRobModel(center=BinomFamily(size=25, prob=estimate(est0)),
neighbor=TotalVarNeighborhood(radius=0.25))
+## bv) Compute optimally robust IC
IC10 <- optIC(model=RobB4, risk=asMSE())
+checkIC(IC10)
+## cv) Determine 1-step estimate
(est1v <- oneStepEstimator(x, IC=IC10, start=est0))
+## instead of av)-cv) you can also use function roptest
+est1v1 <- roptest(x, BinomFamily(size = 25), eps = 0.025, initial.est = est0,
+ neighbor = TotalVarNeighborhood())
+checkIC(pIC(est1v1))
+## you can also omit step 2
+est1v2 <- roptest(x, BinomFamily(size = 25), eps = 0.025,
+ neighbor = TotalVarNeighborhood(), distance = KolmogorovDist)
+checkIC(pIC(est1v2))
+
+## Using Cramer-von-Mises MD estimator (default)
+est1v3 <- roptest(x, BinomFamily(size = 25), eps = 0.025, neighbor = TotalVarNeighborhood())
+checkIC(pIC(est1v3))
+
+## comparison of estimates
+estimate(est1v)
+estimate(est1v1)
+estimate(est1v2)
+estimate(est1v3)
+
## 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))
+(est2c <- kStepEstimator(x, IC=IC9, start=est0, steps = 3L)
+est2c1 <- roptest(x, BinomFamily(size = 25), eps = 0.05, initial.est = est0, steps = 3L)
+checkIC(pIC(est2c1))
+
+est2c2 <- roptest(x, BinomFamily(size = 25), eps = 0.05, steps = 3L,
+ distance = KolmogorovDist)
+checkIC(pIC(est2c2))
+
+## Using Cramer-von-Mises MD estimator
+est2c3 <- roptest(x, BinomFamily(size = 25), eps = 0.05, steps = 3L)
+checkIC(pIC(est2c3))
+
+## comparison of estimates
+estimate(est2c)
+estimate(est2c1)
+estimate(est2c2)
+estimate(est2c3)
+
+
IC10 <- optIC(model=RobB4, risk=asMSE())
(est2v <- kStepEstimator(x, IC=IC10, start=est0, steps = 3L))
checkIC(pIC(est2v))
@@ -142,6 +204,12 @@
(est3v <- oneStepEstimator(x, IC=IC12, start=est0))
checkIC(pIC(est3v))
+## maximum radius for given sample size n: sqrt(n)*0.5
+est3c1 <- roptest(x, BinomFamily(size = 25), eps.upper = 0.5)
+checkIC(pIC(est3c1))
+est3v1 <- roptest(x, BinomFamily(size = 25), eps.upper = 0.5, neighbor = TotalVarNeighborhood())
+checkIC(pIC(est3v1))
+
## 4.2. k-step estimation: radius interval
IC11 <- radiusMinimaxIC(L2Fam=BinomFamily(size=25, prob=estimate(est0)),
neighbor=ContNeighborhood(), risk=asMSE(), loRad=0, upRad=Inf)
@@ -152,3 +220,10 @@
neighbor=TotalVarNeighborhood(), risk=asMSE(), loRad=0, upRad=Inf)
(est4v <- kStepEstimator(x, IC=IC12, start=est0, steps = 3L))
checkIC(pIC(est4v))
+
+## maximum radius for given sample size n: sqrt(n)*0.5
+est4c1 <- roptest(x, BinomFamily(size = 25), eps.upper = 0.5, steps = 3L)
+checkIC(pIC(est4c1))
+est4v1 <- roptest(x, BinomFamily(size = 25), eps.upper = 0.5, neighbor = TotalVarNeighborhood(),
+ steps = 3L)
+checkIC(pIC(est4v1)
More information about the Robast-commits
mailing list