A possibility is to specify the model function explicitly, and then fit the model using sensible starting values:
f <- function(x, Asym, lrc, R0 = 25)
Asym + (R0 - Asym) * exp(-exp(lrc) * x)
nls(
y ~ f(x, Asym, lrc),
data = data.frame(x, y),
start = list(Asym = 15, lrc = -3))
#Nonlinear regression model
# model: y ~ f(x, Asym, lrc)
# data: data.frame(x, y)
# Asym lrc
#17.965 -2.526
# residual sum-of-squares: 12.32
#
#Number of iterations to convergence: 16
#Achieved convergence tolerance: 5.565e-06
One way to choose sensible starting values is to use estimates for Asym
and lrc
from the unconstrained fit nls(y ~ SSasymp(x, Asym, R0, lrc))
.
So for example:
# Unconstrained fit
fit <- nls(y ~ SSasymp(x, Asym, R0, lrc))
coef(fit)
#Asym R0 lrc
#17.057226 22.361817 -3.877708
# Constrained fit with R0 = 25 and starting values from fit
nls(
y ~ f(x, Asym, lrc),
data = data.frame(x, y),
start = as.list(coef(fit)[c(1, 3)]))