Chapter Contents |
Previous |
Next |
The NLIN Procedure |
That is, for values of x less than x0, the equation relating y and x is quadratic (a parabola); and, for values of x greater than x0, the equation is constant (a horizontal line). PROC NLIN can fit such a segmented model even when the joint point, x0, is unknown.
The curve must be continuous (the two sections must meet at x0), and the curve must be smooth (the first derivatives with respect to x are the same at x0).
These conditions imply that
The segmented equation includes only three parameters; however, the equation is nonlinear with respect to these parameters.
You can write program statements with PROC NLIN to conditionally execute different sections of code for the two parts of the model, depending on whether x is less than x0 .
A PUT statement is used to print the constrained parameters every time the program is executed for the first observation (where x =1). The following statements perform the analysis.
*---------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 @@; datalines; .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; x0=-.5*b / c; * Estimate join point; if x<x0 then * Quadratic part of Model; model y=a+b*x+c*x*x; else * Plateau part of Model; model y=a+b*x0+c*x0*x0; if _obs_=1 and _iter_ =. then do; plateau=a+b*x0+c*x0*x0; put / x0= plateau= ; end; output out=b predicted=yp; run; /* Setup for creating the graph */ legend1 frame cframe=ligr label=none cborder=black position=center value=(justify=center); axis1 label=(angle=90 rotate=0) minor=none; axis2 minor=none; proc gplot; plot y*x yp*x/frame cframe=ligr legend=legend1 vaxis=axis1 haxis=axis2 overlay ; run;
Output 45.1.1: Nonlinear Least Squares Iterative Phase
|
Chapter Contents |
Previous |
Next |
Top |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.