How can I fit a logistic regression curve to population data?

29 visualizzazioni (ultimi 30 giorni)
I am currently trying to fit a logistic curve to my population data. The purpose of this is so that I can be able to extrapolate and forecast out 20 years using the fitted logistic curve. I found the glmfit function, but it will not work unless y is a two column matrix. The only y data I have is the population per year. How do I use this function with my type of data? Can I even use this function? If not, how do I fit a logistic curve to my data? Here is an example of my data: x=[2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014] y=[9749,9789,9862,9877,9950,10087,10222,10349,10498,10553,10592,10646,10793,10914,11069]

Risposte (2)

Torsten
Torsten il 5 Ago 2015
Use
x=[1 2 3 4 5 6 7 8 9 10 11 12 13 14]
y=func(x)
with
func(x)=K*9749*exp(r*x)./(K+9749*(exp(r*x)-1))
K and r are the parameters to be fitted.
https://en.wikipedia.org/wiki/Logistic_function
subsection "modeling population growth".
Best wishes
Torsten.
  3 Commenti
Torsten
Torsten il 6 Ago 2015
Please show the relevant part of the code you are using.
Best wishes
Torsten.
Gianna Damiano
Gianna Damiano il 20 Ago 2015
x=[1 2 3 4 5 6 7 8 9 10 11 12 13 14]
func(x)=K*9749*exp(r*x)./(k+9749*(exp(r*x)-1))
y=func(x)

Accedi per commentare.


Torsten
Torsten il 21 Ago 2015
xdata=[1 2 3 4 5 6 7 8 9 10 11 12 13 14];
ydata=[9789 9862 9877 9950 10087 10222 10349 10498 10553 10592 10646 10793 10914 11069];
x0=[1 ; 0.1];
fun=@(x,xdata)x(1)*9749*exp(x(2)*xdata)./(x(1)+9749*(exp(x(2)*xdata)-1))
[x,resnorm] = lsqcurvefit(fun,x0,xdata,ydata);
Best wishes
Torsten.

Categorie

Scopri di più su Biological and Health Sciences in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by