[R] Nonlinear regression

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Wed Dec 20 01:13:47 CET 2017


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 data
>ce <- c(15.17, 42.15, 69.12, 237.7, 419.77)
>qe <- c(17.65, 30.07, 65.36, 81.7, 90.2)
>
>##The linearized data
>celin <- 1/ce
>qelin <- 1/qe
>
>plot(ce, qe, xlim = xlim, ylim = ylim)
>
>##The linear model
>fit1 <- lm(qelin ~ celin)
>intercept1 <- fit1$coefficients[1]
>slope1 <- fit1$coeffecients[2]
>summary(fit1)
>
>Qmax <- 1/intercept1
>Kl <- .735011*Qmax
>
>xlim <- range(ce, celin)
>ylim <- range(qe, qelin)
>
>abline(lm(qelin ~ celin))
>
>c <- seq(min(ce), max(ce))
>q <- (Qmax*Kl*c)/(1+(Kl*c))
>
>lines(c, q)
>
>
>##My attempt at the nonlinear regression
>fit2 <- nls(qe ~ ((Qmax*Kl*ce)/(1+(Kl*ce))), start = list(Qmax = Qmax,
>Kl =
>Kl))
>results <- fit2$m$getpars()
>Qmax2 <- fit2$m$getpars()[1]
>Kl2 <- fit2$m$getpars()[2]
>summary(fit2)
>
>-Timothy



More information about the R-help mailing list