Skip to content
Prev 64555 / 398498 Next

nls.regression syntax problem

If you add a print(p), you will find that after a few iterations
u is negative which leads to problems with the power. It sometimes help write 
u=exp(p), and compute the log later. From a statistical point of view, I am not 
always happy with that solution, but even Pinheiro/Bates use it in the nlme 
samples. 
 
 f <- function (x,p) {
 print(p)
 u <- exp(p[1])
 v <- p[2]
 w <- p[3]
 (x*u)^v+w    # You don't need the I(( here.
 }


Nonlinear regression model
  model:  y ~ f(x, c(a, b, d)) 
   data:  parent.frame() 
        a         b         d 
-2.125873 12.781581  5.577249 
 residual sum-of-squares:  21.12331 
 
Dieter