___  ____  ____  ____  ____ (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 mgh17.do 

. /* NIST/ITL StRD
> Dataset Name:  MGH17             (MGH17.dat)
> 
> File Format:   ASCII
>                Starting Values   (lines 41 to 45)
>                Certified Values  (lines 41 to 50)
>                Data              (lines 61 to 93)
> 
> Procedure:     Nonlinear Least Squares Regression
> 
> Description:   This problem was found to be difficult for some very
>                good algorithms.
> 
>                See More, J. J., Garbow, B. S., and Hillstrom, K. E.
>                (1981).  Testing unconstrained optimization software.
>                ACM Transactions on Mathematical Software. 7(1):
>                pp. 17-41.
> 
> Reference:     Osborne, M. R. (1972).  
>                Some aspects of nonlinear least squares 
>                calculations.  In Numerical Methods for Nonlinear 
>                Optimization, Lootsma (Ed).  
>                New York, NY:  Academic Press, pp. 171-189.
>  
> Data:          1 Response  (y)
>                1 Predictor (x)
>                33 Observations
>                Average Level of Difficulty
>                Generated Data
> 
> Model:         Exponential Class
>                5 Parameters (b1 to b5)
> 
>                y = b1 + b2*exp[-x*b4] + b3*exp[-x*b5]  +  e
> 
> 
> 
>           Starting values                  Certified Values
> 
>         Start 1     Start 2           Parameter     Standard Deviation
>   b1 =     50         0.5          3.7541005211E-01  2.0723153551E-03
>   b2 =    150         1.5          1.9358469127E+00  2.2031669222E-01
>   b3 =   -100        -1           -1.4646871366E+00  2.2175707739E-01
>   b4 =      1          0.01        1.2867534640E-02  4.4861358114E-04
>   b5 =      2          0.02        2.2122699662E-02  8.9471996575E-04
> 
> Residual Sum of Squares:                    5.4648946975E-05
> Residual Standard Deviation:                1.3970497866E-03
> Degrees of Freedom:                                28
> Number of Observations:                            33
> */
. 
. clear

. program drop _all

. 
. scalar N         = 33

. scalar df_r      = 28

. scalar df_m      = 5

. 
. scalar rss       = 5.4648946975E-05

. scalar rmse      = 1.3970497866E-03

. 
. scalar b1        = 3.7541005211E-01  

. scalar seb1      = 2.0723153551E-03

. scalar b2        = 1.9358469127E+00  

. scalar seb2      = 2.2031669222E-01

. scalar b3        = -1.4646871366E+00  

. scalar seb3      = 2.2175707739E-01

. scalar b4        = 1.2867534640E-02  

. scalar seb4      = 4.4861358114E-04

. scalar b5        = 2.2122699662E-02  

. scalar seb5      = 8.9471996575E-04

. 
. program define nlbprog
  1.         version 6
  2.         if "`1'"=="?" {
  3.                 global S_1 "b1 b2 b3 b4 b5"
  4. 
. * first set of initial values do not lead to convergence for original nl
.                 global b1 .5
  5.                 global b2 1.5         
  6.                 global b3 -1         
  7.                 global b4 .01      
  8.                 global b5 .02     
  9.                 exit
 10.         }
 11. 
.         replace `1' = $b1 + $b2*exp(-(x*$b4)) + $b3*exp(-(x*$b5))
 12. end

. 
. qui input double(y x)

. 
. nl ( y = {b1} + {b2}*exp(-x*{b4}) + {b3}*exp(-x*{b5}) ), ///    
>         init(b1 .5 b2 1.5 b3 -1 b4 0.01 b5 0.02) eps(1e-10) 
(obs = 33)

Iteration 0:  residual SS =  .0018987
Iteration 1:  residual SS =  .0017038
Iteration 2:  residual SS =  .0010161
Iteration 3:  residual SS =  .0003689
Iteration 4:  residual SS =  .0000547
Iteration 5:  residual SS =  .0000546
Iteration 6:  residual SS =  .0000546
Iteration 7:  residual SS =  .0000546
Iteration 8:  residual SS =  .0000546
Iteration 9:  residual SS =  .0000546
Iteration 10:  residual SS =  .0000546


      Source |      SS            df       MS
-------------+----------------------------------    Number of obs =         33
       Model |   14.28459          5  2.85691807    R-squared     =     1.0000
    Residual |  .00005465         28  1.9517e-06    Adj R-squared =     1.0000
-------------+----------------------------------    Root MSE      =    .001397
       Total |  14.284645         33   .43286803    Res. dev.     =   -345.616

------------------------------------------------------------------------------
           y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         /b1 |   .3754101   .0020723   181.15   0.000     .3711651     .379655
         /b2 |   1.935847   .2203166     8.79   0.000     1.484549    2.387145
         /b4 |   .0128675   .0004486    28.68   0.000     .0119486    .0137865
         /b3 |  -1.464687    .221757    -6.60   0.000    -1.918936   -1.010438
         /b5 |   .0221227   .0008947    24.73   0.000       .02029    .0239554
------------------------------------------------------------------------------

. 
. 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 [b5]_b[_cons] b5 () /*
> */ [b1]_se[_cons] seb1 [b2]_se[_cons] seb2 [b3]_se[_cons] seb3 /*
> */ [b4]_se[_cons] seb4 [b5]_se[_cons] seb5 () /*
> */ e(rmse) rmse e(rss) rss

[b1]_b[_cons]        8.5
[b2]_b[_cons]        7.1
[b3]_b[_cons]        7.0
[b4]_b[_cons]        7.7
[b5]_b[_cons]        7.6
-------------------------
min                  7.0

[b1]_se[_cons]       6.2
[b2]_se[_cons]       6.3
[b3]_se[_cons]       6.3
[b4]_se[_cons]       6.4
[b5]_se[_cons]       6.1
-------------------------
min                  6.1

e(rmse)             11.9
e(rss)              11.5

. 
. 
. 
end of do-file