[R] Catching NaNs from pweibull()
Nakamura
rbt501 at york.ac.uk
Fri Feb 8 16:08:01 CET 2008
Hello,
I am working with the nls() function and inserting a formula into it that
uses 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)
Regards,
Rob
--
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.
More information about the R-help
mailing list