[S] uniroot(f,...) when f is an integration

Lin, Shang (slin@nki.rfmh.org)
Fri, 29 May 1998 17:53:06 -0400


Hi, S+ users,

In the following, I attemp to find the root of "my.func,"
defined as the difference between "d" and the integration of
a function "weibx" involving an unknown parameter "c".
The purpose is to determine the value of c so that the value of
the integration is equal to the given value d. My attempt failed
with an error message (please see below). I would like to know
if this can be done in Splus. If you have any experiences with
such problem, I would greatly appreciate hearing from you.

Shang P. Lin
Nathan Kline Institute
Orangeburg, NY
------------------------------------------------------------------
mx<-300; my<-50; a0<-30
b<-1.5;a<-gamma(1+1/b)/mx;
d<-my/(gamma(1+1/b)*a^b*b*a0)
my.fucn <- function(c)
{
as.numeric(c)
weibx<-function(x) {x^(b-1)*exp(-(a*x)^b+c*x)}
d-integrate(weibx,0,Inf)[1]
}
uniroot(my.func,c(1,100))[1]

Error in c * x: Non-numeric first operand
Dumped

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news