[Rd] ansari.test.default: bug in call to uniroot?

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Mar 30 00:36:10 CEST 2007


Yes, thanks, an obvious typo and I will fix shortly.

On Thu, 29 Mar 2007, Stephen Weigand wrote:

> A recent message on ansari.test() prompted me to play with the examples. This
> doesn't work for me in R version 2.4.1
>
> R> ansari.test(rnorm(100), rnorm(100, 0, 2), conf.int = TRUE)
>
> Error in uniroot(ab, srange, tol = 1e-04, zq = qnorm(alpha/2, lower = FALSE)) :
> 	object "ab" not found
>
> It looks like there's a small typo in ccia() inside
> ansari.test.default() in which 'ab' is
> passed to uniroot rather than 'ab2'. The definition of ccia below was
> just copied
> from https://svn.r-project.org/R/trunk/src/library/stats/R/ansari.test.R
>
> ccia <- function(alpha) {
>     ## Check if the statistic exceeds both quantiles
>     ## first.
>     statu <- ab2(srange[1], zq=qnorm(alpha/2))
>     statl <- ab2(srange[2], zq=qnorm(alpha/2, lower=FALSE))
>     if (statu > 0 || statl < 0) {
>         warning("samples differ in location: cannot compute
> confidence set, returning NA")
>         return(c(NA, NA))
>     }
>     u <- uniroot(ab2, srange, tol=1e-4,
>                  zq=qnorm(alpha/2))$root
>     l <- uniroot(ab, srange, tol=1e-4,
>                  zq=qnorm(alpha/2, lower=FALSE))$root
>     ## The process of the statistics does not need to be
>     ## monotone: sort is ok here.
>     sort(c(u, l))
> }
>
> Stephen
> Rochester, MN USA
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list