Re: [R] exponential fitting

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Wed 27 Sep 2006 - 13:05:53 GMT

> # using this test data
> set.seed(1)
> x <- 1:20/20
> y <- exp(2 + 3 * x) + rnorm(20)
>
> # if its ok to fit logs so that its linear
> exp(fitted(lm(log(y) ~ x)))

        1 2 3 4 5 6 7 8   8.55615 9.94692 11.56376 13.44340 15.62857 18.16894 21.12223 24.55557

        9 10 11 12 13 14 15 16  28.54699 33.18720 38.58165 44.85295 52.14363 60.61938 70.47284 81.92793

       17 18 19 20
 95.24501 110.72673 128.72494 149.64869
>
> # or to do it on original scale use linear coefs as starting values
> cc <- coef(lm(log(y) ~ x))
> fitted(nls(y ~ exp(a + b*x), start = list(a = cc[1], b = cc[2])))

 [1]   8.592270   9.984536  11.602401  13.482421  15.667073  18.205720
 [7]  21.155722  24.583734  28.567211  33.196159  38.575168  44.825776
[13]  52.089214  60.529599  70.337640  81.734946  94.979039 110.369167
[19] 128.253066 149.034820

attr(,"label")
[1] "Fitted values"

On 9/27/06, jessica.gervais@tudor.lu <jessica.gervais@tudor.lu> wrote:
> Hi,
>
> I would like to fit some experimental points by a exponential function.
> I ignore the parameters of this exponential and what I would like is to
> ask R to calculate the best fitting curve an the associated parameters (as
> the linear model function (lm) does for linear models).
> Is it possible ?
> Do anyone have an idea about how to do that ?
>
> Thanks by advance
>
> Jessica Gervais
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed Sep 27 23:13:18 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 27 Sep 2006 - 13:30:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.