Hello, It is a very naive question, but here it is. I have this values: x: 0.5 4 6 8 12 y: 0.021 0.021 0.020 0.018 0.012 I need to fit a function to them. How can I do it with R? Thank you so much! Dani -- Daniel Valverde Saub? Grup de Biologia Molecular de Llevats Facultat de Veterin?ria de la Universitat Aut?noma de Barcelona Edifici V, Campus UAB 08193 Cerdanyola del Vall?s- SPAIN Tlf. +34 93 581 1910 Fax: +34 93 581 1573
x<-c(0.5,4,6,8,12) y<-c(0.021,0.021,0.020,0.018,0.012) lm(y~x) 2010/5/14 Dani Valverde <daniel.valverde at uab.cat>:> Hello, > It is a very naive question, but here it is. I have this values: > > x: 0.5 4 6 8 12 > > y: 0.021 0.021 0.020 0.018 0.012 > > I need to fit a function to them. How can I do it with R? > Thank you so much! > > Dani > > -- > Daniel Valverde Saub? > > Grup de Biologia Molecular de Llevats > Facultat de Veterin?ria de la Universitat Aut?noma de Barcelona > Edifici V, Campus UAB > 08193 Cerdanyola del Vall?s- SPAIN > > Tlf. +34 93 581 1910 > Fax: +34 93 581 1573 > > ______________________________________________ > R-help at r-project.org 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. >
It appears that as one proceeds from right to left that it flattens out at 0.021 so lets try this where we have added a bit to 0.021 to avoid log(0) plot(x, log(0.0211 - y)) and plot(1/x, log(0.0211 - y)) Except for the first point the latter plot looks linear so lets try: fm <- nls(y ~ cbind(1, exp(- a / x)), start = c(a = mean(x)), alg = "plinear") fm plot(x, y) lines(x, fitted(fm)) which seems to fit fairly well. On Fri, May 14, 2010 at 6:36 AM, Dani Valverde <daniel.valverde at uab.cat> wrote:> Hello, > It is a very naive question, but here it is. I have this values: > > x: 0.5 4 6 8 12 > > y: 0.021 0.021 0.020 0.018 0.012 > > I need to fit a function to them. How can I do it with R? > Thank you so much! > > Dani > > -- > Daniel Valverde Saub? > > Grup de Biologia Molecular de Llevats > Facultat de Veterin?ria de la Universitat Aut?noma de Barcelona > Edifici V, Campus UAB > 08193 Cerdanyola del Vall?s- SPAIN > > Tlf. +34 93 581 1910 > Fax: +34 93 581 1573 > > ______________________________________________ > R-help at r-project.org 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. >