| Date: | Thu, 3 Jul 2003 17:20:11 -0400 |
| Reply-To: | Michael Murff <murffmj@LDSCHURCH.ORG> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Michael Murff <murffmj@LDSCHURCH.ORG> |
| Subject: | PROC LOESS |
| Content-Type: | text/plain; charset=ISO-8859-1 |
Hi SAS friends,
Following is a program that I adapted from the SAS STAT documentation for
PROC LOESS. What's perplexing is that my output has a "connect the dots"
appearance, rather than a single smoothed regression that centers in the
data. Anyone know why this would occur?
many thanks!
Michael Murff,
SLC, Utah
**eliminates duplicate matches for US file; *preparation for proc loess;
**to address multiple lines in graphs;
**LOESS or local regression is used when data contains outliers and
robustness is desired;
**beware of overfitting by choosing an smoothing parameter that is too
small;
**SAS defalut for alpha=.5 although it will optimially select alpaha too;
**requires the data set "usjob" to be present in the work libarary;
**run WW_merge.sas first in order to create usjob;
**COP has used "Incumbent Weighted Salary" in the past;
**A strong preference exists to continue use of this depvar;
**"Incumbent Weighted Salary" = wsal;
**eliminate duplicates;
data usjob temp1; set wwjob(keep=id sheet_code wsal hay);
where sheet_code='US';
by id;
if last.id then output usjob;
else output temp1;
run;
proc freq data=usjob;
tables id;
run;
**check for duplicate ids;
proc freq data=usjob;
tables id;
run;
**basic local regression;
proc loess data=usjob;
model wsal=hay/details(OutputStatistics);
run;
**introduce ods statement to generate output dataset;
proc loess data=usjob;
model wsal=hay;
ods output OutputStatistics=Results;
run;
**check predictions and output;
title1 ’First 5 Observations of the Results Data Set’;
proc print data=Results(obs=5);
id obs;
run;
symbol1 color=black value=dot;
symbol2 color=black interpol=join value=none;
/* macro used in subsequent examples */
%let opts=vaxis=axis1 hm=3 vm=3 overlay;
axis1 label=(angle=90 rotate=0);
proc gplot data=Results;
title1 "Wage Data with Default LOESS Fit";
plot DepVar*hay Pred*hay/ &opts;
run;
proc loess data=usjob;
model wsal=hay/smooth=0.1 0.2 0.3 0.4 residual;
ods output OutputStatistics=Results;
run;
proc print data=Results(obs=5);
id obs;
run;
goptions nodisplay;
proc gplot data=Results;
by SmoothingParameter;
plot DepVar*hay=1 Pred*hay/ &opts name= "fit";
run; quit;
goptions display;
proc greplay nofs tc=sashelp.templt template=l2r2;
igout gseg;
treplay 1:fit 2:fit2 3:fit1 4:fit3;
run; quit;
|