___  ____  ____  ____  ____ (R)
 /__    /   ____/   /   ____/
___/   /   /___/   /   /___/   15.1   Copyright 1985-2017 StataCorp LLC
  Statistics/Data Analysis            StataCorp
                                      4905 Lakeway Drive
     Special Edition                  College Station, Texas 77845 USA
                                      800-STATA-PC        http://www.stata.com
                                      979-696-4600        stata@stata.com
                                      979-696-4601 (fax)

Single-user Stata perpetual license:
       Serial number:  15
         Licensed to:  Kreshna Gopal
                       StataCorp LLC

Notes:
      1.  Stata is running in batch mode.
      2.  Unicode is supported; see help unicode_advice.
      3.  Maximum number of variables is set to 5000; see help set_maxvar.


running /home/krg/bin/profile.do ...
Compile number 629

. do ratkow3.do 

. /* NIST/ITL StRD
> Dataset Name:  Ratkowsky3        (Ratkowsky3.dat)
> 
> File Format:   ASCII
>                Starting Values   (lines 41 to 44)
>                Certified Values  (lines 41 to 49)
>                Data              (lines 61 to 75)
> 
> Procedure:     Nonlinear Least Squares Regression
> 
> Description:   This model and data are an example of fitting  
>                sigmoidal growth curves taken from Ratkowsky (1983).  
>                The response variable is the dry weight of onion bulbs 
>                and tops, and the predictor variable is growing time. 
> 
> 
> Reference:     Ratkowsky, D.A. (1983).  
>                Nonlinear Regression Modeling.
>                New York, NY:  Marcel Dekker, pp. 62 and 88.
> 
> 
> 
> 
> 
> Data:          1 Response  (y = onion bulb dry weight)
>                1 Predictor (x = growing time)
>                15 Observations
>                Higher Level of Difficulty
>                Observed Data
> 
> Model:         Exponential Class
>                4 Parameters (b1 to b4)
> 
>                y = b1 / ((1+exp[b2-b3*x])**(1/b4))  +  e
> 
> 
> 
>           Starting Values                  Certified Values
>  
>         Start 1     Start 2           Parameter     Standard Deviation
>   b1 =   100         700           6.9964151270E+02  1.6302297817E+01
>   b2 =    10           5           5.2771253025E+00  2.0828735829E+00
>   b3 =     1           0.75        7.5962938329E-01  1.9566123451E-01
>   b4 =     1           1.3         1.2792483859E+00  6.8761936385E-01
>  
> Residual Sum of Squares:                    8.7864049080E+03
> Residual Standard Deviation:                2.8262414662E+01
> Degrees of Freedom:                                9  *** should be 11 ***
> Number of Observations:                           15 
> */ 
.  
. clear

. program drop _all

. 
. scalar N         = 15 

. scalar df_r      = 11

. scalar df_m      = 4

. 
. scalar rss       = 8.7864049080E+03

. scalar rmse      = 2.8262414662E+01

. 
. scalar b1        = 6.9964151270E+02  

. scalar seb1      = 1.6302297817E+01

. scalar b2        = 5.2771253025E+00  

. scalar seb2      = 2.0828735829E+00

. scalar b3        = 7.5962938329E-01  

. scalar seb3      = 1.9566123451E-01

. scalar b4        = 1.2792483859E+00  

. scalar seb4      = 6.8761936385E-01

.  
. qui input double(y x)

. 
. /* The following starting values led to convergence problems:
> 
> nl ( y = {b1} / ( ( 1 + exp( {b2} - {b3}*x ) )^(1/{b4})) ), ///
>         init(b1 100 b2 10 b3 1 b4 1)
> 
> */
. 
. nl ( y = {b1} / ( ( 1 + exp( {b2} - {b3}*x ) )^(1/{b4})) ), ///
>         init(b1 700 b2 5 b3 0.75 b4 1.3) eps(1e-10)
(obs = 15)

Iteration 0:  residual SS =  8838.785
Iteration 1:  residual SS =  8788.805
Iteration 2:  residual SS =  8786.424
Iteration 3:  residual SS =  8786.406
Iteration 4:  residual SS =  8786.405
Iteration 5:  residual SS =  8786.405
Iteration 6:  residual SS =  8786.405
Iteration 7:  residual SS =  8786.405
Iteration 8:  residual SS =  8786.405
Iteration 9:  residual SS =  8786.405
Iteration 10:  residual SS =  8786.405


      Source |      SS            df       MS
-------------+----------------------------------    Number of obs =         15
       Model |  3755359.3          4   938839.82    R-squared     =     0.9977
    Residual |  8786.4049         11  798.764083    Adj R-squared =     0.9968
-------------+----------------------------------    Root MSE      =   28.26241
       Total |  3764145.7         15  250943.046    Res. dev.     =   138.1618

------------------------------------------------------------------------------
           y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         /b1 |   699.6415    16.3023    42.92   0.000     663.7604    735.5226
         /b2 |   5.277129   2.082889     2.53   0.028     .6927216    9.861536
         /b3 |   .7596297   .1956631     3.88   0.003     .3289782    1.190281
         /b4 |    1.27925   .6876225     1.86   0.090    -.2341974    2.792697
------------------------------------------------------------------------------

. 
. assert N    == e(N)

. assert df_r == e(df_r)

. assert df_m == e(df_m)

. 
. lrecomp [b1]_b[_cons] b1 [b2]_b[_cons] b2 [b3]_b[_cons] b3 [b4]_b[_cons] b4 (
> ) /*
> */ [b1]_se[_cons] seb1 [b2]_se[_cons] seb2 [b3]_se[_cons] seb3 [b4]_se[_cons]
>  seb4 () /*
> */ e(rmse) rmse e(rss) rss

[b1]_b[_cons]        7.8
[b2]_b[_cons]        6.2
[b3]_b[_cons]        6.4
[b4]_b[_cons]        6.0
-------------------------
min                  6.0

[b1]_se[_cons]       6.4
[b2]_se[_cons]       5.1
[b3]_se[_cons]       5.0
[b4]_se[_cons]       5.3
-------------------------
min                  5.0

e(rmse)             11.0
e(rss)              11.4

. 
. 
end of do-file