Re: [R] nls and discontinuous functions

2007-11-30 Thread Peter Dalgaard
Luis Orlindo Tedeschi wrote: > Folks; I have looked for this subject extensively using all the resources I > have available and could not find a solution; therefore I am sending you this > email seeking for help. I need to solve a discontinuous nonlinear function, > but R 2.6 keeps giving me an

Re: [R] nls and discontinuous functions

2007-11-30 Thread Gabor Grothendieck
Vectorize f using ifelse in place of if: > f <- function (t,k,l,u) { + r0 <- 346.1 + x<- t-l + ifelse(x < 0, r0, (r0-u)*exp(-k*x)+u) + } > > prof1 = data.frame( + t = c(0, 3, 6, 12, 18, 24, 36, 48, 72, 96), + y1 = c(346.12, 343.13, 327.44, 280.95, 242.76, 228.67, +193.48, 174.29, 164.81, 1

[R] nls and discontinuous functions

2007-11-30 Thread Luis Orlindo Tedeschi
Folks; I have looked for this subject extensively using all the resources I have available and could not find a solution; therefore I am sending you this email seeking for help. I need to solve a discontinuous nonlinear function, but R 2.6 keeps giving me an error. Below is a simple example: f