# Nonlinear regression

6 messages
Open this post in threaded view
|

## Nonlinear regression

 Hello, I am working on a small data set and trying to find values of Qmax and Kl for the equation qe = (Qmax * Kl * ce) / (1 + 𝐾l* ce) I found my Qmax and Kl through the linear model butam now trying to find them through the "nls" function however an error comes up that I am unfamiliar with. I have the file loaded for reference. Any help is appreciated. Thank you. -Timothy ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Nonlinear regression

Open this post in threaded view
|

## Re: Nonlinear regression

 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 <[hidden email]> 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 ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Nonlinear regression

 Should I repost the question with reply-all? On Tue, Dec 19, 2017 at 6:13 PM, Jeff Newmiller <[hidden email]> 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 < > [hidden email]> 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 >         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.