[R] Generating a best fit line for non linear data

2011-04-28 Thread BornSurvivor
I have the following data set, and I have to find the line of best fit using this equation, y = a*(1 - exp(-b*x)). samples = seq(1,20,by=1) species = c(5,8,9,9,11,11,12,15,17,19,20,20,21,23,23,25,25,27,27,27) plot(samples,species, main = Accumulation Curve for Tree Species Richness, xlab =

Re: [R] Generating a best fit line for non linear data

2011-04-28 Thread Jorge Ivan Velez
Hi, Try d - data.frame(samples, species) fit = nls(species ~ a *(1 - exp(-b*samples)), start = list(a = 27, b = .15), data = d) summary(fit) Formula: species ~ a * (1 - exp(-b * samples)) Parameters: Estimate Std. Error t value Pr(|t|) a 35.824723.02073 11.860 6.10e-10 *** b 0.07168

Re: [R] Generating a best fit line for non linear data

2011-04-28 Thread Andrew Robinson
I think that you probably need to provide the x values to nls. Try, for example, fit - nls(species ~ a *(1 - exp(-b*samples)),start = list(a = 27, b = .15)) I hope that this helps, Andrew On Thu, Apr 28, 2011 at 01:56:43PM -0700, BornSurvivor wrote: I have the following data set, and I have