[R] uniroot

From: nurza m <m_nurza_at_yahoo.com>
Date: Sun 30 Jul 2006 - 07:52:05 EST


Hello,

I am struggling to find the root of a exponent function.
"uniroot" is complaining about a values at end points not of opposite sign?
 

s<- sapply(1:length(w),function(i)
+ {
+
+ +
+
+

uniroot(saeqn,lower=-5000,upper=0.01036597923,l=list(t=w[i],gp=gp))$root
+ })

Error in uniroot(saeqn, lower = -5000, upper = 0.01036597923, l = list(t = w[i], :

        f() values at end points not of opposite sign >  

and here is my fonction "saeqn".

> saeqn<-function(s,l)
+ {
+
+
+ p<- exp(-l$gp$lambda+s)*l$gp$c
+
+
+

k11<-(l$gp$mu*(l$gp$lambda^2)*l$gp$c-s*l$gp$lambda*l$gp$c*l$gp$mu+l$gp$mu*l$gp$lambda)*p
+
+ k12 <-

-l$gp$mu*l$gp$lambda-s^2+2*s*l$gp$lambda-(l$gp$lambda^2)
+
+ k13 <-k11+k12
+
+

k14<-(l$gp$lambda-s)*(-l$gp$mu*s-s*l$gp$lambda+s^2+l$gp$mu*l$gp$lambda*p)
+
+ k1<- -k13/k14
+
+ k1-l$t
+ }
 

. There is something I must be missing since I never had
luck with "uniroot"!

Thanks,



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun Jul 30 07:58:58 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sun 30 Jul 2006 - 22:17:37 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.