$ontext Non-Linear Least Squares Regression example Erwin Kalvelagen, may 2008 Reference: http://www.statsci.org/data/general/chlorine.html Available Chlorine -------------------------------------------------------------------------------- Description The data are from a Proctor and Gamble study reported by Smith and Dubey (1964) on the amount of available chlorine in a product as a function of time since manufacture. Theoretical considerations lead to the model Chlorine = a + (0.49 - a) exp{ -b (Weeks - 8) } -------------------------------------------------------------------------------- Variable Description -------------------------------------------------------------------------------- Weeks Time in weeks since manufacture Chlorine Available chlorine -------------------------------------------------------------------------------- Source Jennrich, R. I., and Bright, P. B. (1976). Fitting systems of linear differential equations using computer generated exact derivatives. Technometrics 18, 385-392. Jennrich, R. I. (1995). An Introduction to Computational Statistics. Prentice-Hall, Englewood Cliffs, New Jersey. Section 8.2.1. $offtext set i /i1*i42/; table data(i,*) Weeks Chlorine i1 8 0.49 i2 8 0.49 i3 10 0.48 i4 10 0.47 i5 10 0.48 i6 10 0.47 i7 12 0.46 i8 12 0.46 i9 12 0.45 i10 12 0.43 i11 14 0.45 i12 14 0.43 i13 14 0.43 i14 16 0.44 i15 16 0.43 i16 16 0.43 i17 18 0.46 i18 18 0.45 i19 20 0.42 i20 20 0.42 i21 20 0.43 i22 22 0.41 i23 22 0.41 i24 22 0.40 i25 24 0.42 i26 24 0.40 i27 24 0.40 i28 26 0.41 i29 26 0.40 i30 26 0.41 i31 28 0.41 i32 28 0.40 i33 30 0.40 i34 30 0.40 i35 30 0.38 i36 32 0.41 i37 32 0.40 i38 34 0.40 i39 36 0.41 i40 36 0.38 i41 40 0.39 i42 42 0.39 ; parameters Weeks(i) 'Time in weeks since manufacture' Chlorine(i) 'Available chlorine' ; Weeks(i) = data(i,'Weeks'); Chlorine(i) = data(i,'Chlorine'); variables a 'parameter to be estimated' b 'parameter to be estimated' sse 'sum of squared errors' ; equation fit(i) 'equation to fit' sumsq 'dummy objective' ; sumsq.. sse =n= 0; fit(i).. Chlorine(i) =e= a + (0.49 - a) * exp{ - b * (Weeks(i) - 8) }; option nlp=nls; models m /sumsq,fit/; solve m minimizing sse using nlp;