[Rd] documentation error for deriv; MASS scripts ch8; (PR#676)
kjetilh@umsanet.edu.bo
kjetilh@umsanet.edu.bo
Mon, 2 Oct 2000 17:27:37 +0200 (MET DST)
Hola!
There is a bug in the documentation file for deriv, which says that
the third argument is unimplemented. It seems only to be implemented
differently than in s-plus. I show whith the MASS R-script
ch8 file as example:
> expn1 <- deriv(y ~ b0 + b1 * 2^(-x/th), c("b0", "b1", "th"),
+ function(b0, b1, th, x) {})
> expn1
function(b0, b1, th, x) {}
which cannnot be used whith nls! But changing to:
> expn1 <- deriv(y ~ b0 + b1 * 2^(-x/th), c("b0", "b1", "th"),
+ c("b0", "b1", "th", "x") )
> expn1
function (b0, b1, th, x)
{
.expr3 <- 2^(-x/th)
.value <- b0 + b1 * .expr3
.grad <- array(0, c(length(.value), 3), list(NULL, c("b0",
"b1", "th")))
.grad[, "b0"] <- 1
.grad[, "b1"] <- .expr3
.grad[, "th"] <- b1 * (.expr3 * (log(2) * (x/th^2)))
attr(.value, "gradient") <- .grad
.value
}
gives the desired result.
Kjetil Halvorsen
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._