0

I' ve like to understand the differences in ^ and exp() notation in nls models. In my example:

library(nls2)
#Data set
x <- c(1 ,10,  20,  30,  40,  50,  60,  70,  80,  90, 100) 
y <- c(0.033823,  0.014779,  0.004698,  0.001584, -0.002017, -0.003436, 
-0.000006, -0.004626, -0.004626, -0.004626, -0.004626) 

NLS with exp()

fo2<- y ~ a4^(-x/a5)
fm2 <- nls2(fo2, alg = "plinear-random",
     start = data.frame(a4 = c(-10, 10), a5 = c(-10, 10)),
     control = nls.control(maxiter = 1000))

NLS with ^

fo3<- y ~ a4*exp(-x/a5)
fm3 <- nls2(fo3, alg = "plinear-random",
     start = data.frame(a4 = c(-10, 10), a5 = c(-10, 10)),
     control = nls.control(maxiter = 1000))

Results

summary(fm2)

Formula: y ~ a4^(-x/a5)

Parameters:
      Estimate Std. Error t value Pr(>|t|)    
a4   1.346e+00  3.060e+06     0.0        1    
a5   2.890e+00  5.103e-03   566.4   <2e-16 ***
.lin 3.790e-02  2.211e+07     0.0        1    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.003675 on 8 degrees of freedom

Number of iterations to convergence: 1000 
Achieved convergence tolerance: NA

summary(fm3)

Formula: y ~ a4 * exp(-x/a5)

Parameters:
      Estimate Std. Error t value Pr(>|t|)   
a4   5.456e+00  1.474e+09   0.000  1.00000   
a5   9.764e+00  2.294e+00   4.256  0.00278 **
.lin 6.940e-03  1.875e+06   0.000  1.00000   
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.003675 on 8 degrees of freedom

Number of iterations to convergence: 1000 
Achieved convergence tolerance: NA

My outputs were too ambiguous. Any member can simple explain about to differents approaches? Thanks,

Leprechault
  • 1,531
  • 12
  • 28
  • 4
    Are you under the assumption that `a*exp(b) == a^b`? Mathematically those two things are quite different. – Dason Feb 26 '19 at 14:47
  • It is evaluating the model at 1000 random points and showing the best of these and is using different random numbers each time. Even if you run the very same command twice it will possibly give different answers given the random numbers. Use `set.seed` if you want reproducible random numbers or use an `algorithm=` value that does not use random numbers. – G. Grothendieck Feb 26 '19 at 15:21

0 Answers0