/*start by setting the graphics options --Note that names of windows fonts are given in quotes*/ goptions reset=global gunit=in ftitle="garamond" ftext="garamond" htitle=.5 htext=.5; /* read in some data -- look familiar? */ data example; input northing easting z; cards; 1 1 1 1 2 5 1 3 10 1 4 6 1 5 2 1 6 1 1 7 4 1 8 9 1 9 7 ; proc print; Title1 'The Data'; proc gplot data=example; symbol1 v=dot h=.3 cv=grey; plot z*easting ; run; /*linear regression */ Title1 'The Linear Fit: Degree=1'; Proc glm data = example; model z=easting / solution; output out=pred p=predicted r=residual; proc gplot data=pred; symbol1 v=dot h=.3 cv=grey ; symbol2 v= i=spline l=5 w=2 color=red; plot z*easting= 1 predicted*easting= 2 / overlay; run; /*Quadratic */ Title1 'The Quadratic Fit: Degree=2'; Proc glm data = example; model z=easting easting*easting/ solution; output out=pred p=predicted r=residual; proc gplot data=pred; plot z*easting= 1 predicted*easting= 2 / overlay; run; /*cubic*/ Title1 'The Cubic Fit: Degree=3'; Proc glm data = example; model z=easting easting*easting easting*easting*easting / solution; output out=pred p=predicted r=residual; proc gplot data=pred; plot z*easting= 1 predicted*easting= 2 / overlay; run; /*quartic*/ Title1 'The Quartic Fit: Degree=4'; Proc glm data = example; model z=easting easting*easting easting*easting*easting easting*easting*easting*easting / solution; output out=pred p=predicted r=residual; proc gplot data=pred; plot z*easting= 1 predicted*easting= 2 / overlay; run; /*quintic*/ Title1 'The Quintic Fit: Degree=5'; Proc glm data = example; model z=easting easting*easting easting*easting*easting easting*easting*easting*easting easting*easting*easting*easting*easting / solution; output out=pred p=predicted r=residual; proc gplot data=pred; plot z*easting= 1 predicted*easting= 2 / overlay; run; /*loess*/ Title1 'Loess: lambda=2, alpha chosen by GCV'; proc loess data =example; ods Output OutputStatistics=StatOut; model z = easting / degree=2 select=gcv ; proc gplot data=StatOut;; plot depvar*easting= 1 pred*easting= 2 / overlay; run; /*loess*/ Title1 'Loess: lambda=1, alpha chosen by GCV'; proc loess data =example; ods Output OutputStatistics=StatOut; model z = easting / degree=1 select=gcv ; proc gplot data=StatOut;; plot depvar*easting= 1 pred*easting= 2 / overlay; run;