[R] Uniroot - error

From: CarJabo <carly_tse_at_hellokitty.com>
Date: Fri, 06 May 2011 06:00:11 -0700 (PDT)


Hi,

I have tried to use uniroot to solve a value (value a in my function) that gives f=0, and I repeat this process for 10000 times(stimulations). However error occures from the 4625th stimulation - Error in uniroot(f, c(0, 2), maxiter = 1000, tol = 0.001) :
  f() values at end points not of opposite sign

I have also tried interval of (lower=min(U), upper=max(U)) and it won't work as well.

Can anyone help me as I have struggled for few days already and I have to finish it soon. Thanks.

numsim=10000

set.seed(12345)

P = c()
for (m in 1:numsim) {

Y = rnorm(140,0.0125,(0.005^(1/2)))
U = exp(X1)

.............
.............(sorry i have to skip the code in between otherwise
..............my assignment will get penalty for plagarism according to
those screening sotware)
............
S = sum(.....)

f = function(a){sum(F*(answer^(910:1))) - S}

answer = uniroot(f, c(0,2), maxiter=1000,tol=0.001)$root P[m] = answer^26 - 1
}

all the vectors are correct; it works without stimulation; it also works for loop(1:4624) but after 4625 there's error.

--
View this message in context: http://r.789695.n4.nabble.com/Uniroot-error-tp3502628p3502628.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_r-project.org 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 Fri 06 May 2011 - 13:03:59 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 06 May 2011 - 13:50:04 GMT.

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

list of date sections of archive