Fitting with Logistic Curves by yurtgc548

VIEWS: 5 PAGES: 15

									Intrisincally Nonlinear Models

FITTING WITH LOGISTIC CURVES
NONLINEARITY

 Some models can not be “linearized”
 An important (and very useful) example is the
  logistic equation which has the following form:




   Parameters: K, C, r
   THE LOGISTIC CURVE

      The curve starts like exponential and then
       slows and eventually stops growing


Like an exponential here


                                        K: capacity
HOW TO FIT DATA?

 Directly estimate the parameters if we know the
  physical meanings of these parameter
 In logistic model, r is like the growth rate (at the
  beginning at least)
 K is the carrying capacity

 Use plot (if the data is clean)
HOW TO FIT THE DATA, II
   Directly use the least squares creterion by computing
    an error function and applying a minimization
    algorithm
   Sounds straightforward
   Finding the absolute minimum is hard
   It involves solving system of nonlinear equations
   Numerical method is preferred but too many local
    minimum – needs a goos atrting point
USE VISUAL AID

   Recall



   Write C=exp[-rt0]



 t0   is the reflection point
LEAST SQUARES METHOD
   Error function:



   Set the partials to zero:



                                System of nonlinear equations
Some Linear Algebra

   Let




   Then the error function can be writte as

   Distribute the terms we get
   Error function rewritten:

   So,



   Thus,
   Put this back to the error function:



   This is the function we need to minimize
   Matlab: setting up the range
    >r=linspace(0.01,0.5,40);
    >t0=linspace(10,75,40);
    >[r,t0]=meshgrid(r,t0);
   >[m,n]=size(r);
    >e=zeros(m,n);
   Plot the surface of the error function in the specified range
    for i=1:m
       for j=1:n
       e(i,j)=myerror([r(i,j);t0(i,j)],T,Y);
       end
    end
    mesh(r,t0,e);
   Where T,Y are data vectors, myerror is the logistic function
   The m-file for myerror
     function e=myerror(x,t,y)
    %This is my error function
    %Inputs: y=vector of observation (as a COLUMN vector-be careful!)
    %     t=vector of time steps
    %     x=[x(1),x(2)]=[r,t0] the two unknown parameters

    %my private comments

    r=x(1);
    t0=x(2);
    h=1./(1+exp(-r*(t-t0)));
    e=y'*y-(h'*y)^2/(h'*h);
   To finish the parameter estimation, we need
     Guess  the minimum point of g(r,t0)
     Compute the minimum point (using fminsearch)
     Once we find r and t0, compute K
     Evaluate the model with the estimated parameters
     Plot the model with the data
     Perform a goodness of fit test

   Interpret
   Use the method (and Matlab) discussed here
    and use the population data of Orlando to
    estimate the parameters of the logistic
    equation.
   Orlando
   Census Pop.
   1890          2,856
   1900          2,481
   1910          3,894
   1920          9,282
   1930          27,330
   1940          36,736
   1950          52,367
   1960          88,135
   1970          99,006
   1980          128,251
   1990          164,693
   2000          185,951

								
To top