[R] uniroot

nurza m m_nurza at yahoo.com
Sat Jul 29 23:52:05 CEST 2006


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,



More information about the R-help mailing list