[R] Nonlinear regression

Berwin A Turlach berwin.turlach at gmail.com
Wed Dec 20 05:29:10 CET 2017


G'day Timothy,

On Tue, 19 Dec 2017 18:28:00 -0600
Timothy Axberg <axbergtimothy at gmail.com> wrote:

> Should I repost the question with reply-all?

Nope, we got all from Jeff's post. :)

> On Tue, Dec 19, 2017 at 6:13 PM, Jeff Newmiller
> <jdnewmil at dcn.davis.ca.us> wrote:
> 
> > You also need to reply-all so the mailing list stays in the loop.
> > --
> > Sent from my phone. Please excuse my brevity.
> >
> > On December 19, 2017 4:00:29 PM PST, Timothy Axberg <  
> > axbergtimothy at gmail.com> wrote:
> > >Sorry about that. Here is the code typed directly on the email.
> > >
> > >qe = (Qmax * Kl * ce) / (1 + Kl * ce)
[...]
> > >##The linearized data
> > >celin <- 1/ce
> > >qelin <- 1/qe

Plotting qelin against celin, I can see why you call this the
linearized data.  But fitting a linear model to these data obviously
does not give you good starting values for nls().

Given your model equation, I would linearize the model to:
 
   qe = Qmax*KL * ce + KL * ce*qe

and fit a non-intercept linear model to predict qe by ce and
ce*qe.  From this model I would then determine starting values for
nls().  It seems to work with your data set:

R> ce <- c(15.17, 42.15, 69.12, 237.7, 419.77)
R> qe <- c(17.65, 30.07, 65.36, 81.7, 90.2)
R> fit2 <- lm(qe ~ ce + I(ce*qe) - 1)
R> summary(fit2)
R> Kl <- - coef(fit2)[2]
R> Qmax <- coef(fit2)[1]/Kl
R> plot(ce, qe)
R> c <- seq(min(ce), max(ce))
R> q <- (Qmax*Kl*c)/(1+(Kl*c))
R> lines(c, q)
R> fit2 <- nls(qe ~ ((Qmax*Kl*ce)/(1+(Kl*ce))), start = list(Qmax = Qmax,Kl =Kl)) 
R> summary(fit2)

Formula: qe ~ ((Qmax * Kl * ce)/(1 + (Kl * ce)))

Parameters:
      Estimate Std. Error t value Pr(>|t|)   
Qmax 106.42602   12.82808   8.296  0.00367 **
Kl     0.01456    0.00543   2.681  0.07496 . 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 9.249 on 3 degrees of freedom

Number of iterations to convergence: 2 
Achieved convergence tolerance: 6.355e-06

HTH.

Cheers,

	Berwin



More information about the R-help mailing list