[Distr-commits] r424 - branches/distr-2.1/pkg/distrEx/man branches/distr-2.2/pkg/distr/R branches/distr-2.2/pkg/distr/man branches/distr-2.2/pkg/distrDoc branches/distr-2.2/pkg/distrDoc/inst/doc branches/distr-2.2/pkg/distrEx branches/distr-2.2/pkg/distrEx/R branches/distr-2.2/pkg/distrEx/inst branches/distr-2.2/pkg/distrEx/man branches/distr-2.2/pkg/distrMod branches/distr-2.2/pkg/distrSim branches/distr-2.2/pkg/distrTEst branches/distr-2.2/pkg/distrTeach branches/distr-2.2/www pkg/distr/R pkg/distr/chm pkg/distr/man pkg/distrDoc pkg/distrDoc/chm pkg/distrDoc/inst pkg/distrDoc/inst/doc pkg/distrEx pkg/distrEx/R pkg/distrEx/chm pkg/distrEx/inst pkg/distrEx/man pkg/distrEx/src pkg/distrMod pkg/distrSim pkg/distrTEst pkg/distrTeach www

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Mar 21 12:02:02 CET 2009


Author: ruckdeschel
Date: 2009-03-21 12:02:02 +0100 (Sat, 21 Mar 2009)
New Revision: 424

Added:
   pkg/distrEx/chm/distrExConstants.html
   pkg/distrEx/man/distrExConstants.Rd
Removed:
   branches/distr-2.2/www/~$strMod.html
Modified:
   branches/distr-2.1/pkg/distrEx/man/Pareto-class.Rd
   branches/distr-2.2/pkg/distr/R/getLow.R
   branches/distr-2.2/pkg/distr/R/internalUtils.R
   branches/distr-2.2/pkg/distr/man/getLow.Rd
   branches/distr-2.2/pkg/distrDoc/DESCRIPTION
   branches/distr-2.2/pkg/distrDoc/inst/doc/distr.Rnw
   branches/distr-2.2/pkg/distrEx/DESCRIPTION
   branches/distr-2.2/pkg/distrEx/R/Expectation.R
   branches/distr-2.2/pkg/distrEx/R/Expectation_LebDec.R
   branches/distr-2.2/pkg/distrEx/R/Functionals.R
   branches/distr-2.2/pkg/distrEx/R/Gumbel.R
   branches/distr-2.2/pkg/distrEx/R/Kurtosis.R
   branches/distr-2.2/pkg/distrEx/R/Skewness.R
   branches/distr-2.2/pkg/distrEx/inst/NEWS
   branches/distr-2.2/pkg/distrEx/man/E.Rd
   branches/distr-2.2/pkg/distrEx/man/Gumbel-class.Rd
   branches/distr-2.2/pkg/distrEx/man/Var.Rd
   branches/distr-2.2/pkg/distrMod/DESCRIPTION
   branches/distr-2.2/pkg/distrSim/DESCRIPTION
   branches/distr-2.2/pkg/distrTEst/DESCRIPTION
   branches/distr-2.2/pkg/distrTeach/DESCRIPTION
   branches/distr-2.2/www/distrEx.html
   pkg/distr/R/getLow.R
   pkg/distr/R/internalUtils.R
   pkg/distr/chm/Distr.chm
   pkg/distr/chm/getLow.html
   pkg/distr/man/getLow.Rd
   pkg/distrDoc/DESCRIPTION
   pkg/distrDoc/chm/distrDoc.chm
   pkg/distrDoc/inst/NEWS
   pkg/distrDoc/inst/doc/distr.Rnw
   pkg/distrEx/DESCRIPTION
   pkg/distrEx/NAMESPACE
   pkg/distrEx/R/Expectation.R
   pkg/distrEx/R/Expectation_LebDec.R
   pkg/distrEx/R/Functionals.R
   pkg/distrEx/R/Gumbel.R
   pkg/distrEx/R/Kurtosis.R
   pkg/distrEx/R/Skewness.R
   pkg/distrEx/chm/00Index.html
   pkg/distrEx/chm/E.html
   pkg/distrEx/chm/Gumbel-class.html
   pkg/distrEx/chm/Var.html
   pkg/distrEx/chm/distrEx.chm
   pkg/distrEx/chm/distrEx.hhp
   pkg/distrEx/chm/distrEx.toc
   pkg/distrEx/inst/NEWS
   pkg/distrEx/man/E.Rd
   pkg/distrEx/man/Gumbel-class.Rd
   pkg/distrEx/man/Var.Rd
   pkg/distrEx/src/distrEx.dll
   pkg/distrMod/DESCRIPTION
   pkg/distrSim/DESCRIPTION
   pkg/distrTEst/DESCRIPTION
   pkg/distrTeach/DESCRIPTION
   www/distrEx.html
Log:
+trunc:
 -> all packages: changed DESCRIPTION files to require version distrXXX 2.1
 -> distr: 
       + found embarrassing bug in .modifyqgaps (used max/min instead of pmax/pmin)
            (on usual plots did not show up as we do not use slot q there for q-plot...)
       + getLow, getUp gain argument "..." for DiscreteDistributions to be 
            able to use standard calling (with optional extra argument eps)
            no matter of the class being used as argument
 -> distrEx:
      + Expectation gains (optional) arguments low and upp for 
           lower and upper bounds of the integration range; 
      + other functionals based on this may use these arguments, too 
          (var, sd, skewness, kurtosis)
      + (NEWS, distrEx.html updated correspondingly)
      + new explicit E, var, median, IQR, skewness, kurtosis
          for Gumbel distribution; 
        -> to this end need new (global) (NAMESPACE-exported) constants: 
           * Euler-Mascheroni-constant exported as EULERMASCHERONICONSTANT
           * Ap?\195?\169ry-constant exported as APERYCONSTANT
      + Rd-file distrExConstants for these two constants
      
+branches/distr-2.2
 -> changed DESCRIPTION files to require version distrXXX 2.2
 -> [re]ported changes from trunc into this branch
 

Modified: branches/distr-2.1/pkg/distrEx/man/Pareto-class.Rd
===================================================================
--- branches/distr-2.1/pkg/distrEx/man/Pareto-class.Rd	2009-03-19 22:19:33 UTC (rev 423)
+++ branches/distr-2.1/pkg/distrEx/man/Pareto-class.Rd	2009-03-21 11:02:02 UTC (rev 424)
@@ -57,6 +57,23 @@
     \item{Min<-}{\code{signature(x = "Pareto")}: wrapped replace method for
       slot \code{Min} of slot \code{param}. }
 
+    \item{E}{\code{signature(object = "Pareto", fun = "missing", cond = "missing")}: 
+      exact evaluation of expectation using explicit expressions.}
+
+     \item{var}{\code{signature(x = "Pareto")}: 
+      exact evaluation of expectation using explicit expressions.}
+
+     \item{skewness}{\code{signature(x = "Pareto")}: 
+      exact evaluation of expectation using explicit expressions.}
+
+     \item{kurtosis}{\code{signature(x = "Pareto")}: 
+      exact evaluation of expectation using explicit expressions.}
+
+     \item{median}{\code{signature(x = "Pareto")}: 
+      exact evaluation of expectation using explicit expressions.}
+
+     \item{IQR}{\code{signature(x = "Pareto")}: 
+      exact evaluation of expectation using explicit expressions.}
   }
 }
 \references{Johnson et al. (1995) \emph{Continuous Univariate Distributions. Vol. 2. 2nd ed.}

Modified: branches/distr-2.2/pkg/distr/R/getLow.R
===================================================================
--- branches/distr-2.2/pkg/distr/R/getLow.R	2009-03-19 22:19:33 UTC (rev 423)
+++ branches/distr-2.2/pkg/distr/R/getLow.R	2009-03-21 11:02:02 UTC (rev 424)
@@ -54,12 +54,12 @@
                  }
             })
  setMethod("getLow", "DiscreteDistribution",
-            function(object) min(support(object)) )
+            function(object, ...) min(support(object)) )
  setMethod("getUp", "DiscreteDistribution",
-            function(object) max(support(object)) )
+            function(object, ...) max(support(object)) )
 
  setMethod("getLow", "LatticeDistribution",
-            function(object){ 
+            function(object, ...){ 
                 lattice <- lattice(object) 
                 qF <- q(object)
                 if(is.finite(Length(lattice)) || width(lattice)>0)
@@ -70,7 +70,7 @@
                    return(qF(p = exp(.fm(x = .5, f = q(object)))))
                 })
  setMethod("getUp", "LatticeDistribution",
-            function(object){
+            function(object, ...){
                 lattice <- lattice(object) 
                 if(is.finite(Length(lattice)) || width(lattice)<0)
                    return(max(support(object)))

Modified: branches/distr-2.2/pkg/distr/R/internalUtils.R
===================================================================
--- branches/distr-2.2/pkg/distr/R/internalUtils.R	2009-03-19 22:19:33 UTC (rev 423)
+++ branches/distr-2.2/pkg/distr/R/internalUtils.R	2009-03-21 11:02:02 UTC (rev 424)
@@ -1010,21 +1010,30 @@
   if(pmatch(leftright, table = c("left","right"), nomatch = 1) == 1){
      qnew <- function(p, lower.tail = TRUE, log.p = FALSE) {
              q0 <- qfun(p, lower.tail = lower.tail, log.p = log.p)
+             i0 <- seq(length=length(p))
              if(lower.tail){
                 if(log.p) p.gaps <- log(p.gaps)
                 for(i in 1:nrow(gaps)){
                     i1 <- .isEqual(p,p.gaps[i])
+                    i2 <- i0[p<p.gaps[i]]
+                    i3 <- i0[p>p.gaps[i]]
                     q0[i1] <- gaps[i,1]
-                    q0[p<p.gaps[i]] <- min(q0[p<p.gaps[i]],gaps[i,1])
-                    q0[p>p.gaps[i]] <- max(q0[p>p.gaps[i]],gaps[i,2])
+                    if(length(i2)>0)
+                       q0[i2] <- pmin(q0[i2],gaps[i,1])
+                    if(length(i3)>0)
+                       q0[i3] <- pmax(q0[i3],gaps[i,2])
                 }        
              }else{
                 if(log.p) p.gaps.l <- log(p.gaps.l)
                 for(i in 1:nrow(gaps)){
                     i1 <- .isEqual(p,p.gaps.l[i])
+                    i2 <- i0[p<p.gaps.l[i]]
+                    i3 <- i0[p>p.gaps.l[i]]
                     q0[i1] <- gaps[i,2]
-                    q0[p<p.gaps.l[i]] <- max(q0[p<p.gaps.l[i]],gaps[i,2])    
-                    q0[p>p.gaps.l[i]] <- min(q0[p>p.gaps.l[i]],gaps[i,1])    
+                    if(length(i2)>0)
+                       q0[i2] <- pmax(q0[i2],gaps[i,2])    
+                    if(length(i3)>0)
+                       q0[i3] <- pmin(q0[i3],gaps[i,1])    
                 }        
              }
              return(q0)
@@ -1032,21 +1041,30 @@
   }else{
      qnew <- function(p, lower.tail = TRUE, log.p = FALSE) {
              q0 <- qfun(p, lower.tail = lower.tail, log.p = log.p)
+             i0 <- seq(length=length(p))
              if(lower.tail){
                 if(log.p) p.gaps <- log(p.gaps)
                 for(i in 1:nrow(gaps)){
                     i1 <- .isEqual(p,p.gaps[i])
+                    i2 <- i0[p<p.gaps[i]]
+                    i3 <- i0[p>p.gaps[i]]
                     q0[i1] <- gaps[i,2]
-                    q0[p<p.gaps[i]] <- min(q0[p<p.gaps[i]],gaps[i,1])
-                    q0[p>p.gaps[i]] <- max(q0[p>p.gaps[i]],gaps[i,2])
+                    if(length(i2)>0)
+                       q0[i2] <- pmin(q0[i2],gaps[i,1])
+                    if(length(i3)>0)
+                       q0[i3] <- pmax(q0[i3],gaps[i,2])
                 }        
              }else{
                 if(log.p) p.gaps.l <- log(p.gaps.l)
                 for(i in 1:nrow(gaps)){
                     i1 <- .isEqual(p,p.gaps.l[i])
+                    i2 <- i0[p<p.gaps.l[i]]
+                    i3 <- i0[p>p.gaps.l[i]]
                     q0[i1] <- gaps[i,1]
-                    q0[p<p.gaps.l[i]] <- max(q0[p<p.gaps.l[i]],gaps[i,2])    
-                    q0[p>p.gaps.l[i]] <- min(q0[p>p.gaps.l[i]],gaps[i,1])    
+                    if(length(i2)>0)
+                       q0[i2] <- pmax(q0[i2],gaps[i,2])    
+                    if(length(i3)>0)
+                       q0[i3] <- pmin(q0[i3],gaps[i,1])    
                 }        
              }
              return(q0)

Modified: branches/distr-2.2/pkg/distr/man/getLow.Rd
===================================================================
--- branches/distr-2.2/pkg/distr/man/getLow.Rd	2009-03-19 22:19:33 UTC (rev 423)
+++ branches/distr-2.2/pkg/distr/man/getLow.Rd	2009-03-21 11:02:02 UTC (rev 424)
@@ -27,16 +27,16 @@
 \usage{
 \S4method{getUp}{AbscontDistribution}(object,
                                       eps = getdistrOption("TruncQuantile"))
-\S4method{getUp}{DiscreteDistribution}(object)
-\S4method{getUp}{LatticeDistribution}(object)
+\S4method{getUp}{DiscreteDistribution}(object, ...)
+\S4method{getUp}{LatticeDistribution}(object, ...)
 \S4method{getUp}{UnivarLebDecDistribution}(object,
                                       eps = getdistrOption("TruncQuantile"))
 \S4method{getUp}{UnivarMixingDistribution}(object,
                                       eps = getdistrOption("TruncQuantile"))
 \S4method{getLow}{AbscontDistribution}(object,
                                        eps = getdistrOption("TruncQuantile"))
-\S4method{getLow}{DiscreteDistribution}(object)
-\S4method{getLow}{LatticeDistribution}(object)
+\S4method{getLow}{DiscreteDistribution}(object, ...)
+\S4method{getLow}{LatticeDistribution}(object, ...)
 \S4method{getLow}{UnivarLebDecDistribution}(object,
                                       eps = getdistrOption("TruncQuantile"))
 \S4method{getLow}{UnivarMixingDistribution}(object,
@@ -45,6 +45,9 @@
 \arguments{
   \item{object}{a distribution object}
   \item{eps}{truncation point (numeric)}
+  \item{\dots}{for convenience only; makes it possible to call \code{getLow}, 
+  \code{getUp} with argument \code{eps} no matter of the class of \code{object};
+  is ignored in these functions.}
 }
 
 

Modified: branches/distr-2.2/pkg/distrDoc/DESCRIPTION
===================================================================
--- branches/distr-2.2/pkg/distrDoc/DESCRIPTION	2009-03-19 22:19:33 UTC (rev 423)
+++ branches/distr-2.2/pkg/distrDoc/DESCRIPTION	2009-03-21 11:02:02 UTC (rev 424)
@@ -7,9 +7,9 @@
 Author: Florian Camphausen, Matthias Kohl, Peter Ruckdeschel, Thomas
         Stabla
 Maintainer: Peter Ruckdeschel <Peter.Ruckdeschel at itwm.fraunhofer.de>
-Depends: R(>= 2.6.0), tools, distr(>= 2.0.0), startupmsg
-Suggests: distrEx(>= 2.0.0), distrSim(>= 2.0.0), distrTEst(>= 2.0.0),
-        distrTeach(>= 2.0.0), distrMod(>= 2.0.0), Biobase
+Depends: R(>= 2.6.0), tools, distr(>= 2.2.0), startupmsg, distrEx(>= 2.2.0), distrSim(>= 2.2.0), distrTEst(>= 2.2.0),
+        distrTeach(>= 2.2.0), distrMod(>= 2.2.0)
+Suggests: Biobase
 LazyLoad: yes
 License: LGPL-3
 URL: http://distr.r-forge.r-project.org/

Modified: branches/distr-2.2/pkg/distrDoc/inst/doc/distr.Rnw
===================================================================
--- branches/distr-2.2/pkg/distrDoc/inst/doc/distr.Rnw	2009-03-19 22:19:33 UTC (rev 423)
+++ branches/distr-2.2/pkg/distrDoc/inst/doc/distr.Rnw	2009-03-21 11:02:02 UTC (rev 424)
@@ -389,7 +389,7 @@
 {\sf R}-functions.\\
 %
 Schematically, the inheritance relations as well as the slots 
-of  the corresponding classes may be read off from figure~\ref{fig1c}. 
+of  the corresponding classes may be read off from Figure~\ref{fig1c}. 
 Class \code{LatticeDistribution} and slot \code{gaps}, as well as
 additional classes \code{AffLinAbscontDistribution}, 
 \code{AffLinDiscreteDistribution}, \code{AffLinLatticeDistribution} 
@@ -553,7 +553,7 @@
 Consequently, we have a method \code{liesIn} that may answer such questions by a 
 \code{TRUE}/\code{FALSE} statement. Schematically, the inheritance relations of 
 class \code{Parameter} as well as the slots of the corresponding
-\mbox{(sub-)}classes may be read off in figure~\ref{fig4c} where we do not 
+\mbox{(sub-)}classes may be read off in Figure~\ref{fig4c} where we do not 
 repeat inherited slots.
 %
 \ifpdf
@@ -584,7 +584,7 @@
 The most important set to be used as parameter domain/sample space
  (\code{rSpace}) will be an Euclidean space. So \code{rSpace} and 
  \code{EuclideanSpace} are also implemented as classes,
- the structure of which may be read off in figure~\ref{fig5c}.
+ the structure of which may be read off in Figure~\ref{fig5c}.
 \begin{figure}[htb]\label{fig5}
   \begin{center}
     \ifpdf
@@ -651,7 +651,7 @@
 This can be done by \code{savedata}.\\
 Schematically, the inheritance relations of class \code{Dataclass} as well as 
 the slots of the corresponding \mbox{(sub-)}classes may be read off in 
-figure~\ref{fig2c} where we do not  repeat inherited slots.
+Figure~\ref{fig2c} where we do not  repeat inherited slots.
 \begin{figure}[htb]\label{fig2}
   \begin{center}
     \ifpdf
@@ -683,7 +683,7 @@
 To organize all relevant information about these results, we introduce a class 
 \code{Evaluation} the slots of which is filled by method \code{evaluate} ---see 
 subsection~\ref{evaluate}. Schematically, the slots of this class may be read 
-off in figure~\ref{fig3c}.
+off in Figure~\ref{fig3c}.
 \begin{figure}[htb]\label{fig3}
   \begin{center}
     \ifpdf
@@ -729,7 +729,7 @@
 with results of the same range (e.g.\ a parameter space) generated on the
 same data, i.e.; on the same \code{Dataclass} object. To this end, from
 version 1.8 on, we have introduced class \code{EvaluationList}.
-Schematically, the slots of this class may be read off in figure~\ref{fig3c1}.
+Schematically, the slots of this class may be read off in Figure~\ref{fig3c1}.
 \begin{figure}[htb]\label{fig3-1}
   \begin{center}
     \ifpdf
@@ -1124,11 +1124,17 @@
 the far out tails. To this end, from version 2.1, our distribution classes
 gain internal slots \code{.lowerExact} and \code{.logExact} which control
 whether the corresponding slot functions \code{p} and \code{q} use particular
-code for computing on the log-scale (and also using explicit representations
-as upper quantiles (instead of computing $1-{\rm lowerQuantile}$. 
+code for computing on the log-scale respectively whether they use explicit representations
+for upper quantiles (instead of computing $1-{\rm lowerQuantile}$). 
 If a corresponging distribution object has slots \code{.lowerExact} and \code{.logExact}
-both true, we may use this to produce accurate simulations, especially for
-respectively truncated distributions.
+both \code{TRUE}, we may use this to produce accurate simulations, especially for
+respectively truncated distributions:
+<<TruncExtr, eval = TRUE>>=
+N <- Norm()
+TN <- Truncate(N, 20,22)
+r(TN)(20)  ## simulation accurate although :
+p(N)(20, lower.tail = FALSE) ## prob that N>=20 
+@
 
 \subsection{Additional helper functions}
 %
@@ -1143,7 +1149,15 @@
 class \code{AbscontDistribution} (where \code{q.r} takes care about 
 correct treatment of gaps using helper function \code{modifyqgaps}),
 for class \code{UnivarLebDecDistribution}, and for class \code{UnivarMixingDistribution}.
+<<qrex, eval = TRUE>>=
+B <- Binom(5,0.5)
+p(B)(3)
+p.l(B)(3)
+q(B)(.5)
+q.r(B)(0.5)
+@
 
+
 Again from version 2.1 on, class \code{DiscreteDistribution} has a helper
 method \code{prob} which returns vector of probabilities for the 
 support points. More precisely, the return value is a numeric vector 
@@ -1165,19 +1179,43 @@
 a.c./ discrete part of the object;  else the return value is weighted by 
 the respective weight of the part, i.e. \code{acWeight}/\code{discreteWeight}.
 
+<<probHN, eval = TRUE>>=
+B0 <- as(Binom(5,0.5),"DiscreteDistribution")
+   ## coercion necessary:
+   ## otherwise slot "prob" of B0 will be returned
+prob(B0)
+HN <- Huberize(N, -2,1)
+prob(HN)
+@
+
 In order to convert arbitrary univariate distributions to \code{AbscontDistribution}
 from version 2.1 on, we have function \code{makeAbscontDistribution} which
 takes slot \code{p} and uses \code{AbscontDistribution()} to generate a 
 corresponding smoothed version; to smear out mass points on the border
 of the support, these upper and lower bounds are somewhat enlarged.
+Note that in the result, slots \code{p} and \code{q} are not replaced but
+rather taken unchanged from the argument:
 
+<<makeAC, eval = TRUE, fig = TRUE>>=
+par(mfrow=c(2,3))
+plot(makeAbscontDistribution(Nbinom(5,.5)),mfColRow=FALSE)
+plot(makeAbscontDistribution(HN),mfColRow=FALSE)
+par(mfrow=c(1,1))
+@
+
 Methods \code{getLow}, \code{getUp} available for classes \code{DiscreteDistribution},
 \code{AbscontDistribution}, \code{UnivarLebDecDistribution}, and 
 \code{UnivarMixingDistribution} return ``numerical'' end points of the respective
 supports: if these distributions have finite end points, these are returned,
-else a lower/upper \code{ep}-quantile is returned, where \code{ep}, by default,
+else a lower/upper \code{eps}-quantile is returned, where \code{ep}, by default,
 is set to global options \code{TruncQuantile}.
 
+<<getLowUp, eval = TRUE>>=
+getLow(Nbinom(5,0.5))
+getUp(Nbinom(5,0.5))
+getLow(Norm(5,0.5))
+getUp(Norm(5,0.5))
+@
 
 
 %
@@ -1200,11 +1238,15 @@
 for either \pkg{distrSim} or \pkg{distrTEst}.
 
 \subsection{Plotting}
+
+\subsubsection[{Plotting for Distribution objects}]{Plotting for \code{Distribution} objects}
 For an object of class \code{Distribution},
 \code{plot} displays the density/probability function, the c.d.f.\ and the 
 quantile function of a distribution. Note that all usual parameters of 
 \code{plot} remain valid. For instance, you may increase the axis annotations 
-and so on. More important, you may also 
+and so on. \code{plot()} can also cope with \code{log}-arguments.
+
+\paragraph{\code{xlim} argument:} More importantly, you may also 
 override the automatically chosen $x$-region by passing an \code{xlim} argument:
 <<cauchy1, eval = TRUE, fig = TRUE>>=
   plot(Cauchy())
@@ -1221,7 +1263,7 @@
 \code{d.discrete}, \code{p.discrete}, \code{q.discrete}).
 
 
-Moreover you may control optional main, inner titles and subtitles with 
+\paragraph{titles:} Moreover you may control optional main, inner titles and subtitles with 
 arguments \code{main} / \code{sub} / \code{inner}. To this end there are 
 preset strings substituted in both expression and character vectors 
 (where in the following \code{x} denotes the argument 
@@ -1242,7 +1284,9 @@
 \code{cex.main} / \code{cex.inner} / \code{cex.sub} respectively with
 \code{col} / \code{col.main} / \code{col.inner} / \code{col.sub}. Additionally
 it may be helpful to control top and bottom margins with arguments
-\code{bmar}, \code{tmar}. \code{plot()} can also cope with \code{log}-arguments.
+\code{bmar}, \code{tmar}. 
+
+\paragraph{step-function features:} 
 We provide different default symbols for unattained [\code{pch.u}] / attained 
 [\code{pch.a}] one-sided limits, which may be overridden by corresponding
 arguments  \code{pch} / \code{pch.a} / \code{pch.u}.
@@ -1258,60 +1302,142 @@
 \code{do.points}, \code{verticals}, \code{col.points} / \code{col.vert} / 
 \code{col.hor} and \code{cex.points}.
 
-As examples consider the following 10 plots:
+As examples consider the following plots: The standard plot for
+a discrete distribution is shown in Figure~\ref{plotexPic1}.
 
-
-\begin{figure}[p]
+\begin{figure}[p] 
+\begin{center}
 <<plotex1, eval = TRUE, fig = TRUE, width=8.0,height=4.5>>=
 plot(Binom(size = 4, prob = 0.3))
 @
+    \caption{\label{plotexPic1}{Standard plot for discrete distributions
+    }}
+\end{center}
 \end{figure}
-\begin{figure}[p]
+
+Omitting the point symbols at jump points (\code{do.points = FALSE})
+and the corresponding vertical lines (\code{verticals = FALSE}) 
+in the \code{p} and \code{q} panels
+gives  Figure~\ref{plotexPic2}.
+\begin{figure}[p] 
+\begin{center}
 <<plotex2, eval = TRUE, fig = TRUE, width=8.0,height=4.5>>=
 plot(Binom(size = 4, prob = 0.3), do.points = FALSE, verticals = FALSE)
 @
+    \caption{\label{plotexPic2}{Plot for discrete distributions without
+    extra symbols at jump points and vertical lines
+    }}
+\end{center}
 \end{figure}
 
-\begin{figure}[p]
+Instead we might use a somewhat enlarged (\code{cex.main = 1.6}) 
+main title (\code{main = TRUE}) and omit the 
+panel titles (\code{inner = FALSE}). To this end, we should increase the
+margin between main title and panels (by \code{tmar = 6}). This
+is shown in Figure~\ref{plotexPic3}.
+
+\begin{figure}[p] 
+\begin{center}
 <<plotex3, eval = TRUE, fig = TRUE, width=8.0,height=4.5>>=
 plot(Binom(size = 4, prob = 0.3), main = TRUE, inner = FALSE, cex.main = 1.6,
      tmar = 6)
 @
+    \caption{\label{plotexPic3}{Plot for discrete distributions using a main 
+    title
+    }}
+\end{center}
 \end{figure}
 
+Changing point sizes (\code{cex.points}) and line width (\code{lwd}),
+and using (default) panel titles (set \code{TRUE} by default) 
+gives a somewhat different picture
+as in Figure~\ref{plotexPic4}.
+     
 \begin{figure}[p]
+\begin{center}
 <<plotex4, eval = TRUE, fig = TRUE, width=8.0,height=4.5>>=
 plot(Binom(size = 4, prob = 0.3), cex.points = 1.2, pch = 20, lwd = 2)
 @
+    \caption{\label{plotexPic4}{Plot for discrete distributions using panel 
+    titles and changed point sizes
+    }}
+\end{center}
 \end{figure}
 
+Different colors for different plot elements can be used by
+arguments \code{col} (general), \code{col.points} (jump points),
+\code{col.sub} (sub-titles), \code{col.inner} (panel titles).
+In Figure~\ref{plotexPic5}, this is shown; the figure uses main
+(\code{main = TRUE}),
+inner (\code{TRUE} by default) and sub (\code{sub = TRUE}) titles,
+using the default titles respectively.
+     
 \begin{figure}[p]
+\begin{center}
 <<plotex5, eval = TRUE, fig = TRUE, width=8.0,height=4.5>>=
 B <- Binom(size = 4, prob = 0.3)
 plot(B, col="red", col.points = "green", main = TRUE, col.main="blue",
      col.sub = "orange", sub = TRUE, cex.sub = 0.6, col.inner = "brown")
 @
+    \caption{\label{plotexPic5}{Plot for discrete distributions using main, panel 
+    and sub titles with changed colors
+    }}
+\end{center}
 \end{figure}
 
+Changing plot size for marking the jump points by \code{cex.points = 1.2}
+and selecting symbols for left limits (by \code{pch.u = 20}) and
+right values (by \code{pch.a = 20}) at jump points is exemplified  in 
+Figure~\ref{plotexPic6}.
+
 \begin{figure}[p]
+\begin{center}
 <<plotex6, eval = TRUE, fig = TRUE, width=8.0,height=4.5>>=
 plot(Nbinom(size = 4,prob = 0.3), cex.points = 1.2, pch.u = 20, pch.a = 10)
 @
+    \caption{\label{plotexPic6}{Plot for discrete distributions with different
+    symbols for marking jump points
+    }}
+\end{center}
 \end{figure}
 
+Using log-scale for both axes by \code{log = "xy"} and a reduced number of grid
+points for plotting by \code{ngrid = 200} is shown in 
+Figure~\ref{plotexPic7}.
+
 \begin{figure}[p]
+\begin{center}
 <<plotex7, eval = TRUE, fig = TRUE, width=8.0,height=4.5>>=
 plot(Chisq(), log = "xy", ngrid = 100)
 @
+    \caption{\label{plotexPic7}{Plot for absolutely continuous distributions 
+    using log scales
+    }}
+\end{center}
 \end{figure}
 
-\begin{figure}[p]
+Changing line type by \code{lty = 3} and color by \code{col = "red"},
+axis notation orientation by \code{las = 2} and the number of grid
+points used for plotting by \code{ngrid = 200} is shown in 
+Figure~\ref{plotexPic8}.
+\begin{figure}[p] 
+\begin{center}
 <<plotex8, eval = TRUE, fig = TRUE, width=8.0,height=4.5>>=
 plot(Norm(), lwd=3, col = "red", ngrid = 200, lty = 3, las = 2)
 @
+    \caption{\label{plotexPic8}{Plot for absolutely continuous distributions 
+    with different line type and reduced number of grid points
+    }}
+\end{center}
 \end{figure}
 
+You may also use hook functions in distribution plots from version 2.0 on,
+which is especially useful for plotting grids in the background as shown in  
+Figure~\ref{plotexPic9}; this plot also has non-default titles using
+preset strings substitutions (\%N, \%C, \%P, \%A, \%D).
+
 \begin{figure}[p]
+\begin{center}
 <<plotex9, eval = TRUE, fig = TRUE, width=8.0,height=4.5>>=
 plot(Norm(), panel.first = grid(), main = "my Distribution: \%A",
      inner = list(expression(paste(lambda, "-density of \%C(\%P)")), "CDF",
@@ -1319,29 +1445,77 @@
      sub = "this plot was correctly generated on \%D",
      cex.inner = 0.9, cex.sub = 0.8)
 @
+    \caption{\label{plotexPic9}{Plot for absolutely continuous distributions 
+    using non-standard titles and with a background grid
+    }}
+\end{center}
 \end{figure}
 
-\begin{figure}[p]
+Special care is take to correctly depict jumps in the quantile
+function / gaps in the support; from version 2.0 on you have
+function \code{setgaps()} to automatically such gaps, but in case
+of very small density values this may give some ``false positives''
+as shown for the $\chi^2$ distribution in Figure~\ref{plotexPic10}
+
+\begin{figure}[p] 
+\begin{center}
 <<plotex10, eval = TRUE, fig = TRUE, width=8.0,height=4.5>>=
 Ch <- Chisq(); setgaps(Ch, exactq = 3)
 plot(Ch, cex = 1.2, pch.u = 20, pch.a = 10, col.points = "green", 
      col.vert = "red")
 @
+    \caption{\label{plotexPic10}{Plot for absolutely continuous distributions 
+    with automatic gap detection
+    }}
+\end{center}
 \end{figure}
 
+From version 2.0 on, you may override the given panel
+configuration using argument \code{mfColRow=FALSE} 
+---see Figure~\ref{plotexPic11}.
+
+\begin{figure}[p]
+\begin{center}
+<<plotex11, eval = TRUE, fig = TRUE, width=8.0,height=8.0>>=
+layout(matrix(c(1,3,2,3), nrow=2))
+plot(N, mfColRow = FALSE)
+@
+    \caption{\label{plotexPic11}{Plot for absolutely continuous distributions 
+    using non-standard panel configuration
+    }}
+\end{center}
+\end{figure}
+
 Following a suggestion by \href{mailto:unwin at math.uni-augsburg.de}{Anthony Unwin},
 from version 2.1 you may also select the panels you like to plot, using
-argument \code{to.draw.arg}.
+argument \code{to.draw.arg}; the corresponding panels are named and
+may either be given by name or by number (the rank in drawing the default
+``complete'' plot); for details
+see \code{?plot}.  As example for this panel selection, see 
+Figure~\ref{plotexPic12}.
 
+\begin{figure}[p] 
+\begin{center}
+<<plotex12, eval = TRUE, fig = TRUE, width=8.0,height=8.0>>=
+layout(matrix(c(rep(1,6),2,2,3,3,4,4,5,5,5,6,6,6), 
+                   nrow=3, byrow=TRUE))
+plot(HN, mfColRow = FALSE,
+        to.draw.arg=c("p","d.c","p.c","q.c", "p.d","q.d"))
+@
+    \caption{\label{plotexPic12}{Plot for Lebesgue decomposed distributions 
+    with user-chosen selection of plotted panels
+    }}
+\end{center}
+\end{figure}
 
-\par
+\subsubsection[{Plotting for Dataclass objects}]{Plotting for \code{Dataclass} objects}
 For objects of  class \code{Dataclass} ---or of a corresponding subclass---
  \code{plot} plots the sample against the run index and in case  of  
  \code{ContSimulation} the contaminating variables are highlighted by a 
  different color. Additional arguments controlling
  the plot as in the default \code{plot} command may be passed, 
  confer \code{help("plot-methods",package="distrSim")}.
- \par
+\subsubsection[{Plotting for Evaluation objects}]{Plotting for \code{Evaluation} objects}
  For an object of class \code{Evaluation},
 \code{plot} yields a boxplot of the results of the evaluation.
 For an object of class \code{EvaluationList},
@@ -1359,6 +1533,7 @@
 usual {\tt S} recycling rules.
 %\newline??????1
 
+\subsubsection[{Plotting for L2paramFamily objects}]{Plotting for \code{L2paramFamily} objects}
 In package \pkg{distrMod} we have an additional plotting method for class
 \code{L2paramFamily}; besides the underlying model distribution this also
 plots the coordinates of the $L_2$-derivative (scores function).
@@ -1403,16 +1578,10 @@
 himself, confer the documentation of \code{setRNG}. One easy way to fill 
 the \code{Data} slot of a simulation \code{X} with ``new'' random numbers is
 <<simulate, eval = TRUE>>=
-have.distrSim <- suppressWarnings(require("distrSim"))
-if (have.distrSim)
-   {X <- Simulation()
-    seed(X) <- setRNG()
-    simulate(X)
-    print(Data(X)[1:10])
-   } else { 
-    cat("\n functionality not (yet) available; ")
-    cat("you have to install package \"distrSim\" first.\n")
-    }
+X <- Simulation()
+seed(X) <- setRNG()
+simulate(X)
+Data(X)[1:10]
 @
 %
 \subsection[Evaluate (in package distrTEst)]%
@@ -1503,42 +1672,47 @@
 \paragraph{exact evaluation}
 is available for \code{X} of class \code{Arcsine}, \code{Beta} (for noncentrality $0$), 
 \code{Binom}, \code{Cauchy}, \code{Chisq}, \code{Dirac}, \code{Exp}, \code{Fd}, 
-\code{Gammad}, \code{Geom}, \code{Hyper}, \code{Logis}, \code{Lnorm}, 
-\code{Nbinom}, \code{Norm}, \code{Pois}, \code{Td}, \code{Unif}, \code{Weibull}.
+\code{Gammad}, \code{Geom}, \code{Gumbel}, \code{Hyper}, \code{Logis}, \code{Lnorm}, 
+\code{Nbinom}, \code{Norm}, \code{Pareto}, \code{Pois}, \code{Td}, \code{Unif}, \code{Weibull}.
 \paragraph{examples} $ \mbox{ }$\newline
-<<expectationPrep, eval = TRUE, echo=FALSE>>=
-SweaveListingOptions("inSweave"=TRUE)
-@
+%<<expectationPrep, eval = TRUE, echo=FALSE>>=
+%SweaveListingOptions("inSweave"=TRUE)
+%@
 <<expectation, eval = TRUE>>=
-have.distrEx <- suppressWarnings(require("distrEx"))
-if (have.distrEx) 
-    {D4 <- LMCondDistribution(theta = 1)
-     D4  # corresponds to Norm(cond, 1)
-     N <- Norm(mean = 2)
+D4 <- LMCondDistribution(theta = 1)
+D4  # corresponds to Norm(cond, 1)
+N <- Norm(mean = 2)
 
-     print(E(D4, cond = 1))
-     print(E(D4, cond = 1, useApply = FALSE))
-     print(E(as(D4, "UnivariateCondDistribution"), cond = 1))
-     print(E(D4, function(x){x^2}, cond = 2))
-     print(E(D4, function(x){x^2}, cond = 2, useApply = FALSE))
-     print(E(N, function(x){x^2}))
-     print(E(as(N, "UnivariateDistribution"), function(x){x^2},
-       useApply = FALSE)) # crude Monte-Carlo
-     print(E(D4, function(x, cond){cond*x^2}, cond = 2,
-       withCond = TRUE))
-     print(E(D4, function(x, cond){cond*x^2}, cond = 2,
-       withCond = TRUE, useApply = FALSE))
-     print(E(N, function(x){2*x^2}))
-     print(E(as(N, "UnivariateDistribution"), function(x){2*x^2},
-       useApply = FALSE)) # crude Monte-Carlo
-     Y <- 5 * Binom(4, .25) - 3
-     print(Y); print(E(Y))  
-    } else {
-    cat("\n functionality not (yet) available; ")
-    cat("you have to install package \"distrEx\" first.\n")
-    }
+E(D4, cond = 1)
+E(D4, cond = 1, useApply = FALSE)
+E(as(D4, "UnivariateCondDistribution"), cond = 1)
+E(D4, function(x){x^2}, cond = 2)
+E(D4, function(x){x^2}, cond = 2, useApply = FALSE)
+E(N, function(x){x^2})
+E(as(N, "UnivariateDistribution"), function(x){x^2}, 
+     useApply = FALSE) # crude Monte-Carlo
+E(D4, function(x, cond){cond*x^2}, cond = 2,
+  withCond = TRUE)
+E(D4, function(x, cond){cond*x^2}, cond = 2,
+  withCond = TRUE, useApply = FALSE)
+E(N, function(x){2*x^2})
+E(as(N, "UnivariateDistribution"), function(x){2*x^2},
+  useApply = FALSE) # crude Monte-Carlo
+Y <- 5 * Binom(4, .25) - 3
+Y
+E(Y)  
 @
 %
+\paragraph{Controlling integration range:} From version 2.1 on, \code{E} gains
+arguments \code{low} and \code{upp} to restrict evaluation of the
+integrand to a given integration domain; these arguments can also
+be passed through by other functionals based on expectation, like
+\code{var}, \code{sd}, \code{skewness}, and \code{kurtosis}.
+<<expectationlow, eval = TRUE>>=
+E(Cauchy(), low=3, upp=5)
+var(Cauchy(), low=3, upp=5)
+@
+
 \paragraph{Controlling accuracy:} From version 2.1 on, our 
 expectation methods gain explicit arguments to set accuracy locally;
 i.e.; the MC-methods have an argument \code{Nsim} defaulting to 
@@ -1554,6 +1728,15 @@
 bounds as ${\rm median} \pm s_f \,{\rm IQR}$ where $s_f$ is a scaling factor
 to be passed on as argument \code{IQR.fac} which defaults to global option
 \code{IQR.fac}.
+%<<expectationPrep, eval = TRUE, echo=FALSE>>=
+%SweaveListingOptions("inSweave"=TRUE)
+%@
+<<expectation2, eval = TRUE>>=
+E(N, function(x)x^2) 
+E(N, function(x)x^2,  lowerTruncQuantile = 1e-5)
+var(Cauchy(), low =3, upperTruncQuantile = 1e-5,  IQR.fac = 10)
+var(Cauchy(), low =3, upperTruncQuantile = 1e-10, IQR.fac = 20)
+@
 
 %
 \subsubsection{Variance}
@@ -1589,7 +1772,11 @@
 \code{var} just returns the variance of distribution \code{X} --- or 
 of \code{fun(X)} if a function is passed as argument fun, or, if a condition 
 argument \code{cond} (for $Y=y$),  ${\rm Var}\,[X|Y=y]$ respectively 
-${\rm Var}\,[f(X)|Y=y]$ --- just as for \code{E}. \\
+${\rm Var}\,[f(X)|Y=y]$ --- just as for \code{E}.
+The same goes for corresponding arguments controlling the accuracy 
+of \code{E} locally from version 2.1 on (see paragraph ``Controlling accuracy''):
+These may simply passed through in a call to \code{var}.  
+
 For an object \code{Y} of a subclass of class 
 union \code{AffLinDistribution}, we determine the variance as 
 \code{Y at a\textasciicircum2 * var(Y at X0)} and hence use analytic terms for \code{X0} if
@@ -1597,9 +1784,9 @@
 \paragraph{exact evaluation} is provided for specific distributions if no 
 function and no condition argument is given:
 this is available for \code{X} of class \code{Arcsine}, \code{Beta} (for noncentrality $0$), 
-\code{Binom}, \code{Cauchy}, \code{Chisq},\code{Dirac}, \code{Exp}, \code{Fd}, 
-\code{Gammad}, \code{Geom}, \code{Hyper}, \code{Logis}, \code{Lnorm}, 
-\code{Nbinom}, \code{Norm}, \code{Pois}, \code{Unif}, \code{Td}, \code{Weibull}.
+\code{Binom}, \code{Cauchy}, \code{Chisq}, \code{Dirac}, \code{Exp}, \code{Fd}, 
+\code{Gammad}, \code{Geom}, \code{Gumbel}, \code{Hyper}, \code{Logis}, \code{Lnorm}, 
+\code{Nbinom}, \code{Norm}, \code{Pareto}, \code{Pois}, \code{Unif}, \code{Td}, \code{Weibull}.
 \subsubsection{Further functionals}
 By the same techniques we provide the following functionals for univariate 
 distributions:
@@ -1614,6 +1801,7 @@
   arguments)
   \item interquartile range: \code{IQR} (not for function arguments)
 \end{itemize}
+For details, see \code{?skewness}.
 %
 \subsection[Truncated moments (in package distrEx)]{Truncated moments 
 (in package \pkg{distrEx})}\label{m1df}
@@ -1994,8 +2182,6 @@
 \code{MCEstimator}. As an example we can use the negative log-likelihood as
 criterion; i.e., compute the maximum likelihood estimator.
 <<MCEstimator, eval = TRUE>>=
-have.distrMod <- suppressWarnings(require("distrMod"))
-if (have.distrMod){
     library(distrMod)
     x <- rgamma(50, scale = 0.5, shape = 3)
     G <- GammaFamily(scale = 1, shape = 2)
@@ -2005,7 +2191,6 @@
         return(res)
     }
     MCEstimator(x = x, ParamFamily = G, criterion = negLoglikelihood)
-}
 @
 The user can specialize the behavior of \code{MCEstimator} on two layers:
 instance-individual or class-individual.
@@ -2093,10 +2278,8 @@
 Hence, the maximum likelihood estimator and for instance the Kolmogorov MD 
 estimator can more easily be computed as follows.
 <<MLEstimator, eval = TRUE>>=
-if (have.distrMod){
     MLEstimator(x = x, ParamFamily = G)
     MDEstimator(x = x, ParamFamily = G, distance = KolmogorovDist)
-}
 @
 Within \code{MLEstimator}, we call method \code{mleCalc}, which then 
 dispatches according to its arguments \code{x} and \code{PFam}
@@ -2172,7 +2355,7 @@
 subsection~\ref{distrModO}.
 As example consider the following:
 <<CIex, eval = TRUE, fig = TRUE>>=
-
+require(distrMod)
 ## some transformation
 mtrafo <- function(x){
      nms0 <- c("scale","shape")
@@ -3025,72 +3208,62 @@
   {$\mbox{\hspace{2cm}}$\hphantom{\tt http:/}{\tt /mathe7/DISTR/SimulateandEstimate.R}}}}\\[2ex]
 \end{footnotesize}
 <<SimulateandEstimate, eval = TRUE, fig = TRUE, width=8.8,height=3.8>>=
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/distr -r 424


More information about the Distr-commits mailing list