/* An Example of Nonlinear Least Squares Using the CES Production Function. See the manual SAS/STAT USER'S GUIDE, VOL. 2, GLM-VARCOMP (VERSION 6, FOURTH EDITION), p. 1159 */ title 'CES MODEL: LOGQ = B0 + A*LOG(D*L**R + (1-D)*K**R)'; data ces; input l k logq @@; cards; .228 .802 -1.359 .258 .249 -1.695 .821 .771 .193 .767 .511 -.649 .495 .758 -.165 .487 .425 -.270 .678 .452 -.473 .748 .817 .031 .727 .845 -.563 .695 .958 -.125 .458 .084 -2.218 .981 .021 -3.633 .002 .295 -5.586 .429 .277 -.773 .231 .546 -1.315 .664 .129 -1.678 .631 .017 -3.879 .059 .906 -2.301 .811 .223 -1.377 .758 .145 -2.270 .050 .161 -2.539 .823 .006 -5.150 .483 .836 -.324 .682 .521 -.253 .116 .930 -1.530 .440 .495 -.614 .456 .185 -1.151 .342 .092 -2.089 .358 .485 -.951 .162 .934 -1.275 ; /* Use the Gauss-Newton method to estimate the CES production function */ proc nlin data=ces; parms b0=1 a=-1 d=.5 r=-1; lr=l**r; kr=k**r; z=d*lr+(1-d)*kr; model logq=b0+a*log(z); der.b0=1; der.a=log(z); der.d=(a/z)*(lr-kr); der.r=(a/z)*(d*log(l)*lr+(1-d)*log(k)*kr); run; /* Let's use multiple starting points to assure ourselves that we have reached global minimum */ proc nlin data=ces best=8; parms b0=0 to 2 by 0.5 a=-2 to 0 by 0.5 d=0 to 1 by 0.5 r=-2 to 0 by 0.5; lr=l**r; kr=k**r; z=d*lr+(1-d)*kr; model logq=b0+a*log(z); der.b0=1; der.a=log(z); der.d=(a/z)*(lr-kr); der.r=(a/z)*(d*log(l)*lr+(1-d)*log(k)*kr); run; /* Let's use the secant method (DUD) by using proc nlin but without specifying the first derivatives. We should get roughly the same results obtained in the Gauss-Newton method. */ proc nlin data=ces; parms b0=1 a=-1 d=.5 r=-1; lr=l**r; kr=k**r; z=d*lr+(1-d)*kr; model logq=b0+a*log(z); run; proc nlin data=ces best=8; parms b0=0 to 2 by 0.5 a=-2 to 0 by 0.5 d=0 to 1 by 0.5 r=-2 to 0 by 0.5; lr=l**r; kr=k**r; z=d*lr+(1-d)*kr; model logq=b0+a*log(z); run;