[R] Problem with logarithmic nonlinear model using nls() from the `stats' package

Casper Ti. Vector caspervector at gmail.com
Sat Oct 1 11:28:52 CEST 2011


Example:

> f <- function(x) { 1 + 2 * log(1 + 3 * x) + rnorm(1, sd = 0.5) }
> y <- f(x <- c(1 : 10)); y
 [1] 4.503841 5.623073 6.336423 6.861151 7.276430 7.620131 7.913338 8.169004
 [9] 8.395662 8.599227
> nls(x ~ a + b * log(1 + c * x), start = list(a = 1, b = 2, c = 3), trace = TRUE)
37.22954 :  1 2 3 
Error in numericDeriv(form[[3L]], names(ind), env) : 
  Missing value or an infinity produced when evaluating the model
In addition: Warning message:
In log(1 + c * x) : NaNs produced

What's wrong here? Am I handling this problem in the wrong way?
Any suggestions are welcome, thanks :)

-- 
    Using GPG/PGP? Please get my current public key (ID: 0xAEF6A134,
valid from 2010 to 2013) from a key server.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111001/8386afe1/attachment.bin>


More information about the R-help mailing list