[Distr-commits] r595 - in branches/distr-2.2/pkg: distr distr/R distr/inst/doc distr/man distrDoc distrEx/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Oct 6 01:40:03 CEST 2009


Author: ruckdeschel
Date: 2009-10-06 01:40:03 +0200 (Tue, 06 Oct 2009)
New Revision: 595

Added:
   branches/distr-2.2/pkg/distrDoc/NAMESPACE
Removed:
   branches/distr-2.2/pkg/distrEx/R/internals-qqplot-enhanced.R
Modified:
   branches/distr-2.2/pkg/distr/DESCRIPTION
   branches/distr-2.2/pkg/distr/R/0distrOptions.R
   branches/distr-2.2/pkg/distr/R/AllClasses.R
   branches/distr-2.2/pkg/distr/R/UnivarMixingDistribution.R
   branches/distr-2.2/pkg/distr/R/internalUtils_LCD.R
   branches/distr-2.2/pkg/distr/R/internals-qqplot.R
   branches/distr-2.2/pkg/distr/inst/doc/Rplots.pdf
   branches/distr-2.2/pkg/distr/man/internals-qqplot.Rd
Log:
+ distrDoc: forgot to upload NAMESPACE file for distrDoc 
+ distr: reintegrated approximation method from package distrEx 
  (check if distrEx available in global variable .distrExInstalled)
   calls to E(), sd() by distrEx::E(), distrEx::sd().
+ distr: try to fix some strange, not always reproducible error in 
examples to simplifyD-methods:

checking examples ... ERROR
Running examples in 'distr-Ex.R' failed.
The error most likely occurred in:

> ### * simplifyD-methods
>
> flush(stderr()); flush(stdout())
>
> ### Name: simplifyD-methods
> ### Title: Methods for function simplifyD in Package `distr'
> ### Aliases: simplifyD-methods simplifyD
> ###   simplifyD,AbscontDistribution-method
> ###   simplifyD,DiscreteDistribution-method
> ###   simplifyD,UnivarLebDecDistribution-method
> ###   simplifyD,UnivarMixingDistribution-method
> ### Keywords: distribution methods
>
> ### ** Examples
>
> Mix1 <- UnivarMixingDistribution(Norm(),Binom(2,.3),
+  UnivarLebDecDistribution(acPart = Chisq(df = 2), discretePart = Nbinom(3,.09),
+                           acWeight = 0.3),
+  Norm()-Chisq(df=3), mixCoeff=c(0,0,0.2,0.8), withSimplify = FALSE)

Error in f1(x) : approx(): attempted to interpolate NA values
Calls: UnivarMixingDistribution ... lapply -> FUN -> do.call -> <Anonymous> -> q
.l -> f1 -> .C
Execution halted


Modified: branches/distr-2.2/pkg/distr/DESCRIPTION
===================================================================
--- branches/distr-2.2/pkg/distr/DESCRIPTION	2009-10-05 21:53:00 UTC (rev 594)
+++ branches/distr-2.2/pkg/distr/DESCRIPTION	2009-10-05 23:40:03 UTC (rev 595)
@@ -6,6 +6,7 @@
 Author: Florian Camphausen, Matthias Kohl, Peter Ruckdeschel, Thomas Stabla
 Maintainer: Peter Ruckdeschel <Peter.Ruckdeschel at itwm.fraunhofer.de>
 Depends: R(>= 2.2.0), methods, graphics, startupmsg, sfsmisc, SweaveListingUtils
+Suggests: distrEx
 Imports: stats
 LazyLoad: yes
 Encoding: latin1

Modified: branches/distr-2.2/pkg/distr/R/0distrOptions.R
===================================================================
--- branches/distr-2.2/pkg/distr/R/0distrOptions.R	2009-10-05 21:53:00 UTC (rev 594)
+++ branches/distr-2.2/pkg/distr/R/0distrOptions.R	2009-10-05 23:40:03 UTC (rev 595)
@@ -1,3 +1,5 @@
+.distrExInstalled <- ("distrEx" %in% installed.packages())
+
 .distroptions <- list(
                       DefaultNrGridPoints = 2^12,
                       DistrResolution = 1e-6,

Modified: branches/distr-2.2/pkg/distr/R/AllClasses.R
===================================================================
--- branches/distr-2.2/pkg/distr/R/AllClasses.R	2009-10-05 21:53:00 UTC (rev 594)
+++ branches/distr-2.2/pkg/distr/R/AllClasses.R	2009-10-05 23:40:03 UTC (rev 595)
@@ -9,6 +9,8 @@
 .onAttach <- function(library, pkg)
 {
   unlockBinding(".distroptions", asNamespace("distr"))
+  unlockBinding(".distrExInstalled", asNamespace("distr"))
+
 ## global variable needed for flat.R
 ##  unlockBinding(".OkTyp", asNamespace("distr"))
     msga <- gettext(

Modified: branches/distr-2.2/pkg/distr/R/UnivarMixingDistribution.R
===================================================================
--- branches/distr-2.2/pkg/distr/R/UnivarMixingDistribution.R	2009-10-05 21:53:00 UTC (rev 594)
+++ branches/distr-2.2/pkg/distr/R/UnivarMixingDistribution.R	2009-10-05 23:40:03 UTC (rev 595)
@@ -8,6 +8,10 @@
             ldots <- c(ldots, Dlist.L)
        }
     l <- length(ldots)
+
+    if(l==0) stop ("No components given")
+    if(l==1) return(ldots[[1]])
+    
     mixDistr <- do.call(UnivarDistrList,args=ldots)
     ep <- .Machine$double.eps
     if(missing(mixCoeff))
@@ -36,7 +40,7 @@
            try(gaps <- gaps(mixDistr[[i]]), silent=TRUE)
         }else{
            if(!is(try(gaps0 <- gaps(mixDistr[[i]]), silent=TRUE),"try-error"))
-               gaps <- .mergegaps2(gaps,gaps0)
+               if(!is.null(gaps0)) gaps <- .mergegaps2(gaps,gaps0)
         }
     }    
     support <- numeric(0)

Modified: branches/distr-2.2/pkg/distr/R/internalUtils_LCD.R
===================================================================
--- branches/distr-2.2/pkg/distr/R/internalUtils_LCD.R	2009-10-05 21:53:00 UTC (rev 594)
+++ branches/distr-2.2/pkg/distr/R/internalUtils_LCD.R	2009-10-05 23:40:03 UTC (rev 595)
@@ -2,6 +2,7 @@
 
 .mergegaps <- function(gaps, support){
  if(is.null(gaps)) return(NULL)
+ if(is.null(support)) return(gaps)
  if(length(support)==0) return(gaps)
  
  mm <- rbind(cbind(gaps[ ,1],1),
@@ -150,6 +151,7 @@
 .qmixfun <- function(mixDistr, mixCoeff, Cont = TRUE, pnew, gaps = NULL, 
                      leftright = "left"){
   l <- length(mixCoeff)
+  if(l==0) return(NULL)
   loup <- .loupmixfun(mixDistr)
 
   n <- getdistrOption("DefaultNrGridPoints")
@@ -167,6 +169,8 @@
             suppsA,
             suppsA-getdistrOption("DistrResolution"))
   xseq <- sort(unique(xseq))          
+  if(length(xseq)<2)
+     xseq <- c(min(lo,up)-0.1,max(lo,up)+0.1)
 
   px.l <- pnew(xseq, lower.tail = TRUE)
   px.u <- pnew(xseq, lower.tail = FALSE)
@@ -179,6 +183,15 @@
 
 
 .loupmixfun <- function(mixDistr){
+    if(length(mixDistr)==0) return(list(qL = NA, ql = NA, qU = NA, qu = NA))
+    if(length(mixDistr)==1){
+      q1 <- q(mixDistr[[1]])
+      return(list(qL = q1(p = 0, lower.tail = TRUE),
+                  ql = q1(p = getdistrOption("TruncQuantile"), lower.tail = TRUE),
+                  qU = q1(p = 0, lower.tail = FALSE),
+                  qu = q1(p = getdistrOption("TruncQuantile"), lower.tail =FALSE)
+                  ))
+    }
     qL0 <- as.vector(unlist(lapply(mixDistr, function(x)
                          do.call(x at q,list(p = 0, lower.tail = TRUE)))))
     qL1 <- as.vector(unlist(lapply(mixDistr, function(x)

Modified: branches/distr-2.2/pkg/distr/R/internals-qqplot.R
===================================================================
--- branches/distr-2.2/pkg/distr/R/internals-qqplot.R	2009-10-05 21:53:00 UTC (rev 594)
+++ branches/distr-2.2/pkg/distr/R/internals-qqplot.R	2009-10-05 23:40:03 UTC (rev 595)
@@ -164,8 +164,18 @@
  if(is(D,"AbscontDistribution")){
     dp <- d(D)(x,log=TRUE)
     dsupp.p <- dsupp.m<-1
- }else{
-       stop("")
+ }else{ ## have E and sd available ?
+    if(!.distrExInstalled) stop("")
+    supp.ind <- sapply(x, function(y)
+                 which.min(abs(y-support(D))))
+    nx <- length(support(D))
+    supp.ind.p <- pmax(supp.ind + 1 ,nx)
+    supp.ind.m <- pmax(supp.ind - 1 ,1)
+    dsupp.p <- support(D)[supp.ind.p] - support(D)[supp.ind]
+    dsupp.m <- support(D)[supp.ind] - support(D)[supp.ind.m]
+    s <- distrEx::sd(D)
+    m <- distrEx::E(D)
+    dp <- log(pnorm((x+dsupp.p/2-m)/s) - pnorm((x-dsupp.m/2-m)/s))
  }
  ro <- exp(pq/2-dp)*(dsupp.p+dsupp.m)/2*qnorm((1+alpha)/2)
  return(cbind(left=-ro,right=ro))
@@ -173,6 +183,7 @@
 
 
 
+
 .confqq <- function(x,D, withConf.pw  = TRUE,  withConf.sim = TRUE, alpha,
                     col.pCI, lty.pCI, lwd.pCI, pch.pCI, cex.pCI,
                     col.sCI, lty.sCI, lwd.sCI, pch.sCI, cex.sCI,

Modified: branches/distr-2.2/pkg/distr/inst/doc/Rplots.pdf
===================================================================
--- branches/distr-2.2/pkg/distr/inst/doc/Rplots.pdf	2009-10-05 21:53:00 UTC (rev 594)
+++ branches/distr-2.2/pkg/distr/inst/doc/Rplots.pdf	2009-10-05 23:40:03 UTC (rev 595)
@@ -2,8 +2,8 @@
 %âãÏÓ\r
 1 0 obj
 <<
-/CreationDate (D:20091005234212)
-/ModDate (D:20091005234212)
+/CreationDate (D:20091006012823)
+/ModDate (D:20091006012823)
 /Title (R Graphics Output)
 /Producer (R 2.10.0)
 /Creator (R)
@@ -169,7 +169,7 @@
 54.43 64.20 l
 54.53 64.21 l
 54.63 64.22 l
-54.73 64.24 l
+54.73 64.23 l
 54.83 64.25 l
 54.94 64.26 l
 55.04 64.28 l
@@ -275,7 +275,7 @@
 65.15 74.45 l
 65.25 74.75 l
 65.35 75.05 l
-65.45 75.37 l
+65.45 75.36 l
 65.55 75.68 l
 65.65 76.01 l
 65.75 76.34 l
@@ -315,12 +315,12 @@
 69.19 93.26 l
 69.29 93.95 l
 69.39 94.66 l
-69.49 95.38 l
+69.49 95.37 l
 69.59 96.11 l
 69.70 96.85 l
 69.80 97.61 l
 69.90 98.39 l
-70.00 99.17 l
+70.00 99.18 l
 70.10 99.98 l
 70.20 100.79 l
 70.30 101.62 l
@@ -351,7 +351,7 @@
 72.83 127.42 l
 72.93 128.67 l
 73.03 129.93 l
-73.13 131.22 l
+73.13 131.21 l
 73.23 132.51 l
 73.34 133.83 l
 73.44 135.17 l
@@ -359,7 +359,7 @@
 73.64 137.89 l
 73.74 139.28 l
 73.84 140.68 l
-73.94 142.11 l
+73.94 142.10 l
 74.04 143.55 l
 74.14 145.01 l
 74.25 146.48 l
@@ -375,21 +375,21 @@
 75.26 162.23 l
 75.36 163.91 l
 75.46 165.60 l
-75.56 167.30 l
+75.56 167.31 l
 75.66 169.03 l
 75.76 170.77 l
 75.86 172.53 l
 75.96 174.31 l
 76.06 176.10 l
 76.17 177.92 l
-76.27 179.74 l
+76.27 179.75 l
 76.37 181.59 l
 76.47 183.45 l
 76.57 185.33 l
-76.67 187.22 l
+76.67 187.23 l
 76.77 189.14 l
 76.87 191.06 l
-76.97 193.01 l
+76.97 193.00 l
 77.08 194.96 l
 77.18 196.94 l
 77.28 198.93 l
@@ -401,13 +401,13 @@
 77.88 211.18 l
 77.99 213.27 l
 78.09 215.38 l
-78.19 217.50 l
+78.19 217.49 l
 78.29 219.63 l
 78.39 221.77 l
 78.49 223.93 l
 78.59 226.10 l
 78.69 228.28 l
-78.79 230.47 l
+78.79 230.48 l
 78.90 232.68 l
 79.00 234.90 l
 79.10 237.12 l
@@ -416,7 +416,7 @@
 79.40 243.87 l
 79.50 246.13 l
 79.60 248.41 l
-79.70 250.69 l
+79.70 250.70 l
 79.81 252.99 l
 79.91 255.29 l
 80.01 257.60 l
@@ -424,7 +424,7 @@
 80.21 262.24 l
 80.31 264.57 l
 80.41 266.90 l
-80.51 269.25 l
+80.51 269.24 l
 80.61 271.59 l
 80.72 273.94 l
 80.82 276.30 l
@@ -443,23 +443,23 @@
 82.13 307.11 l
 82.23 309.48 l
 82.33 311.84 l
-82.43 314.20 l
+82.43 314.21 l
 82.54 316.56 l
 82.64 318.92 l
 82.74 321.26 l
 82.84 323.61 l
-82.94 325.94 l
+82.94 325.95 l
 83.04 328.28 l
 83.14 330.60 l
 83.24 332.92 l
 83.34 335.23 l
-83.44 337.52 l
+83.44 337.53 l
 83.55 339.82 l
 83.65 342.10 l
 83.75 344.37 l
 83.85 346.63 l
 83.95 348.88 l
-84.05 351.12 l
+84.05 351.11 l
 84.15 353.34 l
 84.25 355.55 l
 84.35 357.75 l
@@ -473,10 +473,10 @@
 85.16 374.78 l
 85.26 376.84 l
 85.37 378.87 l
-85.47 380.89 l
+85.47 380.88 l
 85.57 382.88 l
 85.67 384.85 l
-85.77 386.81 l
+85.77 386.80 l
 85.87 388.74 l
 85.97 390.65 l
 86.07 392.53 l
@@ -603,7 +603,7 @@
 98.31 377.79 l
 98.41 375.79 l
 98.51 373.78 l
-98.61 371.75 l
+98.61 371.74 l
 98.71 369.70 l
 98.81 367.64 l
 98.91 365.56 l
@@ -619,20 +619,20 @@
 99.92 344.06 l
 100.02 341.85 l
 100.13 339.63 l
-100.23 337.40 l
+100.23 337.41 l
 100.33 335.17 l
 100.43 332.93 l
 100.53 330.68 l
-100.63 328.43 l
-100.73 326.17 l
+100.63 328.42 l
+100.73 326.16 l
 100.83 323.90 l
 100.93 321.63 l
 101.04 319.35 l
 101.14 317.07 l
 101.24 314.79 l
 101.34 312.50 l
-101.44 310.21 l
-101.54 307.93 l
+101.44 310.22 l
+101.54 307.92 l
 101.64 305.63 l
 101.74 303.34 l
 101.84 301.05 l
@@ -643,7 +643,7 @@
 102.35 289.59 l
 102.45 287.30 l
 102.55 285.02 l
-102.65 282.74 l
+102.65 282.73 l
 102.75 280.46 l
 102.86 278.18 l
 102.96 275.91 l
@@ -657,11 +657,11 @@
 103.77 257.93 l
 103.87 255.72 l
 103.97 253.51 l
-104.07 251.30 l
+104.07 251.31 l
 104.17 249.11 l
 104.27 246.93 l
 104.37 244.75 l
-104.47 242.59 l
+104.47 242.58 l
 104.57 240.43 l
 104.68 238.28 l
 104.78 236.14 l
@@ -669,7 +669,7 @@
 104.98 231.90 l
 105.08 229.80 l
 105.18 227.71 l
-105.28 225.62 l
+105.28 225.63 l
 105.38 223.56 l
 105.48 221.50 l
 105.59 219.45 l
@@ -684,7 +684,7 @@
 106.49 201.63 l
 106.60 199.72 l
 106.70 197.82 l
-106.80 195.94 l
+106.80 195.93 l
 106.90 194.07 l
 107.00 192.21 l
 107.10 190.37 l
@@ -701,7 +701,7 @@
 108.21 171.16 l
 108.31 169.51 l
 108.42 167.88 l
-108.52 166.26 l
+108.52 166.25 l
 108.62 164.65 l
 108.72 163.06 l
 108.82 161.49 l
@@ -734,7 +734,7 @@
 111.55 125.21 l
 111.65 124.09 l
 111.75 122.99 l
-111.85 121.89 l
+111.85 121.90 l
 111.95 120.82 l
 112.06 119.76 l
 112.16 118.71 l
@@ -756,7 +756,7 @@
 113.77 103.94 l
 113.87 103.13 l
 113.98 102.34 l
-114.08 101.55 l
+114.08 101.56 l
 114.18 100.79 l
 114.28 100.03 l
 114.38 99.29 l
@@ -798,7 +798,7 @@
 118.02 79.71 l
 118.12 79.34 l
 118.22 78.97 l
-118.32 78.62 l
+118.32 78.61 l
 118.42 78.26 l
 118.53 77.92 l
 118.63 77.58 l

Modified: branches/distr-2.2/pkg/distr/man/internals-qqplot.Rd
===================================================================
--- branches/distr-2.2/pkg/distr/man/internals-qqplot.Rd	2009-10-05 21:53:00 UTC (rev 594)
+++ branches/distr-2.2/pkg/distr/man/internals-qqplot.Rd	2009-10-05 23:40:03 UTC (rev 595)
@@ -12,6 +12,7 @@
 \alias{.q2pw}
 \alias{.confqq}
 \alias{.deleteItemsMCL}
+\alias{.distrExInstalled}
 
 
 \title{Internal functions for qqplot of package distr}
@@ -38,6 +39,7 @@
                     n,exact.sCI=(n<100),exact.pCI=(n<100), nosym.pCI = FALSE)
 
 .deleteItemsMCL(mcl)
+.distrExInstalled
 }
 
 
@@ -153,6 +155,10 @@
 this is necessary in the manipulation of an original call
 to a specific \code{qqplot} method to pass on the \code{\dots} argument
 correctly to calls the mentioned functions.
+
+\code{.distrExInstalled} is a constant logical --- \code{TRUE} if package
+\pkg{distrEx} is installed.
+
 }
 
 

Added: branches/distr-2.2/pkg/distrDoc/NAMESPACE
===================================================================
--- branches/distr-2.2/pkg/distrDoc/NAMESPACE	                        (rev 0)
+++ branches/distr-2.2/pkg/distrDoc/NAMESPACE	2009-10-05 23:40:03 UTC (rev 595)
@@ -0,0 +1,11 @@
+import("methods")
+import("startupmsg")
+import("MASS")
+import("distr")
+import("distrEx")
+import("RandVar")
+import("distrMod")
+import("distrTeach")
+import("distrSim")
+import("distrTEst")
+

Deleted: branches/distr-2.2/pkg/distrEx/R/internals-qqplot-enhanced.R
===================================================================
--- branches/distr-2.2/pkg/distrEx/R/internals-qqplot-enhanced.R	2009-10-05 21:53:00 UTC (rev 594)
+++ branches/distr-2.2/pkg/distrEx/R/internals-qqplot-enhanced.R	2009-10-05 23:40:03 UTC (rev 595)
@@ -1,33 +0,0 @@
-################################################################
-# QQ - Plot helper functions in package distr enhanced by distrEx
-################################################################
-
-
-assignInNamespace(".q2pw", value=function(x,p.b,D,n,alpha,exact=(n<100),nosym=FALSE){
- if(exact){
-    fct <- if(nosym) .BinomCI.nosym else .BinomCI
-    ro <- fct(x,p.b,D,n,alpha)
-    return(ro)
- }
- pq <- log(p.b)+log(1-p.b)
- if(is(D,"AbscontDistribution")){
-    dp <- d(D)(x,log=TRUE)
-    dsupp.p <- dsupp.m<-1
- }else{ ## have E and sd available
-    supp.ind <- sapply(x, function(y)
-                 which.min(abs(y-support(D))))
-    nx <- length(support(D))
-    supp.ind.p <- pmax(supp.ind + 1 ,nx)
-    supp.ind.m <- pmax(supp.ind - 1 ,1)
-    dsupp.p <- support(D)[supp.ind.p] - support(D)[supp.ind]
-    dsupp.m <- support(D)[supp.ind] - support(D)[supp.ind.m]
-    s <- sd(D)
-    m <- E(D)
-    dp <- log(pnorm((x+dsupp.p/2-m)/s) - pnorm((x-dsupp.m/2-m)/s))
- }
- ro <- exp(pq/2-dp)*(dsupp.p+dsupp.m)/2*qnorm((1+alpha)/2)
- return(cbind(left=-ro,right=ro))
-}, ns="distr")
-
-
-



More information about the Distr-commits mailing list