0

I want to fit an asymptotic model as follow:

y(x) = Asym + (R0 - Asym) * exp(-exp(lrc) * x)

The model could be fitted in R using nls() function:

y <- c(22.180,21.941,21.786,21.724,20.964,19.128,18.371,17.508,16.931)
x <- c(1,3,5,9,18,36,72,144,288)

nls(y ~ SSasymp(x, Asym, R0, lrc))

However, if I know the value of R0 (for example R0 = 25), then how can I fit this model with the self-starting function SSasymp?

Lin
  • 195
  • 1
  • 12

1 Answers1

1

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)]))
Maurits Evers
  • 49,617
  • 4
  • 47
  • 68
  • Thank you @Maurits! This is a solution. But it may be not very efficient when I have many groups of data to be fitted. – Lin Sep 27 '18 at 01:37
  • @Lin *"But it may be not very efficient when I have many groups of data to be fitted."* On the contrary. This can be automated very nicely: Start with an unconstrained fit, then use relevant coefficient estimates as starting values for a constrained fit. Wrap it in a function. Done. – Maurits Evers Sep 27 '18 at 03:03