OnofriAndreaPG / aomisc

Utilities for stat courses
21 stars 7 forks source link

DRC.power #2

Closed cbird808 closed 4 years ago

cbird808 commented 4 years ago

when fitting the following data:

x | y 100 | 1.61E-05 500 | 2.88E-06 1000 | 1.38E-06 5000 | 2.27E-07 10000 | 1.21E-07

> llModel.coef.e <- drm(data=test, formula = y ~ x, fct=DRC.powerCurve())
> summary(llModel.coef.e)

Model fitted: Power curve (Freundlich equation) (2 parms)

Parameter estimates:

                 Estimate  Std. Error t-value p-value
a:(Intercept)  1.9717e-05  6.0530e-05  0.3257  0.7660
b:(Intercept) -1.9067e-01  4.1728e-01 -0.4569  0.6788

Residual standard error:

 6.114735e-06 (3 degrees of freedom)

The parameters are far from fitting the data.

With nls the result is a much much better fit:

>llModel.coef.e<-nls(y ~ a * I(x^b),data=test,start=list(a=1, b=-1))
> summary(llModel.coef.e)

Formula: y ~ a * I(x^b)

Parameters:
    Estimate Std. Error t value Pr(>|t|)    
a  2.219e-03  2.277e-05   97.45 2.38e-06 ***
b -1.069e+00  2.191e-03 -488.14 1.90e-08 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.231e-08 on 3 degrees of freedom

Number of iterations to convergence: 5 
Achieved convergence tolerance: 9.02e-08
OnofriAndreaPG commented 4 years ago

Hello,

thanks for your comment. I noted that the optimisation algorithm in 'nls()' is often more efficient tan that in 'drm()'. If necessary, I am also providing a self starter for nls(), that is NLS.powerCurve(). The code below appears to work properly

library(aomisc)
library(lattice)
x <- c(100, 500, 1000, 5000, 10000)
y <- c(1.61E-05, 2.88E-06, 1.38E-06, 2.27E-07, 1.21E-07)
llModel.coef.e <- nls(y ~ NLS.powerCurve(x, a, b))
summary(llModel.coef.e)
plotnls(llModel.coef.e)

All the best

Andrea