$ontext Non-Linear Least Squares Regression example Erwin Kalvelagen, may 2008 Reference: http://www.statsci.org/data/general/regrowth.html Pasture Regrowth after Grazing -------------------------------------------------------------------------------- Description The yield of pasture regrowth was measured together with the number of days since last grazing. The measurements were done on different experimental units so it is reasonable to assume the errors independent. -------------------------------------------------------------------------------- Variable Description -------------------------------------------------------------------------------- Days Days since last grazing Yield Yield of pasture -------------------------------------------------------------------------------- Source Ratkowsky, D. A. (1983). Nonlinear Regression Modelling. Marcel Dekker, New York. Huet, S., Bouvier, A., Gruet, M.-A., and Jolivet, E. (1996). Statistical Tools for Nonlinear Regression. A Practical Guide with S-PLUS Examples. Springer, New York. Example 1.1.1. Analysis The data are well fitted by a Weibull growth curve: Yield = a - b exp[ -exp{ c + d log(Days) }]. $offtext set i /i1*i9/; table data(i,*) Days Yield i1 9 8.93 i2 14 10.8 i3 21 18.59 i4 28 22.33 i5 42 39.35 i6 57 56.11 i7 63 61.73 i8 70 64.62 i9 79 67.08 ; parameters Days(i) 'Days since last grazing' Yield(i) 'Yield of pasture' ; Days(i) = data(i,'Days'); Yield(i) = data(i,'Yield'); variables a 'parameter to be estimated' b 'parameter to be estimated' c 'parameter to be estimated' d 'parameter to be estimated' sse 'sum of squared errors' ; equation fit(i) 'equation to fit' sumsq 'dummy objective' ; sumsq.. sse =n= 0; fit(i).. Yield(i) =e= a - b * exp[ -exp{ c + d * log(Days(i)) }]; option nlp=nls; models m /sumsq,fit/; solve m minimizing sse using nlp;