[R] uniroot function question

kchkchkch karihay at gmail.com
Wed Dec 14 19:58:24 CET 2011


Heh.  Yes, 
Berend Hasselman wrote
> 
> Shouldn't the line with uniroot be (why try as function?)
> 
> sol = uniroot(fcn, lower = p1, upper = 1)
> 
> Before the line with  for(i in 1:n) insert the following
> 
> fcn = function(p2) p1*f(p1) + (.20/5.66)*(exp(5.66*(p2 - p0)) -
> exp(5.66*(p1 - p0))) + (1 - p2)*f(p2) - as.numeric(f.integral$value) 
> curve(fcn, from=0, to=1)
> 
> And it should be obvious what the problem is.
> 
> Berend
> 
 I had been trying various solutions (so I'd been "trying" stating the
functions a bunch of different ways)--hence the "try" in there.

but then I fixed it as you suggested--name the function correctly (insert
eyeroll at myself here), and move the fcn = line to outside the for
loop--and I still get the same error.

--
View this message in context: http://r.789695.n4.nabble.com/uniroot-function-question-tp4195737p4196520.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list