You should ask your instructor or teaching assistant for help. R-help
is not for doing homework.
Duncan Murdoch
On 06/05/2011 9:00 AM, CarJabo wrote:> 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.