[Distr-commits] r599 - in branches/distr-2.2/pkg: distr/R distr/inst distr/inst/doc distr/man distrMod/R distrMod/inst distrMod/man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Oct 6 13:11:49 CEST 2009
Author: ruckdeschel
Date: 2009-10-06 13:11:49 +0200 (Tue, 06 Oct 2009)
New Revision: 599
Modified:
branches/distr-2.2/pkg/distr/R/internals-qqplot.R
branches/distr-2.2/pkg/distr/R/qqplot.R
branches/distr-2.2/pkg/distr/inst/NEWS
branches/distr-2.2/pkg/distr/inst/doc/Rplots.pdf
branches/distr-2.2/pkg/distr/man/qqbounds.Rd
branches/distr-2.2/pkg/distr/man/qqplot.Rd
branches/distr-2.2/pkg/distrMod/R/qqplot.R
branches/distr-2.2/pkg/distrMod/inst/NEWS
branches/distr-2.2/pkg/distrMod/inst/TOBEDONE
branches/distr-2.2/pkg/distrMod/man/qqplot.Rd
Log:
+NEWS files for distr and distrMod updated
+enhanced docu for qqplot.R
+updated TOBEDONE in distrMod
+qqplot: new argument n.CI to control the number of points used for CI plotting
+qqplot: corrected point augmentation for CI plotting (was wrong for DiscreteDistribution)
Modified: branches/distr-2.2/pkg/distr/R/internals-qqplot.R
===================================================================
--- branches/distr-2.2/pkg/distr/R/internals-qqplot.R 2009-10-06 00:31:40 UTC (rev 598)
+++ branches/distr-2.2/pkg/distr/R/internals-qqplot.R 2009-10-06 11:11:49 UTC (rev 599)
@@ -36,7 +36,6 @@
return((1:length(x)) %in% nInSupp)
}
-.isEqual <- distr:::.isEqual
.SingleDiscrete <- function(x,D){
## produces a logical vector of
@@ -247,21 +246,25 @@
alpha0 = alpha*100))
if(!qqb$err["sim"]){
expression3 <- expression1
- lty0 <- lty.pCI
+ pch0 <- if(sum(!SI.c)>0) pch.pCI else 0
+ lty0 <- if(sum(SI.c)>0) lty.pCI else 0
col0 <- col.pCI
}
if(!qqb$err["pw"]){
expression3 <- expression2
- lty0 <- lty.sCI
+ pch0 <- if(sum(!SI.c)>0) pch.sCI else 0
+ lty0 <- if(sum(SI.c)>0) lty.sCI else 0
col0 <- col.sCI
}
if( qqb$err["pw"] && qqb$err["sim"]){
expression3 <- eval(substitute(expression(expression1, expression2)))
- lty0 <- c(lty.pCI, lty.sCI)
+ pch0 <- if(sum(!SI.c)>0) c(pch.pCI, pch.sCI) else 0
+ lty0 <- if(sum(SI.c)>0) c(lty.pCI, lty.sCI) else 0
col0 <- c(col.pCI,col.sCI)
}
legend("topleft", legend = expression3, bg = "white",
- lty = lty0, col = col0, lwd = 2, cex = .8)
+ lty = lty0, pch = pch0, merge= FALSE, col = col0,
+ lwd = 2, cex = .8)
}
return(invisible(NULL))
}
Modified: branches/distr-2.2/pkg/distr/R/qqplot.R
===================================================================
--- branches/distr-2.2/pkg/distr/R/qqplot.R 2009-10-06 00:31:40 UTC (rev 598)
+++ branches/distr-2.2/pkg/distr/R/qqplot.R 2009-10-06 11:11:49 UTC (rev 599)
@@ -9,7 +9,7 @@
plot.it = TRUE, xlab = deparse(substitute(x)),
ylab = deparse(substitute(y)), ...,
width = 10, height = 5.5, withSweave = getdistrOption("withSweave"),
- mfColRow=TRUE,
+ mfColRow=TRUE, n.CI = n,
col.IdL = "red", lty.IdL = 2, lwd.IdL = 2,
alpha.CI = .95, exact.pCI = (n<100), exact.sCI = (n<100), nosym.pCI = FALSE,
col.pCI = "orange", lty.pCI = 3, lwd.pCI = 2, pch.pCI = par("pch"), cex.pCI = par("cex"),
@@ -75,15 +75,28 @@
if(#is(y,"AbscontDistribution") &&
withConf){
xy <- unique(sort(c(xc.o,yc.o)))
+ xy <- xy[!.NotInSupport(xy,y)]
lxy <- length(xy)
- if(lxy<n){
- xy0 <- seq(min(xy),max(xy),length=n-lxy)
- xy <- sort(c(xy,xy0))
+ if(is(y,"DiscreteDistribution")){
+ n0 <- min(n.CI, length(support(y)))
+ n1 <- max(n0-lxy,0)
+ if (n1 >0 ){
+ notyetInXY <- setdiff(support(y), xy)
+ xy0 <- sample(notyetInXY, n1)
+ xy <- sort(c(xy,xy0))
+ }
+ }else{
+ if(lxy < n.CI){
+ n1 <- (n.CI-lxy)%/%3
+ xy0 <- seq(min(xy),max(xy),length=n1)
+ xy1 <- r(y)(n.CI-lxy-n1)
+ xy <- sort(c(xy,xy0,xy1))
+ }
}
.confqq(xy, y, withConf.pw, withConf.sim, alpha.CI,
col.pCI, lty.pCI, lwd.pCI, pch.pCI, cex.pCI,
col.sCI, lty.sCI, lwd.sCI, pch.sCI, cex.sCI,
- length(xc), exact.sCI = exact.sCI, exact.pCI = exact.pCI,
+ n, exact.sCI = exact.sCI, exact.pCI = exact.pCI,
nosym.pCI = nosym.pCI)
}
}
Modified: branches/distr-2.2/pkg/distr/inst/NEWS
===================================================================
--- branches/distr-2.2/pkg/distr/inst/NEWS 2009-10-06 00:31:40 UTC (rev 598)
+++ branches/distr-2.2/pkg/distr/inst/NEWS 2009-10-06 11:11:49 UTC (rev 599)
@@ -33,7 +33,14 @@
+ in distr generating functions [Univar]DistrList() gain Dlist argument
++ plotting:
+ * new diagnostic function qqplot to check the compatibility of two distributions
+ + special method for first argument "UnivariateDistribution" (to be checked
+ for compatibility) and for second argument of class "UnivariateDistribution"
+ (H_0 distribution)
+ + comes with corresponding (pointwise/simultaneous) confidence intervals
+
GENERAL ENHANCEMENTS:
+ added field "Encoding: latin1" to all DESCRIPTION files in order to avoid problems
Modified: branches/distr-2.2/pkg/distr/inst/doc/Rplots.pdf
===================================================================
--- branches/distr-2.2/pkg/distr/inst/doc/Rplots.pdf 2009-10-06 00:31:40 UTC (rev 598)
+++ branches/distr-2.2/pkg/distr/inst/doc/Rplots.pdf 2009-10-06 11:11:49 UTC (rev 599)
@@ -2,8 +2,8 @@
%âãÏÓ\r
1 0 obj
<<
-/CreationDate (D:20091006015144)
-/ModDate (D:20091006015144)
+/CreationDate (D:20091006130908)
+/ModDate (D:20091006130908)
/Title (R Graphics Output)
/Producer (R 2.10.0)
/Creator (R)
@@ -282,7 +282,7 @@
65.85 76.68 l
65.96 77.03 l
66.06 77.39 l
-66.16 77.76 l
+66.16 77.75 l
66.26 78.13 l
66.36 78.51 l
66.46 78.90 l
@@ -351,7 +351,7 @@
72.83 127.42 l
72.93 128.67 l
73.03 129.93 l
-73.13 131.21 l
+73.13 131.22 l
73.23 132.51 l
73.34 133.83 l
73.44 135.17 l
@@ -375,7 +375,7 @@
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
@@ -390,7 +390,7 @@
76.77 189.14 l
76.87 191.06 l
76.97 193.01 l
-77.08 194.96 l
+77.08 194.97 l
77.18 196.94 l
77.28 198.93 l
77.38 200.93 l
@@ -416,7 +416,7 @@
79.40 243.87 l
79.50 246.13 l
79.60 248.41 l
-79.70 250.70 l
+79.70 250.69 l
79.81 252.99 l
79.91 255.29 l
80.01 257.60 l
@@ -446,9 +446,9 @@
82.43 314.20 l
82.54 316.56 l
82.64 318.92 l
-82.74 321.26 l
+82.74 321.27 l
82.84 323.61 l
-82.94 325.95 l
+82.94 325.94 l
83.04 328.28 l
83.14 330.60 l
83.24 332.92 l
@@ -459,7 +459,7 @@
83.75 344.37 l
83.85 346.63 l
83.95 348.88 l
-84.05 351.11 l
+84.05 351.12 l
84.15 353.34 l
84.25 355.55 l
84.35 357.75 l
@@ -485,7 +485,7 @@
86.38 398.05 l
86.48 399.85 l
86.58 401.61 l
-86.68 403.36 l
+86.68 403.35 l
86.78 405.07 l
86.88 406.76 l
86.98 408.42 l
@@ -493,7 +493,7 @@
87.19 411.66 l
87.29 413.24 l
87.39 414.79 l
-87.49 416.31 l
+87.49 416.32 l
87.59 417.81 l
87.69 419.27 l
87.79 420.70 l
@@ -583,7 +583,7 @@
96.28 413.39 l
96.39 411.84 l
96.49 410.26 l
-96.59 408.66 l
+96.59 408.65 l
96.69 407.02 l
96.79 405.37 l
96.89 403.69 l
@@ -608,7 +608,7 @@
98.81 367.63 l
98.91 365.56 l
99.01 363.46 l
-99.11 361.36 l
+99.11 361.35 l
99.22 359.24 l
99.32 357.10 l
99.42 354.96 l
@@ -636,21 +636,21 @@
101.64 305.63 l
101.74 303.34 l
101.84 301.05 l
-101.95 298.75 l
+101.95 298.76 l
102.05 296.46 l
102.15 294.17 l
102.25 291.88 l
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
103.06 273.64 l
103.16 271.38 l
103.26 269.12 l
-103.36 266.87 l
+103.36 266.88 l
103.46 264.63 l
103.56 262.39 l
103.66 260.16 l
@@ -664,20 +664,20 @@
104.47 242.58 l
104.57 240.43 l
104.68 238.28 l
-104.78 236.15 l
+104.78 236.14 l
104.88 234.02 l
104.98 231.90 l
105.08 229.80 l
-105.18 227.70 l
+105.18 227.71 l
105.28 225.63 l
-105.38 223.56 l
+105.38 223.55 l
105.48 221.50 l
105.59 219.45 l
105.69 217.42 l
105.79 215.40 l
105.89 213.39 l
105.99 211.40 l
-106.09 209.42 l
+106.09 209.41 l
106.19 207.45 l
106.29 205.49 l
106.39 203.55 l
@@ -696,12 +696,12 @@
107.71 179.66 l
107.81 177.93 l
107.91 176.21 l
-108.01 174.51 l
+108.01 174.52 l
108.11 172.83 l
108.21 171.16 l
108.31 169.51 l
-108.42 167.87 l
-108.52 166.25 l
+108.42 167.88 l
+108.52 166.26 l
108.62 164.65 l
108.72 163.07 l
108.82 161.49 l
@@ -716,7 +716,7 @@
109.73 148.09 l
109.83 146.68 l
109.93 145.29 l
-110.03 143.91 l
+110.03 143.92 l
110.13 142.56 l
110.24 141.21 l
110.34 139.89 l
@@ -725,7 +725,7 @@
110.64 136.00 l
110.74 134.74 l
110.84 133.50 l
-110.94 132.26 l
+110.94 132.27 l
111.04 131.05 l
111.15 129.85 l
111.25 128.67 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
@@ -861,7 +861,7 @@
124.39 66.88 l
124.49 66.80 l
124.59 66.72 l
-124.69 66.63 l
+124.69 66.64 l
124.79 66.56 l
124.89 66.48 l
125.00 66.40 l
Modified: branches/distr-2.2/pkg/distr/man/qqbounds.Rd
===================================================================
--- branches/distr-2.2/pkg/distr/man/qqbounds.Rd 2009-10-06 00:31:40 UTC (rev 598)
+++ branches/distr-2.2/pkg/distr/man/qqbounds.Rd 2009-10-06 11:11:49 UTC (rev 599)
@@ -72,14 +72,20 @@
(\code{FALSE} if \code{withConf.sim} is \code{FALSE}).
}
\references{
- Gentleman reference to be added.
+ Durbin, J. (1973)
+ \emph{Distribution theory for tests based on the sample distribution
+ function}. SIAM.
+ Fisz, M. (1963). \emph{Probability Theory and Mathematical Statistics}.
+ 3rd ed. Wiley, New York.
}
\author{
Peter Ruckdeschel \email{Peter.Ruckdeschel at itwm.fraunhofer.de}
}
\seealso{
\code{\link[stats:qqnorm]{qqplot}} from package \pkg{stats} -- the standard QQ plot
- function, \code{\link[distr]{qqplot}} from package \pkg{distr} for
+ function, \code{\link[stats:ks.test]{ks.test}} again from package \pkg{stats}
+ for the implementation of the Kolmogorov distributions;
+ \code{\link[distr]{qqplot}} from package \pkg{distr} for
comparisons of distributions, and
\code{\link[distrMod]{qqplot}} from package \pkg{distrMod} for comparisons
of data with models, as well as \code{\link[RobAStBase]{qqplot}} for
Modified: branches/distr-2.2/pkg/distr/man/qqplot.Rd
===================================================================
--- branches/distr-2.2/pkg/distr/man/qqplot.Rd 2009-10-06 00:31:40 UTC (rev 598)
+++ branches/distr-2.2/pkg/distr/man/qqplot.Rd 2009-10-06 11:11:49 UTC (rev 599)
@@ -14,7 +14,7 @@
plot.it = TRUE, xlab = deparse(substitute(x)),
ylab = deparse(substitute(y)), ...,
width = 10, height = 5.5, withSweave = getdistrOption("withSweave"),
- mfColRow = TRUE, col.IdL = "red", lty.IdL = 2, lwd.IdL = 2,
+ mfColRow = TRUE, n.CI = n, col.IdL = "red", lty.IdL = 2, lwd.IdL = 2,
alpha.CI = .95, exact.pCI = (n<100), exact.sCI = (n<100), nosym.pCI = FALSE,
col.pCI = "orange", lty.pCI = 3, lwd.pCI = 2, pch.pCI = par("pch"),
cex.pCI = par("cex"),
@@ -47,6 +47,7 @@
\item{withSweave}{logical: if \code{TRUE} (for working with \command{Sweave})
no extra device is opened and height/width are not set}
\item{mfColRow}{shall default partition in panels be used --- defaults to \code{TRUE}}
+\item{n.CI}{numeric; number of points to be used for confidence interval}
\item{col.IdL}{color for the identity line}
\item{lty.IdL}{line type for the identity line}
\item{lwd.IdL}{line width for the identity line}
@@ -74,7 +75,9 @@
\description{
We generalize function \code{\link[stats:qqnorm]{qqplot}} from package \pkg{stats} to
be applicable to distribution objects. In this context,
- \code{qqplot} produces a QQ plot of two distributions.
+ \code{qqplot} produces a QQ plot of two distributions, i.e.; argument \code{x}
+ is the distribution to be checked for compatibility, and \code{y} is the
+ model (\eqn{H_0}{H0}-)distribution.
Graphical parameters may be given as arguments to \code{qqplot}.
The \pkg{stats} function
is just the method for signature \code{x=ANY,y=ANY}.
Modified: branches/distr-2.2/pkg/distrMod/R/qqplot.R
===================================================================
--- branches/distr-2.2/pkg/distrMod/R/qqplot.R 2009-10-06 00:31:40 UTC (rev 598)
+++ branches/distr-2.2/pkg/distrMod/R/qqplot.R 2009-10-06 11:11:49 UTC (rev 599)
@@ -37,6 +37,7 @@
.makeLenAndOrder <- distr:::.makeLenAndOrder
.inGaps <- distr:::.inGaps
.deleteItemsMCL <- distr:::.deleteItemsMCL
+.NotInSupport <- distr:::.NotInSupport
setMethod("qqplot", signature(x = "ANY",
y = "UnivariateDistribution"),
@@ -56,6 +57,7 @@
withSweave = getdistrOption("withSweave"), ## logical: if \code{TRUE}
## (for working with \command{Sweave}) no extra device is opened and height/width are not set
mfColRow = TRUE, ## shall we use panel partition mfrow=c(1,1)?
+ n.CI = n, ## number of points to be used for CI
withLab = FALSE, ## shall observation labels be plotted in
lab.pts = NULL, ## observation labels to be used
which.lbs = NULL, ## which observations shall be labelled
@@ -167,15 +169,29 @@
if(#is(y,"AbscontDistribution")&&
withConf){
xy <- unique(sort(c(x,yc.o)))
+ xy <- xy[!.NotInSupport(xy,y)]
lxy <- length(xy)
- if(lxy<n){
- xy0 <- seq(min(xy),max(xy),length=n-lxy+2)
- xy <- unique(sort(c(xy,xy0)))
+ if(is(y,"DiscreteDistribution")){
+ n0 <- min(n.CI, length(support(y)))
+ n1 <- max(n0-lxy,0)
+ if (n1 >0 ){
+ notyetInXY <- setdiff(support(y), xy)
+ xy0 <- sample(notyetInXY, n1)
+ xy <- sort(unique(c(xy,xy0)))
+ }
+ }else{
+ if(lxy < n.CI){
+ n1 <- (n.CI-lxy)%/%3
+ xy0 <- seq(min(xy),max(xy),length=n1)
+ xy1 <- r(y)(n.CI-lxy-n1)
+ xy <- sort(unique(c(xy,xy0,xy1)))
+ }
}
+
.confqq(xy, y, withConf.pw, withConf.sim, alpha.CI,
col.pCI, lty.pCI, lwd.pCI, pch.pCI, cex.pCI,
col.sCI, lty.sCI, lwd.sCI, pch.sCI, cex.sCI,
- length(x), exact.sCI = exact.sCI, exact.pCI = exact.pCI,
+ n, exact.sCI = exact.sCI, exact.pCI = exact.pCI,
nosym.pCI = nosym.pCI)
}
}
Modified: branches/distr-2.2/pkg/distrMod/inst/NEWS
===================================================================
--- branches/distr-2.2/pkg/distrMod/inst/NEWS 2009-10-06 00:31:40 UTC (rev 598)
+++ branches/distr-2.2/pkg/distrMod/inst/NEWS 2009-10-06 11:11:49 UTC (rev 599)
@@ -32,6 +32,14 @@
+ Models:
* checkL2deriv gains ... argument to pass on accuracy arguments to E()
++ plotting:
+ * new diagnostic function qqplot to check the quality of a model fit
+ + special methods for first argument "ANY" (the data) and for second argument
+ of class "UnivariateDistribution", "ProbFamily",
+ + comes with corresponding (pointwise/simultaneous) confidence intervals
+ + flexible labelling of data points
+
+
GENERAL ENHANCEMENTS:
+ added field "Encoding: latin1" to all DESCRIPTION files in order to avoid problems
Modified: branches/distr-2.2/pkg/distrMod/inst/TOBEDONE
===================================================================
--- branches/distr-2.2/pkg/distrMod/inst/TOBEDONE 2009-10-06 00:31:40 UTC (rev 598)
+++ branches/distr-2.2/pkg/distrMod/inst/TOBEDONE 2009-10-06 11:11:49 UTC (rev 599)
@@ -5,7 +5,6 @@
+ improve Routines for asymptotic covariance / IC for MDE
+ model diagnostics:
- *special qq plot for distributions
*several distances fitted-distribution
*fitted density vs histogram
*fitted cdf vs ecdf
@@ -19,4 +18,6 @@
+ model classes for multivariate location and scale based on distrEllipse
-+ integration of GParetoFamily (not so soon)
\ No newline at end of file
++ integration of GParetoFamily (not so soon)
+
++ generic functions to quantify model fit quality like AIC, BIC
\ No newline at end of file
Modified: branches/distr-2.2/pkg/distrMod/man/qqplot.Rd
===================================================================
--- branches/distr-2.2/pkg/distrMod/man/qqplot.Rd 2009-10-06 00:31:40 UTC (rev 598)
+++ branches/distr-2.2/pkg/distrMod/man/qqplot.Rd 2009-10-06 11:11:49 UTC (rev 599)
@@ -8,7 +8,7 @@
withConf = TRUE, withConf.pw = withConf, withConf.sim = withConf,
plot.it = TRUE, xlab = deparse(substitute(x)),ylab = deparse(substitute(y)),
..., width = 10, height = 5.5, withSweave = getdistrOption("withSweave"),
- mfColRow = TRUE, withLab = FALSE, lab.pts = NULL, which.lbs = NULL,
+ mfColRow = TRUE, n.CI = n, withLab = FALSE, lab.pts = NULL, which.lbs = NULL,
which.Order = NULL, order.traf = NULL,
col.IdL = "red", lty.IdL = 2, lwd.IdL = 2, alpha.CI = .95,
exact.pCI = (n<100), exact.sCI = (n<100), nosym.pCI = FALSE,
@@ -34,7 +34,7 @@
\item{x}{data to be checked for compatibility with distribution/model \code{y}.}
\item{y}{object of class \code{"UnivariateDistribution"} or of
class \code{"ProbFamily"}.}
-\item{n}{numeric; number of quantiles at which to do the comparison.}
+\item{n}{numeric; assumed sample size (by default length of \code{x}).}
\item{withIdLine}{logical; shall line \code{y = x} be plotted in?}
\item{withConf}{logical; shall confidence lines be plotted?}
\item{withConf.pw}{logical; shall pointwise confidence lines be plotted?}
@@ -50,6 +50,7 @@
\item{withSweave}{logical: if \code{TRUE} (for working with \command{Sweave})
no extra device is opened and height/width are not set}
\item{mfColRow}{shall default partition in panels be used --- defaults to \code{TRUE}}
+\item{n.CI}{numeric; number of points to be used for confidence interval}
\item{withLab}{logical; shall observation labels be plotted in?}
\item{lab.pts}{character or \code{NULL}; observation labels to be used}
\item{which.lbs}{integer or \code{NULL}; which observations shall be labelled}
@@ -110,7 +111,10 @@
quantiles of distribution \code{y}.}
\item{qqplot}{\code{signature(x = "ANY", y = "ProbFamily")}:
produces a QQ plot of a dataset \code{x} against the theoretical
-quantiles of the model distribution of model \code{y}.}
+quantiles of the model distribution of model \code{y}. Passed through
+the \code{\dots} argument, all arguments valid for
+\code{signature(x = "ANY", y = "UnivariateDistribution")}
+are also valid for this signature.}
}
}
More information about the Distr-commits
mailing list