Paul Fournel
Paul Fournel

Reputation: 11207

NLS not working with R

I cannot get the nls function to work with r. What am I doing wrong? Here is my code

data = read.table("http://math.univ-lyon1.fr/~gciuperca/lactt.txt", header = FALSE);

plot(data$V1, data$V2)

model <- nls(V2 ~ (a*(V1 + 1)^b)*exp(-c*V1), start = c(a = 0, b = 2, c = 0), data=data)

Here is the error I get (It's in French sorry)

Erreur dans nlsModel(formula, mf, start, wts) : 
   matrice de gradient singulière pour les estimations initiales des paramètres

Upvotes: 0

Views: 1299

Answers (1)

shadow
shadow

Reputation: 22343

Have you tried different starting values?

nls(V2 ~ (a*(V1 + 1)^b)*exp(-c*V1), start = c(a = 1, b = 2, c = .1), data=data)
# Nonlinear regression model
#   model: V2 ~ (a * (V1 + 1)^b) * exp(-c * V1)
#    data: data
#      a      b      c 
# 15.001  0.180  0.003 
#  residual sum-of-squares: 0.001354
# 
# Number of iterations to convergence: 9 
# Achieved convergence tolerance: 1.39e-08

Upvotes: 3

Related Questions