The script analyzes data from 15 patients to predict a recovery prognosis index (prog) based on the number of hospitalization days (days). First, it uses a DATA step to create the 'patient' table from embedded data (cards). Then, it fits an exponential nonlinear regression model `prog = a0*exp(a1*days)` with PROC NLIN. It generates predictions, residuals, and confidence intervals. Graphs (PROC GPLOT) are created to visualize raw data and model fit. In parallel, a second linear regression model is tested on the logarithm of the response variable (`ln(prog)`) with PROC REG to compare approaches.
Data Analysis
Type : CREATION_INTERNE
Data is created directly in the script via a DATA step and the 'cards' statement, forming the 'patient' table with 15 observations and 3 variables (prog, days, lnprog).
1 Code Block
DATA STEP Data
Explanation : This block creates the 'patient' table in memory. It reads two variables, 'prog' (prognosis index) and 'days' (days of hospitalization), from the data provided via the 'cards' statement. It also calculates 'lnprog', the natural logarithm of 'prog'.
Explanation : This procedure fits a nonlinear regression model. The model has an exponential form: `prog = a0*exp(a1*days)`. Initial values for parameters `a0` and `a1` are provided. The procedure calculates parameter estimates and generates an output table 'a' containing predicted values, residuals, and 90% confidence and prediction intervals (alpha=0.1).
Explanation : Prints the content of table 'a' generated by PROC NLIN, which contains the modeling results (observed, predicted values, residuals, etc.).
Copied!
proc print data=a;
run;
1
PROC PRINTDATA=a;
2
RUN;
4 Code Block
PROC PLOT
Explanation : The PROC PLOT procedure is used to create a graph of residuals versus predicted values, to graphically assess the appropriateness of the nonlinear model.
Copied!
proc plot;
plot resid*p;
run;
1
PROC PLOT;
2
plot resid*p;
3
RUN;
5 Code Block
PROC GPLOT
Explanation : This block configures graphical options (goptions, title, symbol, axis) to generate graphs. The first PROC GPLOT creates a scatter plot of the original data. The second superimposes the fitted model curve on the scatter plot to visualize the fit.
Copied!
goptions reset=global gunit=pct border cback=white
colors=(black blue green red)
ftitle=swissb ftext=swiss htitle=4 htext=4;
title1 'Prognostic index versus Days';
symbol1 color=red
interpol=none
value=dot
height=3;
symbol2 color=red
interpol=join;
axis1 label=('Days')
order=(0 to 70 by 10)
width=3;
axis2 label=('Pyrene')
order=(0 to 60 by 10)
width=3;
proc gplot data=a;
plot prog*days/ haxis=axis1 vaxis=axis2;
run;
proc gplot data=a;
plot prog*days p*days/ overlay haxis=axis1 vaxis=axis2;
run;
quit;
Explanation : For comparison purposes, this procedure performs a simple linear regression on the 'lnprog' variable (logarithm of the prognosis index) as a function of 'days'. The results, including predicted values and residuals, are stored in table 'b'.
Copied!
proc reg;
model lnprog=days;
output out=b p=pln r=residln;
run;
1
PROC REG;
2
model lnprog=days;
3
OUTPUT out=b p=pln r=residln;
4
RUN;
7 Code Block
PROC PLOT
Explanation : This block uses PROC PLOT to display the residual plot of the linear model versus predicted values. This allows checking the homoscedasticity assumption (constant variance of residuals) for the log-linear model.
Copied!
proc plot;
plot residln*pln;
run;
1
PROC PLOT;
2
plot residln*pln;
3
RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Data source: Textbook 'Applied Linear Statistical Model', Kutner et al. (5th), p.515. Original file name: ch13-patient-nonlinear.sas
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.