*** ROBUST REGRESSION * Read in the data from {FEV.xls} ; PROC IMPORT DATAFILE = 'C:\Documents and Settings\richc\My Documents\CPH931F08\FEV.xls' OUT = pulmonary DBMS = EXCEL REPLACE; SHEET = FEV; GETNAMES = YES; RUN; * Initiate a ``transcript'' in the Word file {pulmresults.rtf}. ; ODS RTF FILE = 'C:\Documents and Settings\richc\My Documents\CPH931F08\pulmresults.rtf'; * Fit a linear regression model via ordinary least squares. * The response variable is forced expiratory volume (after * logarithmic transformation). The explanatory variables * are age in years, height in inches, gender (1 male, * 0 female), and smoking status (1 yes, 0 no). ; PROC REG DATA = pulmonary; MODEL logFEV = Age Hgt Sex Smoke / influence ; PLOT RSTUDENT. * P.; PLOT RSTUDENT. * AGE; PLOT RSTUDENT. * HGT; PLOT RSTUDENT. * SEX; PLOT RSTUDENT. * SMOKE; RUN; * Fit a linear regression model via M estimation (robust * method). ; proc robustreg data=pulmonary; model logFEV = Age Hgt Sex Smoke ; run; * End Word transcript. ; ODS RTF CLOSE; RUN; *** NONPARAMETRIC REGRESSION * Read in the data from {BWeight.xls} ; PROC IMPORT DATAFILE = 'C:\Documents and Settings\richc\My Documents\CPH931F08\BWeight.xls' OUT = Infants DBMS = EXCEL REPLACE; SHEET = BWeight; GETNAMES = YES; RUN; * Sort the data by gestational age. ; PROC SORT DATA=Infants; by gest; run; * Initiate a ``transcript'' in the Word file {infresults.rtf}. ; ODS RTF FILE = 'C:\Documents and Settings\richc\My Documents\CPH931F08\infresults.rtf'; * Fit a linear regression model by ordinary least squares. * The response variable is birthweight. The explanatory * variable is gestational age. ; proc reg data=Infants; model bwt = gest; plot bwt * gest; run; quit; * Model the relationship between birthweight and gestational * age via LOESS estimation (nonparametric method). ; ods output OutputStatistics=Infantsstats; proc loess data=Infants; model bwt = gest; run; symbol1 color=black value=dot h=2 pct; symbol2 color=black interpol=join value=none width=1; proc gplot data=Infantsstats; plot (depvar pred)*gest / overlay hminor = 0 vminor = 0 vaxis = axis1 frame cframe=ligr; axis1 label = ( r=20 a=50 ) order=(0 to 5000 by 250); title 'LOESS estimation'; run; * End Word transcript. ; ODS RTF CLOSE; RUN;