Simone Gabbriellini
2007-Dec-05 17:54 UTC
[R] how to interpolate a plot with a logistic curve
hello, I have this simple question. This is my dataset size 1 57 2 97 3 105 4 123 5 136 6 153 7 173 8 180 9 193 10 202 11 213 12 219 13 224 14 224 15 248 16 367 17 496 18 568 19 618 20 670 21 719 22 774 23 810 24 814 25 823 I plot it with: plot(generalstats[,1], type="b", xlab="Mesi", ylab="Numero di vertici", main=""); and try to interpolate with a linear regression with abline(lm(generalstats[, 1 ]~ c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)), lty=3, col="red"); how to interpolate the data with a logistic curve? I cannot find the - I suppose easy - solution.. thank you, Simone
On Wednesday 05 December 2007, Simone Gabbriellini wrote:> hello, > > I have this simple question. This is my dataset > > size > 1 57 > 2 97 > 3 105 > 4 123 > 5 136 > 6 153 > 7 173 > 8 180 > 9 193 > 10 202 > 11 213 > 12 219 > 13 224 > 14 224 > 15 248 > 16 367 > 17 496 > 18 568 > 19 618 > 20 670 > 21 719 > 22 774 > 23 810 > 24 814 > 25 823 > > I plot it with: > > plot(generalstats[,1], type="b", xlab="Mesi", ylab="Numero di > vertici", main=""); > > and try to interpolate with a linear regression with > > abline(lm(generalstats[, > 1 > ]~ > c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)), > lty=3, col="red"); > > how to interpolate the data with a logistic curve? I cannot find the - > I suppose easy - solution.. > > thank you, > Simone >try: glm(formula, data, family=binomial()) require(Design) lrm() Cheers, -- Dylan Beaudette Soil Resource Laboratory http://casoilresource.lawr.ucdavis.edu/ University of California at Davis 530.754.7341
Dear Simone, you can use the package 'drc' to fit a logistic model, that is a non-linear regression model based on the equation c+(d-c)/(1+exp(b(x-e))), to your data (below named 'simone'): ## Fitting a 4-parameter logistic model (also called Boltzmann model) simone.m1 <- drm(size~x, data=simone, fct=B.4()) ## Plotting the data together with the fitted curve plot(simone.m1, log="") The fit is not great due to the bend. Christian