[R] Catching NaNs from pweibull()

From: Nakamura <rbt501_at_york.ac.uk>
Date: Fri, 8 Feb 2008 07:07:23 -0800 (PST)

Hello,

I am working with the nls() function and inserting a formula into it that use the pweibull function. However the pweibull function is annoyingly producing NaNs, which nls() refuses to handle. I have put a sample of the code below. Is there a way to prevent these NaNs from interfering, for example a method to catch them? I get the following error when I try to run the code:

res.nls <- nls(cumsumcaught ~
Pcatch*Prepens.released*(1-pweibull(distances,k,l)), + start = list(k=1,l=12), trace=T, control = my.control) Error in numericDeriv(form[[3]], names(ind), env) :

        Missing value or an infinity produced when evaluating the model In addition: Warning messages:
1: NaNs produced in: pweibull(q, shape, scale, lower.tail, log.p) 2: NaNs produced in: pweibull(q, shape, scale, lower.tail, log.p)

HERE IS THE CODE:
# Observed data

Prepens.caughtintraps = c(94,45,71,64,71,31,16,19,27,16,113)

# Numbers of seeds released

Prepens.released = 1250

distances = c(2,3,4,5,7.5,10,12.5,15,17.5,20,25) totalseedscaught = sum(Prepens.caughtintraps) Pcatch = totalseedscaught/Prepens.released

i=11
cumsumcaught = numeric(11)
while (i>0){

	cumsumcaught[i] <- sum(Prepens.caughtintraps[i:11])
	i=i-1

}

res.nls <- nls(cumsumcaught ~
Pcatch*Prepens.released*(1-pweibull(distances,k,l)), start = list(k=1,l=12), trace=T)

-- 
View this message in context: http://www.nabble.com/Catching-NaNs-from-pweibull%28%29-tp15356718p15356718.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 08 Feb 2008 - 15:20:10 GMT

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 08 Feb 2008 - 18:30:12 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