Home > OS >  Understanding the SSasymp function in R and its fitted values
Understanding the SSasymp function in R and its fitted values

Time:03-30

I have run the following non linear model in r:

model <- nls(y ~ SSasymp(x, Asym, R0, lrc), data = df_z)
summary(model)

Here is the output:

Formula: y ~ SSasymp(y, Asym, R0, lrc)

Parameters:
     Estimate Std. Error t value Pr(>|t|)    
Asym  1.11415    0.01093  101.90   <2e-16 ***
R0    2.01447    0.02194   91.83   <2e-16 ***
lrc   4.88583    0.04830  101.15   <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.1958 on 1796 degrees of freedom

Number of iterations to convergence: 11 
Achieved convergence tolerance: 9.266e-06
  (26 observations deleted due to missingness)

According to the enter image description here

where α (or Asym) stands for the asymptotic value of y, β (or RO) represents the value of y when x is 0, and ln(k) is the natural logarithm of the rate constant.

When I fit this model to the data, I get this plot:

enter image description here

Now, when I manually calculate the result for some specific values of x, I get the following:

y = 1.114   (2.01 - 1.114) * exp(-exp(4.886)) * 1 = 1.114
y = 1.114   (2.01 - 1.114) * exp(-exp(4.886)) * 0.1 = 1.114
y = 1.114   (2.01 - 1.114) * exp(-exp(4.886)) * 0.01 = 1.114
y = 1.114   (2.01 - 1.114) * exp(-exp(4.886)) * 0.001 = 1.114

I was expecting to get y values over the red line. But that's not the case.

What am I getting wrong?

CodePudding user response:

You have the value of x outside the final bracket. It should be inside:

xvals <- seq(0, 0.2, 0.001)
yvals <- 1.114   (2.01447 - 1.114) * exp(-exp(4.886) * xvals)
plot(xvals, yvals, type = "l")

enter image description here

  • Related