Skip to content
Prev 154981 / 398506 Next

nls convergence trouble

Hi,

I agree with you that Excel is not the best tool for fittings, that's why I
try to handle R.

But I need to use this specific model ("LgmAltFormula") and not a polynomial
expression with the different parameters even if your method produced
correct fitting.

The parameters "a" and "b" are the Langmuir parameters that describe the
adsorption of a compound onto activated carbon. I need to assess these
parameters.


Regards/Cordialement


Benoit Boulinguiez 


-----Message d'origine-----
De : Petr PIKAL [mailto:petr.pikal at precheza.cz] 
Envoy? : mercredi 3 septembre 2008 17:58
? : Benoit Boulinguiez
Cc : r-help at r-project.org
Objet : Odp: [R] nls convergence trouble

Hi

Excel fit is not exceptionally good. Try

 fff<-function(a,b) (V + b * m * a + C0 * V * b - ((C0 * V * b)^2 + 2 * C0 
*
+     b * V^2 - 2 * C0 * V * m * a * b^2 + V^2 + 2 * V * m * a *
+     b + (b * m * a)^2)^(1/2))/(2 * b * m)

and with attached data frame

plot(Qe,fff(364,0.0126))
abline(0,1)

you clearly see linear relationship in smaller values but quite chaotic 
behaviour in bigger ones (or big deviation of experimental points from 
your model).

So it is up to you if you want any fit (like from Excel) or only a good 
one (like from R). 

Seems to me that simple linear could be quite a good choice although there 
is some nelinearity.

fit<-lm(Qe~Ce+C0+V+m)
summary(fit)

Call:
lm(formula = Qe ~ Ce + C0 + V + m)

Residuals:
    Min      1Q  Median      3Q     Max 
-16.654  -8.653   2.426   9.971  11.912 

Coefficients:
              Estimate Std. Error t value Pr(>|t|) 
(Intercept) -8.148e+02  1.330e+03  -0.613 0.549254 
Ce          -6.894e-02  4.982e-03 -13.839 6.02e-10 ***
C0           3.284e-02  1.676e-03  19.589 4.26e-12 ***
V            2.153e+06  4.607e+05   4.674 0.000300 ***
m           -4.272e+04  1.218e+04  -3.509 0.003167 ** 
---
Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 

Residual standard error: 10.87 on 15 degrees of freedom
Multiple R-squared: 0.9903,     Adjusted R-squared: 0.9877 
F-statistic: 381.3 on 4 and 15 DF,  p-value: 6.91e-15 

plot(predict(fit), Qe)
abline(0,1)

Regards
Petr


r-help-bounces at r-project.org napsal dne 03.09.2008 16:01:36:
with
nls(formula=LgmAltFormula,data=bois.DATA,start=list(a=300,b=0.01),trace=TRUE
list(a =
the
http://www.R-project.org/posting-guide.html