~ubuntu-branches/ubuntu/oneiric/catools/oneiric

« back to all changes in this revision

Viewing changes to man/runquantile.Rd

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2010-04-12 10:02:22 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100412100222-75l1c9tuhfikstw3
Tags: 1.10-1
* Team upload (Closes: #577296).
* New upstream version.
* Update to Policy 3.8.4:
  - Changed section to ‘gnu-r’ (debian/control).
  - Incremented Standards-Version (debian/control).
* Collaborative Debian Med maintenance (debian/control):
  - Set our mailing list as Maintainer, move Steffen to Uploaders.
  - Allow upload by Debian Maintainers.
* Switched to Debhelper 7 (debian/control, debian/compat).
* Depend on a version equal or superior than the R upstream release that
  was used to build this package, using a R:Depends substvar
  debian/control, debian/rules).
* Removed mentions of copyright notices that do not exist anymore in
  the upstream code (debian/copyright, debian/README.Debian).
* Added notes to explain how this package is tested (debian/README.Debian).

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
\description{Moving (aka running, rolling) Window Quantile calculated over a vector}
5
5
\usage{
6
6
  runquantile(x, k, probs, type=7, 
7
 
         endrule=c("quantile", "NA", "trim", "keep", "constant", "func"))
 
7
         endrule=c("quantile", "NA", "trim", "keep", "constant", "func"),
 
8
         align = c("center", "left", "right"))
8
9
}
9
10
 
10
11
\arguments{
11
 
  \item{x}{numeric vector of length n}
 
12
  \item{x}{numeric vector of length n or matrix with n rows. If \code{x} is a 
 
13
    matrix than each column will be processed separately.}
12
14
  \item{k}{width of moving window; must be an integer between one and n }
13
15
  \item{endrule}{character string indicating how the values at the beginning 
14
16
    and the end, of the array, should be treated. Only first and last \code{k2} 
41
43
    algorithms, same as \code{type} in \code{\link{quantile}} function. 
42
44
    Another even more readable description of nine ways to calculate quantiles 
43
45
    can be found at \url{http://mathworld.wolfram.com/Quantile.html}. }
 
46
  \item{align}{specifies whether result should be centered (default), 
 
47
  left-aligned or right-aligned.  If \code{endrule}="quantile" then setting
 
48
  \code{align} to "left" or "right" will fall back on slower implementation 
 
49
  equivalent to \code{endrule}="func". }
44
50
}
45
51
 
46
52
\details{
63
69
}
64
70
 
65
71
\value{
66
 
  Function \code{runquantile} returns a matrix of size [n \eqn{\times}{x} 
67
 
  length(probs)]. Only in case of \code{endrule="trim"} the output will have 
68
 
  less rows. 
69
 
 
72
  If \code{x} is a matrix than function \code{runquantile} returns a matrix of 
 
73
  size [n \eqn{\times}{x} \code{\link{length}}(probs)]. If \code{x} is vactor 
 
74
  a than function \code{runquantile} returns a matrix of size 
 
75
  [\code{\link{dim}}(x) \eqn{\times}{x} \code{\link{length}}(probs)]. 
 
76
  If \code{endrule="trim"} the output will have fewer rows. 
 
77
}
70
78
 
71
79
\references{
72
80
  \itemize{       
184
192
  b = runquantile(x[n:1], k, probs=0.4)
185
193
  stopifnot(all(a[n:1]==b, na.rm=TRUE));
186
194
 
 
195
  # test vector vs. matrix inputs, especially for the edge handling
 
196
  nRow=200; k=25; nCol=10
 
197
  x = rnorm(nRow,sd=30) + abs(seq(nRow)-n/4)
 
198
  x[seq(1,nRow,10)] = NaN;              # add NANs
 
199
  X = matrix(rep(x, nCol ), nRow, nCol) # replicate x in columns of X
 
200
  a = runquantile(x, k, probs=0.6)
 
201
  b = runquantile(X, k, probs=0.6)
 
202
  stopifnot(all(abs(a-b[,1])<eps));        # vector vs. 2D array
 
203
  stopifnot(all(abs(b[,1]-b[,nCol])<eps)); # compare rows within 2D array
 
204
 
187
205
  # Exhaustive testing of runquantile to standard R approach
188
206
  numeric.test = function (x, k) {
189
207
    probs=c(1, 25, 50, 75, 99)/100