I have a similar problem, I'd like to calculate the non-linear regression in R, but I get an error.
This is my code:
f <- function(x1,x2,x3,a,b1,b2,b3) {a * (x1^b1) * (x2^b2) * (x3^b3) }
# generate some data
x1 <- c(9,9,12,12,12,16,9,16)
x2 <- c(0.8,1,0.8,1,1.2,1.2,1.2,1)
x3 <- c(0.14,0.12,0.16,0.14,0.12,0.16,0.16,0.14)
y <- c(304,284,435,489,512,854,517,669)
dat <- data.frame(x1,x2,x3, y)
# fit a nonlinear model
fm <- nls(y ~ f(x1,x2,x3,a,b1,b2,b3), data = dat, start = c(a=0, b1=0,b2=0,b3=0))
# get estimates of a, b
co <- coef(fm)
And I got this error:
Error in nlsModel(formula, mf, start, wts) : singular gradient matrix at initial parameter estimates
What should I do?
Thank you!