OPTIONS LS=76 PS=80 NODATE NONUMBER; /* Example 1 */ title 'NEGATIVE EXPONENTIAL: Y=B0*(1-EXP(-B1*X))'; data a; input x y @@; cards; 020 0.57 030 0.72 040 0.81 050 0.87 060 0.91 070 0.94 080 0.95 090 0.97 100 0.98 110 0.99 120 1.00 130 0.99 140 0.99 150 1.00 160 1.00 170 0.99 180 1.00 190 1.00 200 0.99 210 1.00 ; proc nlin best=10 plot method=marquardt; parms b0=0 to 2 by .5 b1=.01 to .09 by .01; model y=b0*(1-exp(-b1*x)); der.b0=1-exp(-b1*x); der.b1=b0*x*exp(-b1*x); output out=b p=yhat r=yresid; proc plot data=b; plot y*x='a' yhat*x='p' /overlay vpos=30; plot yresid*x / vref=0 vpos=30; run; /* Example 2*/ 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 ; 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; /* Example 3 */ *---------FITTING A SEGMENTED MODEL USING NLIN-----* | | | | y | quadratic plateau | | | y=a+b*x+c*x*x y=p | | | ..................... | | | . : | | | . : | | | . : | | | . : | | | . : | | +-----------------------------------------x | | x0 | | | | continuity restriction: p=a+b*x0+c*x0**2 | | smoothness restriction: 0=b+2*c*x0 so x0=-b/(2*c)| *--------------------------------------------------*; title 'QUADRATIC MODEL WITH PLATEAU'; data a; input y x @@; cards; .46 1 .47 2 .57 3 .61 4 .62 5 .68 6 .69 7 .78 8 .70 9 .74 10 .77 11 .78 12 .74 13 .80 13 .80 15 .78 16 ; proc nlin; parms a=.45 b=.05 c=-.0025; file print; x0=-.5*b/c; * estimate join point; db=-.5/c; * deriv of x0 wrt b; dc=.5*b/c**2; * deriv of x0 wrt c; if x