[Rd] a not-a-bug report on integrate (PR#7070)

ligges at statistik.uni-dortmund.de ligges at statistik.uni-dortmund.de
Thu Jul 8 17:45:43 CEST 2004


Rembert.DeBlander at econ.kuleuven.ac.be wrote:
>>version
> 

PLEASE:

a) Use a sensible subject line
b) Please post only post bug reports if you are sure it is a bug (and 
here it is not a bug!)
c) Check the recent R version (1.9.1) if posting bugs, not an outdated one!
d) Only named arguments are passed through the ... argument:

  integrate(dnorm, lower=-Inf, upper=3, mean=-1, sd=7)

Uwe Ligges



           _
> platform i686-pc-linux-gnu
> arch     i686
> os       linux-gnu
> system   i686, linux-gnu
> status
> major    1
> minor    7.1
> year     2003
> month    06
> day      16
> language R
> 
> Bug:
> 
> integrate(f,lower,upper,extra_args)
> 
> where
> 
> f <- function(x,extra_args)
> {
> body
> }
> 
> integrate doesn't pass the extra arguments when calling f.
> As a first check of this finding I integrated dnorm from minus infinity =
> to 1, with mu =3D -1 and sd =3D 7. As shown below the result is not =
> equal to pnorm(1,-1,7), but it is equal to pnorm(1,0,1) where the =
> default values for mu and sd are taken.
> As a second check I debugged integrate see example 2 below.
> Since the function I need to integrate doesn't make sense with default =
> values for the extra parameters, I do not find a way to work around this =
> problem.
> I have not found any relevant existing bug reports.
> 
> Rembert.DeBlander at econ.kuleuven.ac.be
> 
> Example 1
> *********
> 
>>integrate(dnorm,lower=3D"-INF",upper=3D1,-1,7)
> 
> Error in integrate(dnorm, lower =3D "-INF", upper =3D 1, -1, 7) :
>         invalid parameter values
> 
> 
>>integrate(dnorm,lower=3D"-INF",upper=3D1,subdivisions=3D100,-1,7)
> 
> 0.841331 with absolute error < 0.16=20
> 
> 
>>integrate(dnorm,lower=3D"-INF",upper=3D1,subdivisions=3D100,rel.tol=3D.M=
> 
> achine$double.eps^0.25,abs.tol=3D.Machine$double.eps^0.25,-1,7)
> 0.8413448 with absolute error < 1.5e-05
> 
> 
>>pnorm(1,-1,7)
> 
> [1] 0.6124515
> 
> 
>>pnorm(1,0,1)
> 
> [1] 0.8413447
> 
> Example 2
> *********
> fex <- function(x, v, M)
> {
> (x - t(v) %*% M %*% v)^2
> }
> debug(integrate)
> integrate(fex,lower=3D-3,upper=3D7,subdivisions=3D100,c(1,2,3),matrix(2,3=
> ,3))
> 
> results in
> .
> .
> .
> debug: wk <- .External("call_dqags", ff, rho =3D environment(), =
> as.double(lower),
>     as.double(upper), as.double(abs.tol), as.double(rel.tol),
>     limit =3D limit, PACKAGE =3D "base")
> Browse[1]>
> Error in t(v) : Argument "v" is missing, with no default
> 
> ______________________________________________
> R-devel at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list