$ontext Nonlinear Least Squares Regression example We solve this an OLS by taking logs. Erwin Kalvelagen, nov 2007 Reference: http://www.itl.nist.gov/div898/strd/nls/nls_main.shtml NLS model: y = b1*x**b2 LS model: log(y) = log(b1) + b2*log(x) $offtext *----------------------------------------------------------------------------- * data *----------------------------------------------------------------------------- set i /i1*i6/; table data(i,*) y x i1 2.138E0 1.309E0 i2 3.421E0 1.471E0 i3 3.597E0 1.490E0 i4 4.340E0 1.565E0 i5 4.882E0 1.611E0 i6 5.660E0 1.680E0 ; * * extract data * parameter x(i),y(i); x(i) = data(i,'x'); y(i) = data(i,'y'); *----------------------------------------------------------------------------- * statistical model *----------------------------------------------------------------------------- variables sse 'sum of squared errors' logb1 'coefficient to estimate' b2 'coefficient to estimate' ; equations fit(i) 'the non-linear model' obj 'objective' ; obj.. sse =n= 0; fit(i).. log(y(i)) =e= logb1 + b2*log(x(i)); option lp=ls; model lfit /obj,fit/; solve lfit minimizing sse using lp; display "Solver results:",sse.l,logb1.l,b2.l; scalar b1; b1 = exp(logb1.l); display "Model results:",b1,b2.l;