Data visualization with SAS programming

Extend Prediction Lines Beyond Data Scope

Accepted Solution Solved
Reply
Regular Contributor
Posts: 223
Accepted Solution

Extend Prediction Lines Beyond Data Scope

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;

Shelf life estimation with upper acceptance criterion based on a degradation product at 25C/60%RH


Accepted Solutions
Solution
‎03-31-2014 02:54 PM
Super User
Posts: 19,064

Re: Extend Prediction Lines Beyond Data Scope

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;

View solution in original post


All Replies
Super User
Posts: 11,114

Re: Extend Prediction Lines Beyond Data Scope

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.

Regular Contributor
Posts: 223

Re: Extend Prediction Lines Beyond Data Scope

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;

Solution
‎03-31-2014 02:54 PM
Super User
Posts: 19,064

Re: Extend Prediction Lines Beyond Data Scope

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;

Regular Contributor
Posts: 223

Re: Extend Prediction Lines Beyond Data Scope

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!

Super User
Posts: 19,064

Re: Extend Prediction Lines Beyond Data Scope

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.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 1328 views
  • 0 likes
  • 3 in conversation