hi,
i try to apply a nls regression but i always have this error message
"Error in numericDeriv(form[[3]], names(ind), env) :
Missing value or an Infinity produced when evaluating the model"
i don't understand why it doesn't work
this is the programm that i run:
f <- function (x,p) {
u <- p[1]
v <- p[2]
w <- p[3]
(I((x*u)^v))+w
}
x<-c(1:10)
y<-c(5,6,6.5,8,7,4,3,5,9,15)
r <- nls( y ~ f(x,c(a,b,d)), start=c(a=3, b=2.5, d=3) )
so, if you see a mistake can you contact me:
Anne KERVAHU
annekervahu at yahoo.fr
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