I am trying to figure out how to make a prediction line extend beyond the scope of my data. For example, in an FDA guidance document (http://www.fda.gov/RegulatoryInformation/Guidances/ucm128092.htm) there is a sample stability plot where the data points stop at 12 months, but the regression and confidence line extend to 48 months (see plot below). Is it possible to do this simply with the SGPLOT procedure? Also, can I get just one confidence limit instead of both the upper and lower? Here is sample code of what I have done in an attempt to copy the graph (notice how my regression and prediction lines stop at 12 months and I have bot the upper and lower limits):
data stability;
input time impurity;
cards;
0 0.65
3 0.68
6 0.72
9 0.75
12 0.85
;
run;
proc sgplot data=stability;
title "Shelf life Estimation with Upper and Lower Acceptance Criteria Based on a Degradation Product at 25C/60% RH";
scatter x=time y=impurity/ markerattrs=(symbol=diamond);
reg x=time y=impurity/ lineattrs=(color=black) cli cliattrs=(clilineattrs=(color=black pattern=1));
refline 1.45 / lineattrs=(pattern=4 thickness=2 color=black);
xaxis label='Time Point (Months)' values=(0 to 48 by 3);
yaxis label="Degradation Product (%)" values=(0 to 3 by 0.5);
keylegend / position=right;
run;
THIS IS NOT STATISTICALLY CORRECT.
However, I do recall the Confidence limits were a function of the original estimates plus something, just can't recall what the something is. But if you can figure it out this is a good starting point.
Also, this is time data, so you may want to look into the ETS procs.
data stability;
input time impurity;
cards;
0 0.65
3 0.68
6 0.72
9 0.75
12 0.85
15 .
18 .
21 .
24 .
;
run;
proc reg data=stability;
model impurity=time / cli;
output out=reg p=pred2 ucl=upper lcl=lower;
quit;
I would approach this by using an actual regression procedure with the input data having the addition time points needed and then have the output data include the predicted values and limits. The procedure will provide a predicted value for independent x value in the input dataset. That way you could select which limit you would graph as well as indicating which of the markers are actual and predicted.
Can you give me an example of what you mean? I can get the predicted values for the data in range, but not extended beyond that. I attempted to use the stability data to get the parameter estimates. I then used that to assemble the formula for the regression line and was able to expand the predicted values. However, I can't get the 95% confidence limits. They are just the exact same as the predicted values. Can you tell me what I am doing wrong?
data stability;
input time impurity;
cards;
0 0.65
3 0.68
6 0.72
9 0.75
12 0.85
;
run;
/*** Get parmeter estimates for specified model ***/
ods listing close;
ods output ParameterEstimates=est;
proc reg data=stability;
model impurity=time;
quit;
ods listing;
/*** Store parameter estimates in macro variables ***/
proc sql noprint;
select estimate into :int from est where variable='Intercept';
select estimate into :time from est where variable='time';
quit;
/*** Create predicted values from the regression equation formed from parameter estimates ***/
data pred;
do time=0 to 48 by .1;
pred=&int.+(&time.*time);
output;
end;
run;
/*** Rerun regression analysis to get confidence limits ***/
proc reg data=pred;
model pred=time / cli;
output out=reg p=pred2;
quit;
THIS IS NOT STATISTICALLY CORRECT.
However, I do recall the Confidence limits were a function of the original estimates plus something, just can't recall what the something is. But if you can figure it out this is a good starting point.
Also, this is time data, so you may want to look into the ETS procs.
data stability;
input time impurity;
cards;
0 0.65
3 0.68
6 0.72
9 0.75
12 0.85
15 .
18 .
21 .
24 .
;
run;
proc reg data=stability;
model impurity=time / cli;
output out=reg p=pred2 ucl=upper lcl=lower;
quit;
I can't validate if this is correct or if it is just getting me something that looks very close, but it looks like just adding the missing y-values for the x-values beyond the scope of the data did the trick. Thanks!
Prediction intervals have a different formula than confidence intervals. If you're trying to calculate the prediction confidence intervals it will be a different formula.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.