Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • nl estimate for a logistic function

    Dear All, I found this question here (http://bbs.pinggu.org/forum.php?mod=...=1#pid50990852). The end to fit a logistic function such as
    Code:
    y=k/(1+a*exp(bx)), k>0  a>0  b<0
    The dataset and a sample code (not really working) are
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(x y)
       167029 28706.89
       161561 33845.98
       185859 36910.36
       218371  43732.3
       258063 52074.97
    291307.38 57348.29
    268989.72 62685.77
    286250.03 66478.91
       266881 69358.89
    281825.53 75624.97
    end
    
    nl (y={k}/(1+{a}*exp({b}*x))), initial(k 1 a 1 b -0.1)
    The result is
    Code:
    . nl (y={k}/(1+{a}*exp({b}*x))), initial(k 1 a 1 b -0.1)
    (obs = 10)
    
    Iteration 0:  residual SS =  2.38e+09
    Iteration 1:  residual SS =  2.38e+09
    
    
          Source |      SS            df       MS
    -------------+----------------------------------    Number of obs =         10
           Model |          0          0           .    R-squared     =     0.0000
        Residual |  2.376e+09          9   263946028    Adj R-squared =     0.0000
    -------------+----------------------------------    Root MSE      =   16246.42
           Total |  2.376e+09          9   263946028    Res. dev.     =   221.2377
    
    ------------------------------------------------------------------------------
               y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
              /k |   52676.73   5137.568    10.25   0.000     41054.75    64298.72
              /a |          1          .        .       .            .           .
              /b |        -.1          .        .       .            .           .
    ------------------------------------------------------------------------------
      Parameter b taken as constant term in model & ANOVA table
    Any suggestions to obtain a solution are highly appreciated.
    Last edited by River Huang; 12 May 2018, 03:05.
    Ho-Chuan (River) Huang
    Stata 19.0, MP(4)

  • #2
    If you plot the data it doesn't look a very convincing logistic. At best you have something from the steep midsection but there is little information about asymptotes and it's not clear that y -> 0 as x decreases.

    In general nl often requires really good guesses and is not smart about recovering from lousy guesses. When data are implausible for the function fitted the problem can't be easier than that.

    Comment


    • #3
      Hi, Nick, Got it and thanks.
      Ho-Chuan (River) Huang
      Stata 19.0, MP(4)

      Comment

      Working...
      X