OPTIONS LINESIZE=80;
TITLE1 'Linear Least-Square Regression Example';
TITLE2 'Dependent Variable, Y: Oxygen Purity (%)';
TITLE3 'Independent Variable, X: Hydrocarbon Level (%)';
DATA ChemHC;
/* @@ means a loop in reading input variable sequence */
INPUT Purity H_Carbon @@;
CARDS;
90.01 0.99 89.05 1.02 91.43 1.15
93.74 1.29 96.73 1.46 94.45 1.36
87.59 0.87 91.77 1.23 99.42 1.55
93.65 1.40 93.54 1.19 92.52 1.15
90.56 0.98 89.54 1.01 89.85 1.11
90.39 1.20 93.25 1.26 93.41 1.32
94.98 1.43 87.33 0.95
;
RUN;
/* Print the original data set */
PROC PRINT;
RUN;
/* Regression Procedure */
PROC REG DATA=ChemHC;
MODEL Purity = H_Carbon /P R;
/* P = Calculates predicted values from the */
/* input data and the estimated regression */
/* model */
/* R = Calculate the analysis of the residuals */
/* Create output dataset "A" for later plotting */
OUTPUT OUT=A P=YHAT R=RESID STUDENT=STDR;
RUN;
/* Plot output sub-datasets 'YHAT', 'RESID' and 'STDR' */
/* from the regression analysis output dataset "A" */
PROC PLOT DATA=A;
PLOT RESID * YHAT;
PLOT STDR * YHAT;
RUN;
/* Compute Normal Scores of input data, 'A' */
/* using cum. normal function/Residual */
/* BLOM -> yi = þ-1(ri -3/8)/(n+1/4) */
/* ri = rank of the ith obs */
PROC RANK DATA=A NORMAL=BLOM OUT=NPLOT;
VAR RESID;
RANKS NSCORE;
RUN;
PROC PLOT DATA=NPLOT;
PLOT NSCORE * RESID;
RUN;
/* Compute Normal Scores of input data, 'A' */
/* using cum. normal function/Studentized Residual */
/* BLOM -> yi = þ-1(ri -3/8)/(n+1/4) */
/* ri = rank of the ith obs */
PROC RANK DATA=A NORMAL=BLOM OUT=NPLOT;
VAR STDR;
RANKS NTSCORE;
RUN;
PROC PLOT DATA=NPLOT;
PLOT NTSCORE * STDR;
RUN;
|